setsum -> sum
authornipkow
Mon Oct 17 11:46:22 2016 +0200 (2016-10-17)
changeset 64267b9a1486e79be
parent 64265 8eb6365f5916
child 64268 3faa948dc861
setsum -> sum
src/Doc/Logics/document/HOL.tex
src/Doc/Main/Main_Doc.thy
src/Doc/Sugar/Sugar.thy
src/HOL/Algebra/IntRing.thy
src/HOL/Analysis/Binary_Product_Measure.thy
src/HOL/Analysis/Bochner_Integration.thy
src/HOL/Analysis/Borel_Space.thy
src/HOL/Analysis/Bounded_Continuous_Function.thy
src/HOL/Analysis/Bounded_Linear_Function.thy
src/HOL/Analysis/Brouwer_Fixpoint.thy
src/HOL/Analysis/Caratheodory.thy
src/HOL/Analysis/Cartesian_Euclidean_Space.thy
src/HOL/Analysis/Cauchy_Integral_Theorem.thy
src/HOL/Analysis/Complex_Analysis_Basics.thy
src/HOL/Analysis/Complex_Transcendental.thy
src/HOL/Analysis/Conformal_Mappings.thy
src/HOL/Analysis/Continuous_Extension.thy
src/HOL/Analysis/Convex_Euclidean_Space.thy
src/HOL/Analysis/Derivative.thy
src/HOL/Analysis/Determinants.thy
src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy
src/HOL/Analysis/Euclidean_Space.thy
src/HOL/Analysis/Fashoda_Theorem.thy
src/HOL/Analysis/Finite_Cartesian_Product.thy
src/HOL/Analysis/Gamma_Function.thy
src/HOL/Analysis/Harmonic_Numbers.thy
src/HOL/Analysis/Henstock_Kurzweil_Integration.thy
src/HOL/Analysis/Homeomorphism.thy
src/HOL/Analysis/Inner_Product.thy
src/HOL/Analysis/Integral_Test.thy
src/HOL/Analysis/L2_Norm.thy
src/HOL/Analysis/Lebesgue_Measure.thy
src/HOL/Analysis/Linear_Algebra.thy
src/HOL/Analysis/Measure_Space.thy
src/HOL/Analysis/Nonnegative_Lebesgue_Integration.thy
src/HOL/Analysis/Ordered_Euclidean_Space.thy
src/HOL/Analysis/Path_Connected.thy
src/HOL/Analysis/Poly_Roots.thy
src/HOL/Analysis/Polytope.thy
src/HOL/Analysis/Regularity.thy
src/HOL/Analysis/Summation_Tests.thy
src/HOL/Analysis/Tagged_Division.thy
src/HOL/Analysis/Topology_Euclidean_Space.thy
src/HOL/Analysis/Uniform_Limit.thy
src/HOL/Analysis/Weierstrass_Theorems.thy
src/HOL/Analysis/ex/Approximations.thy
src/HOL/Binomial.thy
src/HOL/Complex.thy
src/HOL/Datatype_Examples/Misc_Primrec.thy
src/HOL/Decision_Procs/Approximation.thy
src/HOL/Deriv.thy
src/HOL/Groups_Big.thy
src/HOL/Groups_List.thy
src/HOL/HOLCF/Universal.thy
src/HOL/Hoare_Parallel/OG_Examples.thy
src/HOL/Hoare_Parallel/RG_Examples.thy
src/HOL/IMP/Abs_Int0.thy
src/HOL/IMP/Abs_Int1.thy
src/HOL/IMP/Abs_Int3.thy
src/HOL/IMP/Abs_Int_ITP/Abs_Int1_ITP.thy
src/HOL/IMP/Abs_Int_ITP/Abs_Int3_ITP.thy
src/HOL/Inequalities.thy
src/HOL/Int.thy
src/HOL/Library/BigO.thy
src/HOL/Library/Bourbaki_Witt_Fixpoint.thy
src/HOL/Library/Combine_PER.thy
src/HOL/Library/Extended_Nat.thy
src/HOL/Library/Extended_Nonnegative_Real.thy
src/HOL/Library/Extended_Real.thy
src/HOL/Library/FSet.thy
src/HOL/Library/Finite_Map.thy
src/HOL/Library/Formal_Power_Series.thy
src/HOL/Library/Groups_Big_Fun.thy
src/HOL/Library/Indicator_Function.thy
src/HOL/Library/Multiset.thy
src/HOL/Library/Multiset_Permutations.thy
src/HOL/Library/Nat_Bijection.thy
src/HOL/Library/Permutations.thy
src/HOL/Library/Polynomial.thy
src/HOL/Library/Polynomial_FPS.thy
src/HOL/Library/Polynomial_Factorial.thy
src/HOL/Library/Product_Plus.thy
src/HOL/Library/RBT_Set.thy
src/HOL/Library/Set_Algebras.thy
src/HOL/Library/Stirling.thy
src/HOL/Lifting_Set.thy
src/HOL/Limits.thy
src/HOL/List.thy
src/HOL/MacLaurin.thy
src/HOL/Metis_Examples/Big_O.thy
src/HOL/Nat_Transfer.thy
src/HOL/Nitpick.thy
src/HOL/Nonstandard_Analysis/HSeries.thy
src/HOL/Nonstandard_Analysis/Nonstandard_Analysis.thy
src/HOL/NthRoot.thy
src/HOL/Number_Theory/Cong.thy
src/HOL/Number_Theory/Factorial_Ring.thy
src/HOL/Number_Theory/Fib.thy
src/HOL/Old_Number_Theory/Euler.thy
src/HOL/Old_Number_Theory/Fib.thy
src/HOL/Old_Number_Theory/Finite2.thy
src/HOL/Old_Number_Theory/Quadratic_Reciprocity.thy
src/HOL/Old_Number_Theory/Residues.thy
src/HOL/Predicate_Compile_Examples/Predicate_Compile_Quickcheck_Examples.thy
src/HOL/Probability/Central_Limit_Theorem.thy
src/HOL/Probability/Characteristic_Functions.thy
src/HOL/Probability/Distributions.thy
src/HOL/Probability/Independent_Family.thy
src/HOL/Probability/Information.thy
src/HOL/Probability/PMF_Impl.thy
src/HOL/Probability/Probability_Mass_Function.thy
src/HOL/Probability/Probability_Measure.thy
src/HOL/Probability/Projective_Limit.thy
src/HOL/Probability/SPMF.thy
src/HOL/Probability/ex/Koepf_Duermuth_Countermeasure.thy
src/HOL/Rat.thy
src/HOL/Real.thy
src/HOL/Real_Vector_Spaces.thy
src/HOL/Series.thy
src/HOL/Set_Interval.thy
src/HOL/Transcendental.thy
src/HOL/UNITY/Comp/Alloc.thy
src/HOL/UNITY/Comp/AllocBase.thy
src/HOL/UNITY/Comp/AllocImpl.thy
src/HOL/UNITY/Follows.thy
src/HOL/ex/Execute_Choice.thy
src/HOL/ex/HarmonicSeries.thy
src/HOL/ex/Meson_Test.thy
src/HOL/ex/Sum_of_Powers.thy
src/HOL/ex/ThreeDivides.thy
src/HOL/ex/Transfer_Int_Nat.thy
     1.1 --- a/src/Doc/Logics/document/HOL.tex	Sun Oct 16 22:43:51 2016 +0200
     1.2 +++ b/src/Doc/Logics/document/HOL.tex	Mon Oct 17 11:46:22 2016 +0200
     1.3 @@ -145,7 +145,7 @@
     1.4  numbers).  The type class \cldx{plus_ac0} comprises all types for which 0
     1.5  and~+ satisfy the laws $x+y=y+x$, $(x+y)+z = x+(y+z)$ and $0+x = x$.  These
     1.6  types include the numeric ones \tdx{nat}, \tdx{int} and~\tdx{real} and also
     1.7 -multisets.  The summation operator \cdx{setsum} is available for all types in
     1.8 +multisets.  The summation operator \cdx{sum} is available for all types in
     1.9  this class. 
    1.10  
    1.11  Theory \thydx{Ord} defines the syntactic class \cldx{ord} of order
     2.1 --- a/src/Doc/Main/Main_Doc.thy	Sun Oct 16 22:43:51 2016 +0200
     2.2 +++ b/src/Doc/Main/Main_Doc.thy	Mon Oct 17 11:46:22 2016 +0200
     2.3 @@ -408,7 +408,7 @@
     2.4  @{const Finite_Set.finite} & @{term_type_only Finite_Set.finite "'a set\<Rightarrow>bool"}\\
     2.5  @{const Finite_Set.card} & @{term_type_only Finite_Set.card "'a set \<Rightarrow> nat"}\\
     2.6  @{const Finite_Set.fold} & @{term_type_only Finite_Set.fold "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"}\\
     2.7 -@{const Groups_Big.setsum} & @{term_type_only Groups_Big.setsum "('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'b::comm_monoid_add"}\\
     2.8 +@{const Groups_Big.sum} & @{term_type_only Groups_Big.sum "('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'b::comm_monoid_add"}\\
     2.9  @{const Groups_Big.setprod} & @{term_type_only Groups_Big.setprod "('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'b::comm_monoid_mult"}\\
    2.10  \end{supertabular}
    2.11  
    2.12 @@ -416,8 +416,8 @@
    2.13  \subsubsection*{Syntax}
    2.14  
    2.15  \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}}
    2.16 -@{term "setsum (\<lambda>x. x) A"} & @{term[source]"setsum (\<lambda>x. x) A"} & (\<^verbatim>\<open>SUM\<close>)\\
    2.17 -@{term "setsum (\<lambda>x. t) A"} & @{term[source]"setsum (\<lambda>x. t) A"}\\
    2.18 +@{term "sum (\<lambda>x. x) A"} & @{term[source]"sum (\<lambda>x. x) A"} & (\<^verbatim>\<open>SUM\<close>)\\
    2.19 +@{term "sum (\<lambda>x. t) A"} & @{term[source]"sum (\<lambda>x. t) A"}\\
    2.20  @{term[source] "\<Sum>x|P. t"} & @{term"\<Sum>x|P. t"}\\
    2.21  \multicolumn{2}{@ {}l@ {}}{Similarly for \<open>\<Prod>\<close> instead of \<open>\<Sum>\<close>} & (\<^verbatim>\<open>PROD\<close>)\\
    2.22  \end{supertabular}
    2.23 @@ -463,10 +463,10 @@
    2.24  @{term[source] "\<Union>i\<le>n. A"} & @{term[source] "\<Union>i \<in> {..n}. A"}\\
    2.25  @{term[source] "\<Union>i<n. A"} & @{term[source] "\<Union>i \<in> {..<n}. A"}\\
    2.26  \multicolumn{2}{@ {}l@ {}}{Similarly for \<open>\<Inter>\<close> instead of \<open>\<Union>\<close>}\\
    2.27 -@{term "setsum (\<lambda>x. t) {a..b}"} & @{term[source] "setsum (\<lambda>x. t) {a..b}"}\\
    2.28 -@{term "setsum (\<lambda>x. t) {a..<b}"} & @{term[source] "setsum (\<lambda>x. t) {a..<b}"}\\
    2.29 -@{term "setsum (\<lambda>x. t) {..b}"} & @{term[source] "setsum (\<lambda>x. t) {..b}"}\\
    2.30 -@{term "setsum (\<lambda>x. t) {..<b}"} & @{term[source] "setsum (\<lambda>x. t) {..<b}"}\\
    2.31 +@{term "sum (\<lambda>x. t) {a..b}"} & @{term[source] "sum (\<lambda>x. t) {a..b}"}\\
    2.32 +@{term "sum (\<lambda>x. t) {a..<b}"} & @{term[source] "sum (\<lambda>x. t) {a..<b}"}\\
    2.33 +@{term "sum (\<lambda>x. t) {..b}"} & @{term[source] "sum (\<lambda>x. t) {..b}"}\\
    2.34 +@{term "sum (\<lambda>x. t) {..<b}"} & @{term[source] "sum (\<lambda>x. t) {..<b}"}\\
    2.35  \multicolumn{2}{@ {}l@ {}}{Similarly for \<open>\<Prod>\<close> instead of \<open>\<Sum>\<close>}\\
    2.36  \end{supertabular}
    2.37  
     3.1 --- a/src/Doc/Sugar/Sugar.thy	Sun Oct 16 22:43:51 2016 +0200
     3.2 +++ b/src/Doc/Sugar/Sugar.thy	Mon Oct 17 11:46:22 2016 +0200
     3.3 @@ -13,9 +13,9 @@
     3.4  This document is for those Isabelle users who have mastered
     3.5  the art of mixing \LaTeX\ text and Isabelle theories and never want to
     3.6  typeset a theorem by hand anymore because they have experienced the
     3.7 -bliss of writing \verb!@!\verb!{thm[display,mode=latex_sum] setsum_Suc_diff [no_vars]}!
     3.8 +bliss of writing \verb!@!\verb!{thm[display,mode=latex_sum] sum_Suc_diff [no_vars]}!
     3.9  and seeing Isabelle typeset it for them:
    3.10 -@{thm[display,mode=latex_sum] setsum_Suc_diff[no_vars]}
    3.11 +@{thm[display,mode=latex_sum] sum_Suc_diff[no_vars]}
    3.12  No typos, no omissions, no sweat.
    3.13  If you have not experienced that joy, read Chapter 4, \emph{Presenting
    3.14  Theories}, @{cite LNCS2283} first.
     4.1 --- a/src/HOL/Algebra/IntRing.thy	Sun Oct 16 22:43:51 2016 +0200
     4.2 +++ b/src/HOL/Algebra/IntRing.thy	Mon Oct 17 11:46:22 2016 +0200
     4.3 @@ -91,7 +91,7 @@
     4.4    rewrites int_carrier_eq: "carrier \<Z> = UNIV"
     4.5      and int_zero_eq: "zero \<Z> = 0"
     4.6      and int_add_eq: "add \<Z> x y = x + y"
     4.7 -    and int_finsum_eq: "finsum \<Z> f A = setsum f A"
     4.8 +    and int_finsum_eq: "finsum \<Z> f A = sum f A"
     4.9  proof -
    4.10    \<comment> "Specification"
    4.11    show "abelian_monoid \<Z>" by standard auto
    4.12 @@ -105,7 +105,7 @@
    4.13    note add = this
    4.14    show zero: "zero \<Z> = 0"
    4.15      by simp
    4.16 -  show "finsum \<Z> f A = setsum f A"
    4.17 +  show "finsum \<Z> f A = sum f A"
    4.18      by (induct A rule: infinite_finite_induct, auto)
    4.19  qed
    4.20  
    4.21 @@ -117,7 +117,7 @@
    4.22    rewrites "carrier \<Z> = UNIV"
    4.23      and "zero \<Z> = 0"
    4.24      and "add \<Z> x y = x + y"
    4.25 -    and "finsum \<Z> f A = setsum f A"
    4.26 +    and "finsum \<Z> f A = sum f A"
    4.27      and int_a_inv_eq: "a_inv \<Z> x = - x"
    4.28      and int_a_minus_eq: "a_minus \<Z> x y = x - y"
    4.29  proof -
    4.30 @@ -150,7 +150,7 @@
    4.31    rewrites "carrier \<Z> = UNIV"
    4.32      and "zero \<Z> = 0"
    4.33      and "add \<Z> x y = x + y"
    4.34 -    and "finsum \<Z> f A = setsum f A"
    4.35 +    and "finsum \<Z> f A = sum f A"
    4.36      and "a_inv \<Z> x = - x"
    4.37      and "a_minus \<Z> x y = x - y"
    4.38  proof -
     5.1 --- a/src/HOL/Analysis/Binary_Product_Measure.thy	Sun Oct 16 22:43:51 2016 +0200
     5.2 +++ b/src/HOL/Analysis/Binary_Product_Measure.thy	Mon Oct 17 11:46:22 2016 +0200
     5.3 @@ -767,8 +767,8 @@
     5.4      apply (subst B.emeasure_pair_measure_alt[OF X])
     5.5      apply (subst emeasure_count_space)
     5.6      apply (auto simp add: emeasure_count_space nn_integral_count_space
     5.7 -                          pos_card of_nat_setsum[symmetric] card_SigmaI[symmetric]
     5.8 -                simp del: of_nat_setsum card_SigmaI
     5.9 +                          pos_card of_nat_sum[symmetric] card_SigmaI[symmetric]
    5.10 +                simp del: of_nat_sum card_SigmaI
    5.11                  intro!: arg_cong[where f=card])
    5.12      done
    5.13  qed
     6.1 --- a/src/HOL/Analysis/Bochner_Integration.thy	Sun Oct 16 22:43:51 2016 +0200
     6.2 +++ b/src/HOL/Analysis/Bochner_Integration.thy	Mon Oct 17 11:46:22 2016 +0200
     6.3 @@ -157,10 +157,10 @@
     6.4  
     6.5  lemma
     6.6    fixes f :: "'a \<Rightarrow> 'b::semiring_1" assumes "finite A"
     6.7 -  shows setsum_mult_indicator[simp]: "(\<Sum>x \<in> A. f x * indicator (B x) (g x)) = (\<Sum>x\<in>{x\<in>A. g x \<in> B x}. f x)"
     6.8 -  and setsum_indicator_mult[simp]: "(\<Sum>x \<in> A. indicator (B x) (g x) * f x) = (\<Sum>x\<in>{x\<in>A. g x \<in> B x}. f x)"
     6.9 +  shows sum_mult_indicator[simp]: "(\<Sum>x \<in> A. f x * indicator (B x) (g x)) = (\<Sum>x\<in>{x\<in>A. g x \<in> B x}. f x)"
    6.10 +  and sum_indicator_mult[simp]: "(\<Sum>x \<in> A. indicator (B x) (g x) * f x) = (\<Sum>x\<in>{x\<in>A. g x \<in> B x}. f x)"
    6.11    unfolding indicator_def
    6.12 -  using assms by (auto intro!: setsum.mono_neutral_cong_right split: if_split_asm)
    6.13 +  using assms by (auto intro!: sum.mono_neutral_cong_right split: if_split_asm)
    6.14  
    6.15  lemma borel_measurable_induct_real[consumes 2, case_names set mult add seq]:
    6.16    fixes P :: "('a \<Rightarrow> real) \<Rightarrow> bool"
    6.17 @@ -220,8 +220,8 @@
    6.18      next
    6.19        case (insert x F)
    6.20        then show ?case
    6.21 -        by (auto intro!: add mult set setsum_nonneg split: split_indicator split_indicator_asm
    6.22 -                 simp del: setsum_mult_indicator simp: setsum_nonneg_eq_0_iff)
    6.23 +        by (auto intro!: add mult set sum_nonneg split: split_indicator split_indicator_asm
    6.24 +                 simp del: sum_mult_indicator simp: sum_nonneg_eq_0_iff)
    6.25      qed
    6.26      with U' show "P (U' i)" by simp
    6.27    qed
    6.28 @@ -337,7 +337,7 @@
    6.29      (\<Sum>y\<in>f`space M. (\<Sum>z\<in>g`space M.
    6.30        if \<exists>x\<in>space M. y = f x \<and> z = g x then measure M {x\<in>space M. g x = z} else 0) *\<^sub>R y)"
    6.31      unfolding simple_bochner_integral_def
    6.32 -  proof (safe intro!: setsum.cong scaleR_cong_right)
    6.33 +  proof (safe intro!: sum.cong scaleR_cong_right)
    6.34      fix y assume y: "y \<in> space M" "f y \<noteq> 0"
    6.35      have [simp]: "g ` space M \<inter> {z. \<exists>x\<in>space M. f y = f x \<and> z = g x} =
    6.36          {z. \<exists>x\<in>space M. f y = f x \<and> z = g x}"
    6.37 @@ -359,17 +359,17 @@
    6.38      ultimately
    6.39      show "measure M {x \<in> space M. f x = f y} =
    6.40        (\<Sum>z\<in>g ` space M. if \<exists>x\<in>space M. f y = f x \<and> z = g x then measure M {x \<in> space M. g x = z} else 0)"
    6.41 -      apply (simp add: setsum.If_cases eq)
    6.42 +      apply (simp add: sum.If_cases eq)
    6.43        apply (subst measure_finite_Union[symmetric])
    6.44        apply (auto simp: disjoint_family_on_def less_top)
    6.45        done
    6.46    qed
    6.47    also have "\<dots> = (\<Sum>y\<in>f`space M. (\<Sum>z\<in>g`space M.
    6.48        if \<exists>x\<in>space M. y = f x \<and> z = g x then measure M {x\<in>space M. g x = z} *\<^sub>R y else 0))"
    6.49 -    by (auto intro!: setsum.cong simp: scaleR_setsum_left)
    6.50 +    by (auto intro!: sum.cong simp: scaleR_sum_left)
    6.51    also have "\<dots> = ?r"
    6.52 -    by (subst setsum.commute)
    6.53 -       (auto intro!: setsum.cong simp: setsum.If_cases scaleR_setsum_right[symmetric] eq)
    6.54 +    by (subst sum.commute)
    6.55 +       (auto intro!: sum.cong simp: sum.If_cases scaleR_sum_right[symmetric] eq)
    6.56    finally show "simple_bochner_integral M f = ?r" .
    6.57  qed
    6.58  
    6.59 @@ -391,7 +391,7 @@
    6.60      by (intro simple_bochner_integral_partition)
    6.61         (auto simp: simple_bochner_integrable_compose2 elim: simple_bochner_integrable.cases)
    6.62    ultimately show ?thesis
    6.63 -    by (simp add: setsum.distrib[symmetric] scaleR_add_right)
    6.64 +    by (simp add: sum.distrib[symmetric] scaleR_add_right)
    6.65  qed
    6.66  
    6.67  lemma (in linear) simple_bochner_integral_linear:
    6.68 @@ -404,7 +404,7 @@
    6.69         (auto simp: simple_bochner_integrable_compose2[where p="\<lambda>x y. f x"] zero
    6.70               elim: simple_bochner_integrable.cases)
    6.71    also have "\<dots> = f (simple_bochner_integral M g)"
    6.72 -    by (simp add: simple_bochner_integral_def setsum scaleR)
    6.73 +    by (simp add: simple_bochner_integral_def sum scaleR)
    6.74    finally show ?thesis .
    6.75  qed
    6.76  
    6.77 @@ -431,7 +431,7 @@
    6.78  proof -
    6.79    have "norm (simple_bochner_integral M f) \<le>
    6.80      (\<Sum>y\<in>f ` space M. norm (measure M {x \<in> space M. f x = y} *\<^sub>R y))"
    6.81 -    unfolding simple_bochner_integral_def by (rule norm_setsum)
    6.82 +    unfolding simple_bochner_integral_def by (rule norm_sum)
    6.83    also have "\<dots> = (\<Sum>y\<in>f ` space M. measure M {x \<in> space M. f x = y} *\<^sub>R norm y)"
    6.84      by simp
    6.85    also have "\<dots> = simple_bochner_integral M (\<lambda>x. norm (f x))"
    6.86 @@ -444,7 +444,7 @@
    6.87  lemma simple_bochner_integral_nonneg[simp]:
    6.88    fixes f :: "'a \<Rightarrow> real"
    6.89    shows "(\<And>x. 0 \<le> f x) \<Longrightarrow> 0 \<le> simple_bochner_integral M f"
    6.90 -  by (simp add: setsum_nonneg simple_bochner_integral_def)
    6.91 +  by (simp add: sum_nonneg simple_bochner_integral_def)
    6.92  
    6.93  lemma simple_bochner_integral_eq_nn_integral:
    6.94    assumes f: "simple_bochner_integrable M f" "\<And>x. 0 \<le> f x"
    6.95 @@ -473,9 +473,9 @@
    6.96      unfolding simple_integral_def
    6.97      by (subst simple_bochner_integral_partition[OF f(1), where g="\<lambda>x. ennreal (f x)" and v=enn2real])
    6.98         (auto intro: f simple_function_compose1 elim: simple_bochner_integrable.cases
    6.99 -             intro!: setsum.cong ennreal_cong_mult
   6.100 -             simp: setsum_ennreal[symmetric] ac_simps ennreal_mult
   6.101 -             simp del: setsum_ennreal)
   6.102 +             intro!: sum.cong ennreal_cong_mult
   6.103 +             simp: sum_ennreal[symmetric] ac_simps ennreal_mult
   6.104 +             simp del: sum_ennreal)
   6.105    also have "\<dots> = (\<integral>\<^sup>+x. f x \<partial>M)"
   6.106      using f
   6.107      by (intro nn_integral_eq_simple_integral[symmetric])
   6.108 @@ -714,7 +714,7 @@
   6.109    unfolding diff_conv_add_uminus
   6.110    by (intro has_bochner_integral_add has_bochner_integral_minus)
   6.111  
   6.112 -lemma has_bochner_integral_setsum:
   6.113 +lemma has_bochner_integral_sum:
   6.114    "(\<And>i. i \<in> I \<Longrightarrow> has_bochner_integral M (f i) (x i)) \<Longrightarrow>
   6.115      has_bochner_integral M (\<lambda>x. \<Sum>i\<in>I. f i x) (\<Sum>i\<in>I. x i)"
   6.116    by (induct I rule: infinite_finite_induct) auto
   6.117 @@ -882,7 +882,7 @@
   6.118      by (auto simp: space_restrict_space measure_restrict_space[OF \<Omega>(1)] le_infI2
   6.119                     simple_bochner_integral_def Collect_restrict
   6.120               split: split_indicator split_indicator_asm
   6.121 -             intro!: setsum.mono_neutral_cong_left arg_cong2[where f=measure])
   6.122 +             intro!: sum.mono_neutral_cong_left arg_cong2[where f=measure])
   6.123  qed
   6.124  
   6.125  context
   6.126 @@ -971,8 +971,8 @@
   6.127  lemma integrable_zero[simp, intro]: "integrable M (\<lambda>x. 0)"
   6.128    by (metis has_bochner_integral_zero integrable.simps)
   6.129  
   6.130 -lemma integrable_setsum[simp, intro]: "(\<And>i. i \<in> I \<Longrightarrow> integrable M (f i)) \<Longrightarrow> integrable M (\<lambda>x. \<Sum>i\<in>I. f i x)"
   6.131 -  by (metis has_bochner_integral_setsum integrable.simps)
   6.132 +lemma integrable_sum[simp, intro]: "(\<And>i. i \<in> I \<Longrightarrow> integrable M (f i)) \<Longrightarrow> integrable M (\<lambda>x. \<Sum>i\<in>I. f i x)"
   6.133 +  by (metis has_bochner_integral_sum integrable.simps)
   6.134  
   6.135  lemma integrable_indicator[simp, intro]: "A \<in> sets M \<Longrightarrow> emeasure M A < \<infinity> \<Longrightarrow>
   6.136    integrable M (\<lambda>x. indicator A x *\<^sub>R c)"
   6.137 @@ -1045,13 +1045,13 @@
   6.138      integral\<^sup>L M (\<lambda>x. f x - g x) = integral\<^sup>L M f - integral\<^sup>L M g"
   6.139    by (intro has_bochner_integral_integral_eq has_bochner_integral_diff has_bochner_integral_integrable)
   6.140  
   6.141 -lemma integral_setsum: "(\<And>i. i \<in> I \<Longrightarrow> integrable M (f i)) \<Longrightarrow>
   6.142 +lemma integral_sum: "(\<And>i. i \<in> I \<Longrightarrow> integrable M (f i)) \<Longrightarrow>
   6.143    integral\<^sup>L M (\<lambda>x. \<Sum>i\<in>I. f i x) = (\<Sum>i\<in>I. integral\<^sup>L M (f i))"
   6.144 -  by (intro has_bochner_integral_integral_eq has_bochner_integral_setsum has_bochner_integral_integrable)
   6.145 -
   6.146 -lemma integral_setsum'[simp]: "(\<And>i. i \<in> I =simp=> integrable M (f i)) \<Longrightarrow>
   6.147 +  by (intro has_bochner_integral_integral_eq has_bochner_integral_sum has_bochner_integral_integrable)
   6.148 +
   6.149 +lemma integral_sum'[simp]: "(\<And>i. i \<in> I =simp=> integrable M (f i)) \<Longrightarrow>
   6.150    integral\<^sup>L M (\<lambda>x. \<Sum>i\<in>I. f i x) = (\<Sum>i\<in>I. integral\<^sup>L M (f i))"
   6.151 -  unfolding simp_implies_def by (rule integral_setsum)
   6.152 +  unfolding simp_implies_def by (rule integral_sum)
   6.153  
   6.154  lemma integral_bounded_linear: "bounded_linear T \<Longrightarrow> integrable M f \<Longrightarrow>
   6.155      integral\<^sup>L M (\<lambda>x. T (f x)) = T (integral\<^sup>L M f)"
   6.156 @@ -1729,9 +1729,9 @@
   6.157      using summable
   6.158    proof eventually_elim
   6.159      fix j x assume [simp]: "summable (\<lambda>i. norm (f i x))"
   6.160 -    have "norm (\<Sum>i<j. f i x) \<le> (\<Sum>i<j. norm (f i x))" by (rule norm_setsum)
   6.161 +    have "norm (\<Sum>i<j. f i x) \<le> (\<Sum>i<j. norm (f i x))" by (rule norm_sum)
   6.162      also have "\<dots> \<le> (\<Sum>i. norm (f i x))"
   6.163 -      using setsum_le_suminf[of "\<lambda>i. norm (f i x)"] unfolding sums_iff by auto
   6.164 +      using sum_le_suminf[of "\<lambda>i. norm (f i x)"] unfolding sums_iff by auto
   6.165      finally show "norm (\<Sum>i<j. f i x) \<le> (\<Sum>i. norm (f i x))" by simp
   6.166    qed
   6.167  
   6.168 @@ -1835,7 +1835,7 @@
   6.169      have "(\<And>i::'b. i \<in> A \<Longrightarrow> integrable M (f i::'a \<Rightarrow> 'b)) \<Longrightarrow>
   6.170      (\<And>i. i \<in> A \<Longrightarrow> P (f i)) \<Longrightarrow> P (\<lambda>x. \<Sum>i\<in>A. f i x)"
   6.171      by (induct A rule: infinite_finite_induct) (auto intro!: add) }
   6.172 -  note setsum = this
   6.173 +  note sum = this
   6.174  
   6.175    define s' where [abs_def]: "s' i z = indicator (space M) z *\<^sub>R s i z" for i z
   6.176    then have s'_eq_s: "\<And>i x. x \<in> space M \<Longrightarrow> s' i x = s i x"
   6.177 @@ -1873,7 +1873,7 @@
   6.178          using sbi by (auto elim: simple_bochner_integrable.cases simp: less_top)
   6.179        finally have "emeasure M {y \<in> space M. s' i y = s' i x} \<noteq> \<infinity>" by simp }
   6.180      then show "P (s' i)"
   6.181 -      by (subst s'_eq) (auto intro!: setsum base simp: less_top)
   6.182 +      by (subst s'_eq) (auto intro!: sum base simp: less_top)
   6.183  
   6.184      fix x assume "x \<in> space M" with s show "(\<lambda>i. s' i x) \<longlonglongrightarrow> f x"
   6.185        by (simp add: s'_eq_s)
   6.186 @@ -2191,19 +2191,19 @@
   6.187    shows "(\<integral>x. f x \<partial>count_space A) = (\<Sum>a | a \<in> A \<and> f a \<noteq> 0. f a)"
   6.188  proof -
   6.189    have eq: "\<And>x. x \<in> A \<Longrightarrow> (\<Sum>a | x = a \<and> a \<in> A \<and> f a \<noteq> 0. f a) = (\<Sum>x\<in>{x}. f x)"
   6.190 -    by (intro setsum.mono_neutral_cong_left) auto
   6.191 +    by (intro sum.mono_neutral_cong_left) auto
   6.192  
   6.193    have "(\<integral>x. f x \<partial>count_space A) = (\<integral>x. (\<Sum>a | a \<in> A \<and> f a \<noteq> 0. indicator {a} x *\<^sub>R f a) \<partial>count_space A)"
   6.194      by (intro integral_cong refl) (simp add: f eq)
   6.195    also have "\<dots> = (\<Sum>a | a \<in> A \<and> f a \<noteq> 0. measure (count_space A) {a} *\<^sub>R f a)"
   6.196 -    by (subst integral_setsum) (auto intro!: setsum.cong)
   6.197 +    by (subst integral_sum) (auto intro!: sum.cong)
   6.198    finally show ?thesis
   6.199      by auto
   6.200  qed
   6.201  
   6.202  lemma lebesgue_integral_count_space_finite: "finite A \<Longrightarrow> (\<integral>x. f x \<partial>count_space A) = (\<Sum>a\<in>A. f a)"
   6.203    by (subst lebesgue_integral_count_space_finite_support)
   6.204 -     (auto intro!: setsum.mono_neutral_cong_left)
   6.205 +     (auto intro!: sum.mono_neutral_cong_left)
   6.206  
   6.207  lemma integrable_count_space_nat_iff:
   6.208    fixes f :: "nat \<Rightarrow> _::{banach,second_countable_topology}"
   6.209 @@ -2491,7 +2491,7 @@
   6.210        by (auto split: split_indicator simp: eq_commute[of x] cong: conj_cong)
   6.211    qed
   6.212    also have "\<dots> = (\<Sum>a\<in>A. f a * measure M {a})"
   6.213 -    using finite by (subst integral_setsum) (auto simp add: integrable_mult_left_iff)
   6.214 +    using finite by (subst integral_sum) (auto simp add: integrable_mult_left_iff)
   6.215    finally show ?thesis .
   6.216  qed
   6.217  
   6.218 @@ -2645,7 +2645,7 @@
   6.219        (\<Sum>z\<in>s i ` (space N \<times> space M). measure M {y \<in> space M. s i (x, y) = z} *\<^sub>R z)"
   6.220        using s(1)[THEN simple_functionD(1)]
   6.221        unfolding simple_bochner_integral_def
   6.222 -      by (intro setsum.mono_neutral_cong_left)
   6.223 +      by (intro sum.mono_neutral_cong_left)
   6.224           (auto simp: eq_commute space_pair_measure image_iff cong: conj_cong) }
   6.225    note eq = this
   6.226  
     7.1 --- a/src/HOL/Analysis/Borel_Space.thy	Sun Oct 16 22:43:51 2016 +0200
     7.2 +++ b/src/HOL/Analysis/Borel_Space.thy	Mon Oct 17 11:46:22 2016 +0200
     7.3 @@ -969,7 +969,7 @@
     7.4    shows "(\<lambda>x. f x + g x) \<in> borel_measurable M"
     7.5    using f g by (rule borel_measurable_continuous_Pair) (intro continuous_intros)
     7.6  
     7.7 -lemma borel_measurable_setsum[measurable (raw)]:
     7.8 +lemma borel_measurable_sum[measurable (raw)]:
     7.9    fixes f :: "'c \<Rightarrow> 'a \<Rightarrow> 'b::{second_countable_topology, topological_comm_monoid_add}"
    7.10    assumes "\<And>i. i \<in> S \<Longrightarrow> f i \<in> borel_measurable M"
    7.11    shows "(\<lambda>x. \<Sum>i\<in>S. f i x) \<in> borel_measurable M"
    7.12 @@ -1646,7 +1646,7 @@
    7.13      and borel_measurable_ereal_divide: "(\<lambda>x. f x / g x) \<in> borel_measurable M"
    7.14    using assms by (simp_all add: minus_ereal_def divide_ereal_def)
    7.15  
    7.16 -lemma borel_measurable_ereal_setsum[measurable (raw)]:
    7.17 +lemma borel_measurable_ereal_sum[measurable (raw)]:
    7.18    fixes f :: "'c \<Rightarrow> 'a \<Rightarrow> ereal"
    7.19    assumes "\<And>i. i \<in> S \<Longrightarrow> f i \<in> borel_measurable M"
    7.20    shows "(\<lambda>x. \<Sum>i\<in>S. f i x) \<in> borel_measurable M"
     8.1 --- a/src/HOL/Analysis/Bounded_Continuous_Function.thy	Sun Oct 16 22:43:51 2016 +0200
     8.2 +++ b/src/HOL/Analysis/Bounded_Continuous_Function.thy	Mon Oct 17 11:46:22 2016 +0200
     8.3 @@ -426,7 +426,7 @@
     8.4      by (simp add: cbox_def)
     8.5    then have "(\<Sum>i\<in>Basis. (dist (clamp a b y \<bullet> i) (clamp a b x \<bullet> i))\<^sup>2) \<le>
     8.6      (\<Sum>i\<in>Basis. (dist (y \<bullet> i) (x \<bullet> i))\<^sup>2)"
     8.7 -    by (auto intro!: setsum_mono simp: clamp_def dist_real_def abs_le_square_iff[symmetric])
     8.8 +    by (auto intro!: sum_mono simp: clamp_def dist_real_def abs_le_square_iff[symmetric])
     8.9    then show ?thesis
    8.10      by (auto intro: real_sqrt_le_mono
    8.11        simp: euclidean_dist_l2[where y=x] euclidean_dist_l2[where y="clamp a b x"] setL2_def)
     9.1 --- a/src/HOL/Analysis/Bounded_Linear_Function.thy	Sun Oct 16 22:43:51 2016 +0200
     9.2 +++ b/src/HOL/Analysis/Bounded_Linear_Function.thy	Mon Oct 17 11:46:22 2016 +0200
     9.3 @@ -43,7 +43,7 @@
     9.4    bounded_linear_scaleR_const
     9.5    bounded_linear_const_scaleR
     9.6    bounded_linear_ident
     9.7 -  bounded_linear_setsum
     9.8 +  bounded_linear_sum
     9.9    bounded_linear_Pair
    9.10    bounded_linear_sub
    9.11    bounded_linear_fst_comp
    9.12 @@ -204,8 +204,8 @@
    9.13    scaleR_right
    9.14    zero_left
    9.15    zero_right
    9.16 -  setsum_left
    9.17 -  setsum_right
    9.18 +  sum_left
    9.19 +  sum_right
    9.20  
    9.21  end
    9.22  
    9.23 @@ -340,20 +340,20 @@
    9.24  
    9.25  subsection \<open>On Euclidean Space\<close>
    9.26  
    9.27 -lemma Zfun_setsum:
    9.28 +lemma Zfun_sum:
    9.29    assumes "finite s"
    9.30    assumes f: "\<And>i. i \<in> s \<Longrightarrow> Zfun (f i) F"
    9.31 -  shows "Zfun (\<lambda>x. setsum (\<lambda>i. f i x) s) F"
    9.32 +  shows "Zfun (\<lambda>x. sum (\<lambda>i. f i x) s) F"
    9.33    using assms by induct (auto intro!: Zfun_zero Zfun_add)
    9.34  
    9.35  lemma norm_blinfun_euclidean_le:
    9.36    fixes a::"'a::euclidean_space \<Rightarrow>\<^sub>L 'b::real_normed_vector"
    9.37 -  shows "norm a \<le> setsum (\<lambda>x. norm (a x)) Basis"
    9.38 +  shows "norm a \<le> sum (\<lambda>x. norm (a x)) Basis"
    9.39    apply (rule norm_blinfun_bound)
    9.40 -   apply (simp add: setsum_nonneg)
    9.41 +   apply (simp add: sum_nonneg)
    9.42    apply (subst euclidean_representation[symmetric, where 'a='a])
    9.43 -  apply (simp only: blinfun.bilinear_simps setsum_distrib_right)
    9.44 -  apply (rule order.trans[OF norm_setsum setsum_mono])
    9.45 +  apply (simp only: blinfun.bilinear_simps sum_distrib_right)
    9.46 +  apply (rule order.trans[OF norm_sum sum_mono])
    9.47    apply (simp add: abs_mult mult_right_mono ac_simps Basis_le_norm)
    9.48    done
    9.49  
    9.50 @@ -366,7 +366,7 @@
    9.51    have "\<And>j. j \<in> Basis \<Longrightarrow> Zfun (\<lambda>x. norm (b x j - a j)) F"
    9.52      using assms unfolding tendsto_Zfun_iff Zfun_norm_iff .
    9.53    hence "Zfun (\<lambda>x. \<Sum>j\<in>Basis. norm (b x j - a j)) F"
    9.54 -    by (auto intro!: Zfun_setsum)
    9.55 +    by (auto intro!: Zfun_sum)
    9.56    thus ?thesis
    9.57      unfolding tendsto_Zfun_iff
    9.58      by (rule Zfun_le)
    9.59 @@ -387,9 +387,9 @@
    9.60    have "(\<Sum>j\<in>Basis. \<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> j)) *\<^sub>R j) \<bullet> b
    9.61      = (\<Sum>j\<in>Basis. if j = b then (\<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> j))) else 0)"
    9.62      using b
    9.63 -    by (auto simp add: algebra_simps inner_setsum_left inner_Basis split: if_split intro!: setsum.cong)
    9.64 +    by (auto simp add: algebra_simps inner_sum_left inner_Basis split: if_split intro!: sum.cong)
    9.65    also have "\<dots> = (\<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> b)))"
    9.66 -    using b by (simp add: setsum.delta)
    9.67 +    using b by (simp add: sum.delta)
    9.68    also have "\<dots> = f x \<bullet> b"
    9.69      by (metis (mono_tags, lifting) Linear_Algebra.linear_componentwise linear_axioms)
    9.70    finally show "(\<Sum>j\<in>Basis. \<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> j)) *\<^sub>R j) \<bullet> b = f x \<bullet> b" .
    9.71 @@ -400,15 +400,15 @@
    9.72    by transfer simp
    9.73  
    9.74  lemma blinfun_of_matrix_minus: "blinfun_of_matrix x - blinfun_of_matrix y = blinfun_of_matrix (x - y)"
    9.75 -  by transfer (auto simp: algebra_simps setsum_subtractf)
    9.76 +  by transfer (auto simp: algebra_simps sum_subtractf)
    9.77  
    9.78  lemma norm_blinfun_of_matrix:
    9.79    "norm (blinfun_of_matrix a) \<le> (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. \<bar>a i j\<bar>)"
    9.80    apply (rule norm_blinfun_bound)
    9.81 -   apply (simp add: setsum_nonneg)
    9.82 -  apply (simp only: blinfun_of_matrix_apply setsum_distrib_right)
    9.83 -  apply (rule order_trans[OF norm_setsum setsum_mono])
    9.84 -  apply (rule order_trans[OF norm_setsum setsum_mono])
    9.85 +   apply (simp add: sum_nonneg)
    9.86 +  apply (simp only: blinfun_of_matrix_apply sum_distrib_right)
    9.87 +  apply (rule order_trans[OF norm_sum sum_mono])
    9.88 +  apply (rule order_trans[OF norm_sum sum_mono])
    9.89    apply (simp add: abs_mult mult_right_mono ac_simps Basis_le_norm)
    9.90    done
    9.91  
    9.92 @@ -419,7 +419,7 @@
    9.93    have "\<And>i j. i \<in> Basis \<Longrightarrow> j \<in> Basis \<Longrightarrow> Zfun (\<lambda>x. norm (b x i j - a i j)) F"
    9.94      using assms unfolding tendsto_Zfun_iff Zfun_norm_iff .
    9.95    hence "Zfun (\<lambda>x. (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. \<bar>b x i j - a i j\<bar>)) F"
    9.96 -    by (auto intro!: Zfun_setsum)
    9.97 +    by (auto intro!: Zfun_sum)
    9.98    thus ?thesis
    9.99      unfolding tendsto_Zfun_iff blinfun_of_matrix_minus
   9.100      by (rule Zfun_le) (auto intro!: order_trans[OF norm_blinfun_of_matrix])
   9.101 @@ -480,8 +480,8 @@
   9.102      subseq r \<and> (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) i) (l i) < e) sequentially)"
   9.103    by (rule compact_lemma_general[where unproj = "\<lambda>e. blinfun_of_matrix (\<lambda>i j. e j \<bullet> i)"])
   9.104     (auto intro!: euclidean_eqI[where 'a='b] bounded_linear_image assms
   9.105 -    simp: blinfun_of_matrix_works blinfun_of_matrix_apply inner_Basis mult_if_delta setsum.delta'
   9.106 -      scaleR_setsum_left[symmetric])
   9.107 +    simp: blinfun_of_matrix_works blinfun_of_matrix_apply inner_Basis mult_if_delta sum.delta'
   9.108 +      scaleR_sum_left[symmetric])
   9.109  
   9.110  lemma blinfun_euclidean_eqI: "(\<And>i. i \<in> Basis \<Longrightarrow> blinfun_apply x i = blinfun_apply y i) \<Longrightarrow> x = y"
   9.111    apply (auto intro!: blinfun_eqI)
   9.112 @@ -493,7 +493,7 @@
   9.113  lemma Blinfun_eq_matrix: "bounded_linear f \<Longrightarrow> Blinfun f = blinfun_of_matrix (\<lambda>i j. f j \<bullet> i)"
   9.114    by (intro blinfun_euclidean_eqI)
   9.115       (auto simp: blinfun_of_matrix_apply bounded_linear_Blinfun_apply inner_Basis if_distrib
   9.116 -      cond_application_beta setsum.delta' euclidean_representation
   9.117 +      cond_application_beta sum.delta' euclidean_representation
   9.118        cong: if_cong)
   9.119  
   9.120  text \<open>TODO: generalize (via @{thm compact_cball})?\<close>
   9.121 @@ -520,10 +520,10 @@
   9.122        also note norm_blinfun_of_matrix
   9.123        also have "(\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. \<bar>(f (r n) - l) j \<bullet> i\<bar>) <
   9.124          (\<Sum>i\<in>(Basis::'b set). e / real_of_nat DIM('b))"
   9.125 -      proof (rule setsum_strict_mono)
   9.126 +      proof (rule sum_strict_mono)
   9.127          fix i::'b assume i: "i \<in> Basis"
   9.128          have "(\<Sum>j::'a\<in>Basis. \<bar>(f (r n) - l) j \<bullet> i\<bar>) < (\<Sum>j::'a\<in>Basis. e / ?d)"
   9.129 -        proof (rule setsum_strict_mono)
   9.130 +        proof (rule sum_strict_mono)
   9.131            fix j::'a assume j: "j \<in> Basis"
   9.132            have "\<bar>(f (r n) - l) j \<bullet> i\<bar> \<le> norm ((f (r n) - l) j)"
   9.133              by (simp add: Basis_le_norm i)
    10.1 --- a/src/HOL/Analysis/Brouwer_Fixpoint.thy	Sun Oct 16 22:43:51 2016 +0200
    10.2 +++ b/src/HOL/Analysis/Brouwer_Fixpoint.thy	Mon Oct 17 11:46:22 2016 +0200
    10.3 @@ -52,13 +52,13 @@
    10.4  lemmas Zero_notin_Suc = zero_notin_Suc_image
    10.5  lemmas atMost_Suc_eq_insert_0 = Iic_Suc_eq_insert_0
    10.6  
    10.7 -lemma setsum_union_disjoint':
    10.8 +lemma sum_union_disjoint':
    10.9    assumes "finite A"
   10.10      and "finite B"
   10.11      and "A \<inter> B = {}"
   10.12      and "A \<union> B = C"
   10.13 -  shows "setsum g C = setsum g A + setsum g B"
   10.14 -  using setsum.union_disjoint[OF assms(1-3)] and assms(4) by auto
   10.15 +  shows "sum g C = sum g A + sum g B"
   10.16 +  using sum.union_disjoint[OF assms(1-3)] and assms(4) by auto
   10.17  
   10.18  lemma pointwise_minimal_pointwise_maximal:
   10.19    fixes s :: "(nat \<Rightarrow> nat) set"
   10.20 @@ -139,19 +139,19 @@
   10.21    shows "odd (card {s\<in>S. compo s})"
   10.22  proof -
   10.23    have "(\<Sum>s | s \<in> S \<and> \<not> compo s. nF s) + (\<Sum>s | s \<in> S \<and> compo s. nF s) = (\<Sum>s\<in>S. nF s)"
   10.24 -    by (subst setsum.union_disjoint[symmetric]) (auto intro!: setsum.cong)
   10.25 +    by (subst sum.union_disjoint[symmetric]) (auto intro!: sum.cong)
   10.26    also have "\<dots> = (\<Sum>s\<in>S. card {f \<in> {f\<in>F. compo' f \<and> bnd f}. face f s}) +
   10.27                    (\<Sum>s\<in>S. card {f \<in> {f\<in>F. compo' f \<and> \<not> bnd f}. face f s})"
   10.28 -    unfolding setsum.distrib[symmetric]
   10.29 +    unfolding sum.distrib[symmetric]
   10.30      by (subst card_Un_disjoint[symmetric])
   10.31 -       (auto simp: nF_def intro!: setsum.cong arg_cong[where f=card])
   10.32 +       (auto simp: nF_def intro!: sum.cong arg_cong[where f=card])
   10.33    also have "\<dots> = 1 * card {f\<in>F. compo' f \<and> bnd f} + 2 * card {f\<in>F. compo' f \<and> \<not> bnd f}"
   10.34 -    using assms(4,5) by (fastforce intro!: arg_cong2[where f="op +"] setsum_multicount)
   10.35 +    using assms(4,5) by (fastforce intro!: arg_cong2[where f="op +"] sum_multicount)
   10.36    finally have "odd ((\<Sum>s | s \<in> S \<and> \<not> compo s. nF s) + card {s\<in>S. compo s})"
   10.37      using assms(6,8) by simp
   10.38    moreover have "(\<Sum>s | s \<in> S \<and> \<not> compo s. nF s) =
   10.39      (\<Sum>s | s \<in> S \<and> \<not> compo s \<and> nF s = 0. nF s) + (\<Sum>s | s \<in> S \<and> \<not> compo s \<and> nF s = 2. nF s)"
   10.40 -    using assms(7) by (subst setsum.union_disjoint[symmetric]) (fastforce intro!: setsum.cong)+
   10.41 +    using assms(7) by (subst sum.union_disjoint[symmetric]) (fastforce intro!: sum.cong)+
   10.42    ultimately show ?thesis
   10.43      by auto
   10.44  qed
   10.45 @@ -1417,9 +1417,9 @@
   10.46    fix y :: 'a assume y: "y \<in> unit_cube"
   10.47    have "dist 0 y = norm y" by (rule dist_0_norm)
   10.48    also have "\<dots> = norm (\<Sum>i\<in>Basis. (y \<bullet> i) *\<^sub>R i)" unfolding euclidean_representation ..
   10.49 -  also have "\<dots> \<le> (\<Sum>i\<in>Basis. norm ((y \<bullet> i) *\<^sub>R i))" by (rule norm_setsum)
   10.50 +  also have "\<dots> \<le> (\<Sum>i\<in>Basis. norm ((y \<bullet> i) *\<^sub>R i))" by (rule norm_sum)
   10.51    also have "\<dots> \<le> (\<Sum>i::'a\<in>Basis. 1)"
   10.52 -    by (rule setsum_mono, simp add: y [unfolded mem_unit_cube])
   10.53 +    by (rule sum_mono, simp add: y [unfolded mem_unit_cube])
   10.54    finally show "dist 0 y \<le> (\<Sum>i::'a\<in>Basis. 1)" .
   10.55  qed
   10.56  
   10.57 @@ -1679,7 +1679,7 @@
   10.58        unfolding inner_diff_left[symmetric]
   10.59        by (rule norm_le_l1)
   10.60      also have "\<dots> < (\<Sum>(i::'a) \<in> Basis. d / real n)"
   10.61 -      apply (rule setsum_strict_mono)
   10.62 +      apply (rule sum_strict_mono)
   10.63        using as
   10.64        apply auto
   10.65        done
   10.66 @@ -1731,7 +1731,7 @@
   10.67      by auto
   10.68    {
   10.69      have "(\<Sum>i\<in>Basis. \<bar>real (r (b' i)) - real (q (b' i))\<bar>) \<le> (\<Sum>(i::'a)\<in>Basis. 1)"
   10.70 -      apply (rule setsum_mono)
   10.71 +      apply (rule sum_mono)
   10.72        using rs(1)[OF b'_im]
   10.73        apply (auto simp add:* field_simps simp del: of_nat_Suc)
   10.74        done
   10.75 @@ -1743,7 +1743,7 @@
   10.76    moreover
   10.77    {
   10.78      have "(\<Sum>i\<in>Basis. \<bar>real (s (b' i)) - real (q (b' i))\<bar>) \<le> (\<Sum>(i::'a)\<in>Basis. 1)"
   10.79 -      apply (rule setsum_mono)
   10.80 +      apply (rule sum_mono)
   10.81        using rs(2)[OF b'_im]
   10.82        apply (auto simp add:* field_simps simp del: of_nat_Suc)
   10.83        done
   10.84 @@ -1757,7 +1757,7 @@
   10.85      unfolding r'_def s'_def z_def
   10.86      using \<open>p > 0\<close>
   10.87      apply (rule_tac[!] le_less_trans[OF norm_le_l1])
   10.88 -    apply (auto simp add: field_simps setsum_divide_distrib[symmetric] inner_diff_left)
   10.89 +    apply (auto simp add: field_simps sum_divide_distrib[symmetric] inner_diff_left)
   10.90      done
   10.91    then have "\<bar>(f z - z) \<bullet> i\<bar> < d / real n"
   10.92      using rs(3) i
    11.1 --- a/src/HOL/Analysis/Caratheodory.thy	Sun Oct 16 22:43:51 2016 +0200
    11.2 +++ b/src/HOL/Analysis/Caratheodory.thy	Mon Oct 17 11:46:22 2016 +0200
    11.3 @@ -20,31 +20,31 @@
    11.4  proof -
    11.5    have g_def: "g = (\<lambda>m. (\<Sum>n. f (m,n)))"
    11.6      using assms by (simp add: fun_eq_iff)
    11.7 -  have reindex: "\<And>B. (\<Sum>x\<in>B. f (prod_decode x)) = setsum f (prod_decode ` B)"
    11.8 -    by (simp add: setsum.reindex[OF inj_prod_decode] comp_def)
    11.9 +  have reindex: "\<And>B. (\<Sum>x\<in>B. f (prod_decode x)) = sum f (prod_decode ` B)"
   11.10 +    by (simp add: sum.reindex[OF inj_prod_decode] comp_def)
   11.11    have "(SUP n. \<Sum>i<n. f (prod_decode i)) = (SUP p : UNIV \<times> UNIV. \<Sum>i<fst p. \<Sum>n<snd p. f (i, n))"
   11.12 -  proof (intro SUP_eq; clarsimp simp: setsum.cartesian_product reindex)
   11.13 +  proof (intro SUP_eq; clarsimp simp: sum.cartesian_product reindex)
   11.14      fix n
   11.15      let ?M = "\<lambda>f. Suc (Max (f ` prod_decode ` {..<n}))"
   11.16      { fix a b x assume "x < n" and [symmetric]: "(a, b) = prod_decode x"
   11.17        then have "a < ?M fst" "b < ?M snd"
   11.18          by (auto intro!: Max_ge le_imp_less_Suc image_eqI) }
   11.19 -    then have "setsum f (prod_decode ` {..<n}) \<le> setsum f ({..<?M fst} \<times> {..<?M snd})"
   11.20 -      by (auto intro!: setsum_mono3)
   11.21 -    then show "\<exists>a b. setsum f (prod_decode ` {..<n}) \<le> setsum f ({..<a} \<times> {..<b})" by auto
   11.22 +    then have "sum f (prod_decode ` {..<n}) \<le> sum f ({..<?M fst} \<times> {..<?M snd})"
   11.23 +      by (auto intro!: sum_mono3)
   11.24 +    then show "\<exists>a b. sum f (prod_decode ` {..<n}) \<le> sum f ({..<a} \<times> {..<b})" by auto
   11.25    next
   11.26      fix a b
   11.27      let ?M = "prod_decode ` {..<Suc (Max (prod_encode ` ({..<a} \<times> {..<b})))}"
   11.28      { fix a' b' assume "a' < a" "b' < b" then have "(a', b') \<in> ?M"
   11.29          by (auto intro!: Max_ge le_imp_less_Suc image_eqI[where x="prod_encode (a', b')"]) }
   11.30 -    then have "setsum f ({..<a} \<times> {..<b}) \<le> setsum f ?M"
   11.31 -      by (auto intro!: setsum_mono3)
   11.32 -    then show "\<exists>n. setsum f ({..<a} \<times> {..<b}) \<le> setsum f (prod_decode ` {..<n})"
   11.33 +    then have "sum f ({..<a} \<times> {..<b}) \<le> sum f ?M"
   11.34 +      by (auto intro!: sum_mono3)
   11.35 +    then show "\<exists>n. sum f ({..<a} \<times> {..<b}) \<le> sum f (prod_decode ` {..<n})"
   11.36        by auto
   11.37    qed
   11.38    also have "\<dots> = (SUP p. \<Sum>i<p. \<Sum>n. f (i, n))"
   11.39 -    unfolding suminf_setsum[OF summableI, symmetric]
   11.40 -    by (simp add: suminf_eq_SUP SUP_pair setsum.commute[of _ "{..< fst _}"])
   11.41 +    unfolding suminf_sum[OF summableI, symmetric]
   11.42 +    by (simp add: suminf_eq_SUP SUP_pair sum.commute[of _ "{..< fst _}"])
   11.43    finally show ?thesis unfolding g_def
   11.44      by (simp add: suminf_eq_SUP)
   11.45  qed
   11.46 @@ -529,7 +529,7 @@
   11.47    with \<open>volume M f\<close> have "f (\<Union>(A`I)) = (\<Sum>a\<in>A`I. f a)"
   11.48      unfolding volume_def by blast
   11.49    also have "\<dots> = (\<Sum>i\<in>I. f (A i))"
   11.50 -  proof (subst setsum.reindex_nontrivial)
   11.51 +  proof (subst sum.reindex_nontrivial)
   11.52      fix i j assume "i \<in> I" "j \<in> I" "i \<noteq> j" "A i = A j"
   11.53      with \<open>disjoint_family_on A I\<close> have "A i = {}"
   11.54        by (auto simp: disjoint_family_on_def)
   11.55 @@ -547,7 +547,7 @@
   11.56    shows "volume M \<mu>"
   11.57  proof (unfold volume_def, safe)
   11.58    fix C assume "finite C" "C \<subseteq> M" "disjoint C"
   11.59 -  then show "\<mu> (\<Union>C) = setsum \<mu> C"
   11.60 +  then show "\<mu> (\<Union>C) = sum \<mu> C"
   11.61    proof (induct C)
   11.62      case (insert c C)
   11.63      from insert(1,2,4,5) have "\<mu> (\<Union>insert c C) = \<mu> c + \<mu> (\<Union>C)"
   11.64 @@ -570,7 +570,7 @@
   11.65      fix D assume D: "D \<subseteq> M" "finite D" "disjoint D"
   11.66      assume "\<Union>C = \<Union>D"
   11.67      have "(\<Sum>d\<in>D. \<mu> d) = (\<Sum>d\<in>D. \<Sum>c\<in>C. \<mu> (c \<inter> d))"
   11.68 -    proof (intro setsum.cong refl)
   11.69 +    proof (intro sum.cong refl)
   11.70        fix d assume "d \<in> D"
   11.71        have Un_eq_d: "(\<Union>c\<in>C. c \<inter> d) = d"
   11.72          using \<open>d \<in> D\<close> \<open>\<Union>C = \<Union>D\<close> by auto
   11.73 @@ -592,7 +592,7 @@
   11.74      assume "\<Union>C = \<Union>D"
   11.75      with split_sum[OF C D] split_sum[OF D C]
   11.76      have "(\<Sum>d\<in>D. \<mu> d) = (\<Sum>c\<in>C. \<mu> c)"
   11.77 -      by (simp, subst setsum.commute, simp add: ac_simps) }
   11.78 +      by (simp, subst sum.commute, simp add: ac_simps) }
   11.79    note sum_eq = this
   11.80  
   11.81    { fix C assume C: "C \<subseteq> M" "finite C" "disjoint C"
   11.82 @@ -612,7 +612,7 @@
   11.83      fix a assume "a \<in> ?R" then guess Ca .. note Ca = this
   11.84      with \<mu>'[of Ca] \<open>volume M \<mu>\<close>[THEN volume_positive]
   11.85      show "0 \<le> \<mu>' a"
   11.86 -      by (auto intro!: setsum_nonneg)
   11.87 +      by (auto intro!: sum_nonneg)
   11.88    next
   11.89      show "\<mu>' {} = 0" using \<mu>'[of "{}"] by auto
   11.90    next
   11.91 @@ -627,7 +627,7 @@
   11.92      also have "\<dots> = (\<Sum>c\<in>Ca \<union> Cb. \<mu> c) + (\<Sum>c\<in>Ca \<inter> Cb. \<mu> c)"
   11.93        using C_Int_cases volume_empty[OF \<open>volume M \<mu>\<close>] by (elim disjE) simp_all
   11.94      also have "\<dots> = (\<Sum>c\<in>Ca. \<mu> c) + (\<Sum>c\<in>Cb. \<mu> c)"
   11.95 -      using Ca Cb by (simp add: setsum.union_inter)
   11.96 +      using Ca Cb by (simp add: sum.union_inter)
   11.97      also have "\<dots> = \<mu>' a + \<mu>' b"
   11.98        using Ca Cb by (simp add: \<mu>')
   11.99      finally show "\<mu>' (a \<union> b) = \<mu>' a + \<mu>' b"
  11.100 @@ -680,7 +680,7 @@
  11.101          by (simp add: sums_iff)
  11.102      qed
  11.103      also have "\<dots> = (\<Sum>c\<in>C. \<mu> c)"
  11.104 -      using F'(2) by (subst (2) F') (simp add: setsum.reindex)
  11.105 +      using F'(2) by (subst (2) F') (simp add: sum.reindex)
  11.106      finally show "\<mu> (\<Union>C) = (\<Sum>c\<in>C. \<mu> c)" .
  11.107    next
  11.108      show "\<mu> {} = 0"
  11.109 @@ -798,9 +798,9 @@
  11.110                 intro: generated_ringI_Basic)
  11.111      also have "\<dots> = (\<Sum>c\<in>C'. \<Sum>n. \<mu>_r (A' n \<inter> c))"
  11.112        using C' A'
  11.113 -      by (intro suminf_setsum G.Int G.finite_Union) (auto intro: generated_ringI_Basic)
  11.114 +      by (intro suminf_sum G.Int G.finite_Union) (auto intro: generated_ringI_Basic)
  11.115      also have "\<dots> = (\<Sum>c\<in>C'. \<mu>_r c)"
  11.116 -      using eq V C' by (auto intro!: setsum.cong)
  11.117 +      using eq V C' by (auto intro!: sum.cong)
  11.118      also have "\<dots> = \<mu>_r (\<Union>C')"
  11.119        using C' Un_A
  11.120        by (subst volume_finite_additive[symmetric, OF V(1)])
    12.1 --- a/src/HOL/Analysis/Cartesian_Euclidean_Space.thy	Sun Oct 16 22:43:51 2016 +0200
    12.2 +++ b/src/HOL/Analysis/Cartesian_Euclidean_Space.thy	Mon Oct 17 11:46:22 2016 +0200
    12.3 @@ -12,18 +12,18 @@
    12.4    by simp
    12.5  
    12.6  (*move up?*)
    12.7 -lemma setsum_UNIV_sum:
    12.8 +lemma sum_UNIV_sum:
    12.9    fixes g :: "'a::finite + 'b::finite \<Rightarrow> _"
   12.10    shows "(\<Sum>x\<in>UNIV. g x) = (\<Sum>x\<in>UNIV. g (Inl x)) + (\<Sum>x\<in>UNIV. g (Inr x))"
   12.11    apply (subst UNIV_Plus_UNIV [symmetric])
   12.12 -  apply (subst setsum.Plus)
   12.13 +  apply (subst sum.Plus)
   12.14    apply simp_all
   12.15    done
   12.16  
   12.17 -lemma setsum_mult_product:
   12.18 -  "setsum h {..<A * B :: nat} = (\<Sum>i\<in>{..<A}. \<Sum>j\<in>{..<B}. h (j + i * B))"
   12.19 -  unfolding setsum_nat_group[of h B A, unfolded atLeast0LessThan, symmetric]
   12.20 -proof (rule setsum.cong, simp, rule setsum.reindex_cong)
   12.21 +lemma sum_mult_product:
   12.22 +  "sum h {..<A * B :: nat} = (\<Sum>i\<in>{..<A}. \<Sum>j\<in>{..<B}. h (j + i * B))"
   12.23 +  unfolding sum_nat_group[of h B A, unfolded atLeast0LessThan, symmetric]
   12.24 +proof (rule sum.cong, simp, rule sum.reindex_cong)
   12.25    fix i
   12.26    show "inj_on (\<lambda>j. j + i * B) {..<B}" by (auto intro!: inj_onI)
   12.27    show "{i * B..<i * B + B} = (\<lambda>j. j + i * B) ` {..<B}"
   12.28 @@ -108,19 +108,19 @@
   12.29  
   12.30  subsection \<open>A naive proof procedure to lift really trivial arithmetic stuff from the basis of the vector space.\<close>
   12.31  
   12.32 -lemma setsum_cong_aux:
   12.33 -  "(\<And>x. x \<in> A \<Longrightarrow> f x = g x) \<Longrightarrow> setsum f A = setsum g A"
   12.34 -  by (auto intro: setsum.cong)
   12.35 +lemma sum_cong_aux:
   12.36 +  "(\<And>x. x \<in> A \<Longrightarrow> f x = g x) \<Longrightarrow> sum f A = sum g A"
   12.37 +  by (auto intro: sum.cong)
   12.38  
   12.39 -hide_fact (open) setsum_cong_aux
   12.40 +hide_fact (open) sum_cong_aux
   12.41  
   12.42  method_setup vector = \<open>
   12.43  let
   12.44    val ss1 =
   12.45      simpset_of (put_simpset HOL_basic_ss @{context}
   12.46 -      addsimps [@{thm setsum.distrib} RS sym,
   12.47 -      @{thm setsum_subtractf} RS sym, @{thm setsum_distrib_left},
   12.48 -      @{thm setsum_distrib_right}, @{thm setsum_negf} RS sym])
   12.49 +      addsimps [@{thm sum.distrib} RS sym,
   12.50 +      @{thm sum_subtractf} RS sym, @{thm sum_distrib_left},
   12.51 +      @{thm sum_distrib_right}, @{thm sum_negf} RS sym])
   12.52    val ss2 =
   12.53      simpset_of (@{context} addsimps
   12.54               [@{thm plus_vec_def}, @{thm times_vec_def},
   12.55 @@ -130,8 +130,8 @@
   12.56                @{thm vec_lambda_beta}, @{thm vector_scalar_mult_def}])
   12.57    fun vector_arith_tac ctxt ths =
   12.58      simp_tac (put_simpset ss1 ctxt)
   12.59 -    THEN' (fn i => resolve_tac ctxt @{thms Cartesian_Euclidean_Space.setsum_cong_aux} i
   12.60 -         ORELSE resolve_tac ctxt @{thms setsum.neutral} i
   12.61 +    THEN' (fn i => resolve_tac ctxt @{thms Cartesian_Euclidean_Space.sum_cong_aux} i
   12.62 +         ORELSE resolve_tac ctxt @{thms sum.neutral} i
   12.63           ORELSE simp_tac (put_simpset HOL_basic_ss ctxt addsimps [@{thm vec_eq_iff}]) i)
   12.64      (* THEN' TRY o clarify_tac HOL_cs  THEN' (TRY o rtac @{thm iffI}) *)
   12.65      THEN' asm_full_simp_tac (put_simpset ss2 ctxt addsimps ths)
   12.66 @@ -152,9 +152,9 @@
   12.67  lemma vec_cmul: "vec(c * x) = c *s vec x " by vector
   12.68  lemma vec_neg: "vec(- x) = - vec x " by vector
   12.69  
   12.70 -lemma vec_setsum:
   12.71 +lemma vec_sum:
   12.72    assumes "finite S"
   12.73 -  shows "vec(setsum f S) = setsum (vec \<circ> f) S"
   12.74 +  shows "vec(sum f S) = sum (vec \<circ> f) S"
   12.75    using assms
   12.76  proof induct
   12.77    case empty
   12.78 @@ -299,8 +299,8 @@
   12.79  lemma norm_bound_component_lt_cart: "norm x < e ==> \<bar>x$i\<bar> < e"
   12.80    by (metis component_le_norm_cart le_less_trans)
   12.81  
   12.82 -lemma norm_le_l1_cart: "norm x <= setsum(\<lambda>i. \<bar>x$i\<bar>) UNIV"
   12.83 -  by (simp add: norm_vec_def setL2_le_setsum)
   12.84 +lemma norm_le_l1_cart: "norm x <= sum(\<lambda>i. \<bar>x$i\<bar>) UNIV"
   12.85 +  by (simp add: norm_vec_def setL2_le_sum)
   12.86  
   12.87  lemma scalar_mult_eq_scaleR: "c *s x = c *\<^sub>R x"
   12.88    unfolding scaleR_vec_def vector_scalar_mult_def by simp
   12.89 @@ -309,9 +309,9 @@
   12.90    unfolding dist_norm scalar_mult_eq_scaleR
   12.91    unfolding scaleR_right_diff_distrib[symmetric] by simp
   12.92  
   12.93 -lemma setsum_component [simp]:
   12.94 +lemma sum_component [simp]:
   12.95    fixes f:: " 'a \<Rightarrow> ('b::comm_monoid_add) ^'n"
   12.96 -  shows "(setsum f S)$i = setsum (\<lambda>x. (f x)$i) S"
   12.97 +  shows "(sum f S)$i = sum (\<lambda>x. (f x)$i) S"
   12.98  proof (cases "finite S")
   12.99    case True
  12.100    then show ?thesis by induct simp_all
  12.101 @@ -320,19 +320,19 @@
  12.102    then show ?thesis by simp
  12.103  qed
  12.104  
  12.105 -lemma setsum_eq: "setsum f S = (\<chi> i. setsum (\<lambda>x. (f x)$i ) S)"
  12.106 +lemma sum_eq: "sum f S = (\<chi> i. sum (\<lambda>x. (f x)$i ) S)"
  12.107    by (simp add: vec_eq_iff)
  12.108  
  12.109 -lemma setsum_cmul:
  12.110 +lemma sum_cmul:
  12.111    fixes f:: "'c \<Rightarrow> ('a::semiring_1)^'n"
  12.112 -  shows "setsum (\<lambda>x. c *s f x) S = c *s setsum f S"
  12.113 -  by (simp add: vec_eq_iff setsum_distrib_left)
  12.114 +  shows "sum (\<lambda>x. c *s f x) S = c *s sum f S"
  12.115 +  by (simp add: vec_eq_iff sum_distrib_left)
  12.116  
  12.117 -lemma setsum_norm_allsubsets_bound_cart:
  12.118 +lemma sum_norm_allsubsets_bound_cart:
  12.119    fixes f:: "'a \<Rightarrow> real ^'n"
  12.120 -  assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e"
  12.121 -  shows "setsum (\<lambda>x. norm (f x)) P \<le> 2 * real CARD('n) *  e"
  12.122 -  using setsum_norm_allsubsets_bound[OF assms]
  12.123 +  assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (sum f Q) \<le> e"
  12.124 +  shows "sum (\<lambda>x. norm (f x)) P \<le> 2 * real CARD('n) *  e"
  12.125 +  using sum_norm_allsubsets_bound[OF assms]
  12.126    by simp
  12.127  
  12.128  subsection\<open>Closures and interiors of halfspaces\<close>
  12.129 @@ -475,15 +475,15 @@
  12.130  
  12.131  definition matrix_matrix_mult :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'p^'n \<Rightarrow> 'a ^ 'p ^'m"
  12.132      (infixl "**" 70)
  12.133 -  where "m ** m' == (\<chi> i j. setsum (\<lambda>k. ((m$i)$k) * ((m'$k)$j)) (UNIV :: 'n set)) ::'a ^ 'p ^'m"
  12.134 +  where "m ** m' == (\<chi> i j. sum (\<lambda>k. ((m$i)$k) * ((m'$k)$j)) (UNIV :: 'n set)) ::'a ^ 'p ^'m"
  12.135  
  12.136  definition matrix_vector_mult :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n \<Rightarrow> 'a ^ 'm"
  12.137      (infixl "*v" 70)
  12.138 -  where "m *v x \<equiv> (\<chi> i. setsum (\<lambda>j. ((m$i)$j) * (x$j)) (UNIV ::'n set)) :: 'a^'m"
  12.139 +  where "m *v x \<equiv> (\<chi> i. sum (\<lambda>j. ((m$i)$j) * (x$j)) (UNIV ::'n set)) :: 'a^'m"
  12.140  
  12.141  definition vector_matrix_mult :: "'a ^ 'm \<Rightarrow> ('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n "
  12.142      (infixl "v*" 70)
  12.143 -  where "v v* m == (\<chi> j. setsum (\<lambda>i. ((m$i)$j) * (v$i)) (UNIV :: 'm set)) :: 'a^'n"
  12.144 +  where "v v* m == (\<chi> j. sum (\<lambda>i. ((m$i)$j) * (v$i)) (UNIV :: 'm set)) :: 'a^'n"
  12.145  
  12.146  definition "(mat::'a::zero => 'a ^'n^'n) k = (\<chi> i j. if i = j then k else 0)"
  12.147  definition transpose where
  12.148 @@ -495,14 +495,14 @@
  12.149  
  12.150  lemma mat_0[simp]: "mat 0 = 0" by (vector mat_def)
  12.151  lemma matrix_add_ldistrib: "(A ** (B + C)) = (A ** B) + (A ** C)"
  12.152 -  by (vector matrix_matrix_mult_def setsum.distrib[symmetric] field_simps)
  12.153 +  by (vector matrix_matrix_mult_def sum.distrib[symmetric] field_simps)
  12.154  
  12.155  lemma matrix_mul_lid:
  12.156    fixes A :: "'a::semiring_1 ^ 'm ^ 'n"
  12.157    shows "mat 1 ** A = A"
  12.158    apply (simp add: matrix_matrix_mult_def mat_def)
  12.159    apply vector
  12.160 -  apply (auto simp only: if_distrib cond_application_beta setsum.delta'[OF finite]
  12.161 +  apply (auto simp only: if_distrib cond_application_beta sum.delta'[OF finite]
  12.162      mult_1_left mult_zero_left if_True UNIV_I)
  12.163    done
  12.164  
  12.165 @@ -512,26 +512,26 @@
  12.166    shows "A ** mat 1 = A"
  12.167    apply (simp add: matrix_matrix_mult_def mat_def)
  12.168    apply vector
  12.169 -  apply (auto simp only: if_distrib cond_application_beta setsum.delta[OF finite]
  12.170 +  apply (auto simp only: if_distrib cond_application_beta sum.delta[OF finite]
  12.171      mult_1_right mult_zero_right if_True UNIV_I cong: if_cong)
  12.172    done
  12.173  
  12.174  lemma matrix_mul_assoc: "A ** (B ** C) = (A ** B) ** C"
  12.175 -  apply (vector matrix_matrix_mult_def setsum_distrib_left setsum_distrib_right mult.assoc)
  12.176 -  apply (subst setsum.commute)
  12.177 +  apply (vector matrix_matrix_mult_def sum_distrib_left sum_distrib_right mult.assoc)
  12.178 +  apply (subst sum.commute)
  12.179    apply simp
  12.180    done
  12.181  
  12.182  lemma matrix_vector_mul_assoc: "A *v (B *v x) = (A ** B) *v x"
  12.183    apply (vector matrix_matrix_mult_def matrix_vector_mult_def
  12.184 -    setsum_distrib_left setsum_distrib_right mult.assoc)
  12.185 -  apply (subst setsum.commute)
  12.186 +    sum_distrib_left sum_distrib_right mult.assoc)
  12.187 +  apply (subst sum.commute)
  12.188    apply simp
  12.189    done
  12.190  
  12.191  lemma matrix_vector_mul_lid: "mat 1 *v x = (x::'a::semiring_1 ^ 'n)"
  12.192    apply (vector matrix_vector_mult_def mat_def)
  12.193 -  apply (simp add: if_distrib cond_application_beta setsum.delta' cong del: if_weak_cong)
  12.194 +  apply (simp add: if_distrib cond_application_beta sum.delta' cong del: if_weak_cong)
  12.195    done
  12.196  
  12.197  lemma matrix_transpose_mul:
  12.198 @@ -548,15 +548,15 @@
  12.199    apply (erule_tac x="axis ia 1" in allE)
  12.200    apply (erule_tac x="i" in allE)
  12.201    apply (auto simp add: if_distrib cond_application_beta axis_def
  12.202 -    setsum.delta[OF finite] cong del: if_weak_cong)
  12.203 +    sum.delta[OF finite] cong del: if_weak_cong)
  12.204    done
  12.205  
  12.206  lemma matrix_vector_mul_component: "((A::real^_^_) *v x)$k = (A$k) \<bullet> x"
  12.207    by (simp add: matrix_vector_mult_def inner_vec_def)
  12.208  
  12.209  lemma dot_lmul_matrix: "((x::real ^_) v* A) \<bullet> y = x \<bullet> (A *v y)"
  12.210 -  apply (simp add: inner_vec_def matrix_vector_mult_def vector_matrix_mult_def setsum_distrib_right setsum_distrib_left ac_simps)
  12.211 -  apply (subst setsum.commute)
  12.212 +  apply (simp add: inner_vec_def matrix_vector_mult_def vector_matrix_mult_def sum_distrib_right sum_distrib_left ac_simps)
  12.213 +  apply (subst sum.commute)
  12.214    apply simp
  12.215    done
  12.216  
  12.217 @@ -588,27 +588,27 @@
  12.218    by (simp add: matrix_vector_mult_def inner_vec_def)
  12.219  
  12.220  lemma matrix_mult_vsum:
  12.221 -  "(A::'a::comm_semiring_1^'n^'m) *v x = setsum (\<lambda>i. (x$i) *s column i A) (UNIV:: 'n set)"
  12.222 +  "(A::'a::comm_semiring_1^'n^'m) *v x = sum (\<lambda>i. (x$i) *s column i A) (UNIV:: 'n set)"
  12.223    by (simp add: matrix_vector_mult_def vec_eq_iff column_def mult.commute)
  12.224  
  12.225  lemma vector_componentwise:
  12.226    "(x::'a::ring_1^'n) = (\<chi> j. \<Sum>i\<in>UNIV. (x$i) * (axis i 1 :: 'a^'n) $ j)"
  12.227 -  by (simp add: axis_def if_distrib setsum.If_cases vec_eq_iff)
  12.228 +  by (simp add: axis_def if_distrib sum.If_cases vec_eq_iff)
  12.229  
  12.230 -lemma basis_expansion: "setsum (\<lambda>i. (x$i) *s axis i 1) UNIV = (x::('a::ring_1) ^'n)"
  12.231 -  by (auto simp add: axis_def vec_eq_iff if_distrib setsum.If_cases cong del: if_weak_cong)
  12.232 +lemma basis_expansion: "sum (\<lambda>i. (x$i) *s axis i 1) UNIV = (x::('a::ring_1) ^'n)"
  12.233 +  by (auto simp add: axis_def vec_eq_iff if_distrib sum.If_cases cong del: if_weak_cong)
  12.234  
  12.235  lemma linear_componentwise_expansion:
  12.236    fixes f:: "real ^'m \<Rightarrow> real ^ _"
  12.237    assumes lf: "linear f"
  12.238 -  shows "(f x)$j = setsum (\<lambda>i. (x$i) * (f (axis i 1)$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs")
  12.239 +  shows "(f x)$j = sum (\<lambda>i. (x$i) * (f (axis i 1)$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs")
  12.240  proof -
  12.241    let ?M = "(UNIV :: 'm set)"
  12.242    let ?N = "(UNIV :: 'n set)"
  12.243 -  have "?rhs = (setsum (\<lambda>i.(x$i) *\<^sub>R f (axis i 1) ) ?M)$j"
  12.244 -    unfolding setsum_component by simp
  12.245 +  have "?rhs = (sum (\<lambda>i.(x$i) *\<^sub>R f (axis i 1) ) ?M)$j"
  12.246 +    unfolding sum_component by simp
  12.247    then show ?thesis
  12.248 -    unfolding linear_setsum_mul[OF lf, symmetric]
  12.249 +    unfolding linear_sum_mul[OF lf, symmetric]
  12.250      unfolding scalar_mult_eq_scaleR[symmetric]
  12.251      unfolding basis_expansion
  12.252      by simp
  12.253 @@ -630,7 +630,7 @@
  12.254  
  12.255  lemma matrix_vector_mul_linear: "linear(\<lambda>x. A *v (x::real ^ _))"
  12.256    by (simp add: linear_iff matrix_vector_mult_def vec_eq_iff
  12.257 -      field_simps setsum_distrib_left setsum.distrib)
  12.258 +      field_simps sum_distrib_left sum.distrib)
  12.259  
  12.260  lemma matrix_works:
  12.261    assumes lf: "linear f"
  12.262 @@ -652,14 +652,14 @@
  12.263    by (simp add: matrix_eq matrix_works matrix_vector_mul_assoc[symmetric] o_def)
  12.264  
  12.265  lemma matrix_vector_column:
  12.266 -  "(A::'a::comm_semiring_1^'n^_) *v x = setsum (\<lambda>i. (x$i) *s ((transpose A)$i)) (UNIV:: 'n set)"
  12.267 +  "(A::'a::comm_semiring_1^'n^_) *v x = sum (\<lambda>i. (x$i) *s ((transpose A)$i)) (UNIV:: 'n set)"
  12.268    by (simp add: matrix_vector_mult_def transpose_def vec_eq_iff mult.commute)
  12.269  
  12.270  lemma adjoint_matrix: "adjoint(\<lambda>x. (A::real^'n^'m) *v x) = (\<lambda>x. transpose A *v x)"
  12.271    apply (rule adjoint_unique)
  12.272    apply (simp add: transpose_def inner_vec_def matrix_vector_mult_def
  12.273 -    setsum_distrib_right setsum_distrib_left)
  12.274 -  apply (subst setsum.commute)
  12.275 +    sum_distrib_right sum_distrib_left)
  12.276 +  apply (subst sum.commute)
  12.277    apply (auto simp add: ac_simps)
  12.278    done
  12.279  
  12.280 @@ -758,13 +758,13 @@
  12.281  lemma matrix_left_invertible_independent_columns:
  12.282    fixes A :: "real^'n^'m"
  12.283    shows "(\<exists>(B::real ^'m^'n). B ** A = mat 1) \<longleftrightarrow>
  12.284 -      (\<forall>c. setsum (\<lambda>i. c i *s column i A) (UNIV :: 'n set) = 0 \<longrightarrow> (\<forall>i. c i = 0))"
  12.285 +      (\<forall>c. sum (\<lambda>i. c i *s column i A) (UNIV :: 'n set) = 0 \<longrightarrow> (\<forall>i. c i = 0))"
  12.286      (is "?lhs \<longleftrightarrow> ?rhs")
  12.287  proof -
  12.288    let ?U = "UNIV :: 'n set"
  12.289    { assume k: "\<forall>x. A *v x = 0 \<longrightarrow> x = 0"
  12.290      { fix c i
  12.291 -      assume c: "setsum (\<lambda>i. c i *s column i A) ?U = 0" and i: "i \<in> ?U"
  12.292 +      assume c: "sum (\<lambda>i. c i *s column i A) ?U = 0" and i: "i \<in> ?U"
  12.293        let ?x = "\<chi> i. c i"
  12.294        have th0:"A *v ?x = 0"
  12.295          using c
  12.296 @@ -786,7 +786,7 @@
  12.297  lemma matrix_right_invertible_independent_rows:
  12.298    fixes A :: "real^'n^'m"
  12.299    shows "(\<exists>(B::real^'m^'n). A ** B = mat 1) \<longleftrightarrow>
  12.300 -    (\<forall>c. setsum (\<lambda>i. c i *s row i A) (UNIV :: 'm set) = 0 \<longrightarrow> (\<forall>i. c i = 0))"
  12.301 +    (\<forall>c. sum (\<lambda>i. c i *s row i A) (UNIV :: 'm set) = 0 \<longrightarrow> (\<forall>i. c i = 0))"
  12.302    unfolding left_invertible_transpose[symmetric]
  12.303      matrix_left_invertible_independent_columns
  12.304    by (simp add: column_transpose)
  12.305 @@ -797,7 +797,7 @@
  12.306  proof -
  12.307    let ?U = "UNIV :: 'm set"
  12.308    have fU: "finite ?U" by simp
  12.309 -  have lhseq: "?lhs \<longleftrightarrow> (\<forall>y. \<exists>(x::real^'m). setsum (\<lambda>i. (x$i) *s column i A) ?U = y)"
  12.310 +  have lhseq: "?lhs \<longleftrightarrow> (\<forall>y. \<exists>(x::real^'m). sum (\<lambda>i. (x$i) *s column i A) ?U = y)"
  12.311      unfolding matrix_right_invertible_surjective matrix_mult_vsum surj_def
  12.312      apply (subst eq_commute)
  12.313      apply rule
  12.314 @@ -806,10 +806,10 @@
  12.315    { assume h: ?lhs
  12.316      { fix x:: "real ^'n"
  12.317        from h[unfolded lhseq, rule_format, of x] obtain y :: "real ^'m"
  12.318 -        where y: "setsum (\<lambda>i. (y$i) *s column i A) ?U = x" by blast
  12.319 +        where y: "sum (\<lambda>i. (y$i) *s column i A) ?U = x" by blast
  12.320        have "x \<in> span (columns A)"
  12.321          unfolding y[symmetric]
  12.322 -        apply (rule span_setsum)
  12.323 +        apply (rule span_sum)
  12.324          unfolding scalar_mult_eq_scaleR
  12.325          apply (rule span_mul)
  12.326          apply (rule span_superset)
  12.327 @@ -820,11 +820,11 @@
  12.328      then have ?rhs unfolding rhseq by blast }
  12.329    moreover
  12.330    { assume h:?rhs
  12.331 -    let ?P = "\<lambda>(y::real ^'n). \<exists>(x::real^'m). setsum (\<lambda>i. (x$i) *s column i A) ?U = y"
  12.332 +    let ?P = "\<lambda>(y::real ^'n). \<exists>(x::real^'m). sum (\<lambda>i. (x$i) *s column i A) ?U = y"
  12.333      { fix y
  12.334        have "?P y"
  12.335        proof (rule span_induct_alt[of ?P "columns A", folded scalar_mult_eq_scaleR])
  12.336 -        show "\<exists>x::real ^ 'm. setsum (\<lambda>i. (x$i) *s column i A) ?U = 0"
  12.337 +        show "\<exists>x::real ^ 'm. sum (\<lambda>i. (x$i) *s column i A) ?U = 0"
  12.338            by (rule exI[where x=0], simp)
  12.339        next
  12.340          fix c y1 y2
  12.341 @@ -832,7 +832,7 @@
  12.342          from y1 obtain i where i: "i \<in> ?U" "y1 = column i A"
  12.343            unfolding columns_def by blast
  12.344          from y2 obtain x:: "real ^'m" where
  12.345 -          x: "setsum (\<lambda>i. (x$i) *s column i A) ?U = y2" by blast
  12.346 +          x: "sum (\<lambda>i. (x$i) *s column i A) ?U = y2" by blast
  12.347          let ?x = "(\<chi> j. if j = i then c + (x$i) else (x$j))::real^'m"
  12.348          show "?P (c*s y1 + y2)"
  12.349          proof (rule exI[where x= "?x"], vector, auto simp add: i x[symmetric] if_distrib distrib_left cond_application_beta cong del: if_weak_cong)
  12.350 @@ -840,18 +840,18 @@
  12.351            have th: "\<forall>xa \<in> ?U. (if xa = i then (c + (x$i)) * ((column xa A)$j)
  12.352                else (x$xa) * ((column xa A$j))) = (if xa = i then c * ((column i A)$j) else 0) + ((x$xa) * ((column xa A)$j))"
  12.353              using i(1) by (simp add: field_simps)
  12.354 -          have "setsum (\<lambda>xa. if xa = i then (c + (x$i)) * ((column xa A)$j)
  12.355 -              else (x$xa) * ((column xa A$j))) ?U = setsum (\<lambda>xa. (if xa = i then c * ((column i A)$j) else 0) + ((x$xa) * ((column xa A)$j))) ?U"
  12.356 -            apply (rule setsum.cong[OF refl])
  12.357 +          have "sum (\<lambda>xa. if xa = i then (c + (x$i)) * ((column xa A)$j)
  12.358 +              else (x$xa) * ((column xa A$j))) ?U = sum (\<lambda>xa. (if xa = i then c * ((column i A)$j) else 0) + ((x$xa) * ((column xa A)$j))) ?U"
  12.359 +            apply (rule sum.cong[OF refl])
  12.360              using th apply blast
  12.361              done
  12.362 -          also have "\<dots> = setsum (\<lambda>xa. if xa = i then c * ((column i A)$j) else 0) ?U + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U"
  12.363 -            by (simp add: setsum.distrib)
  12.364 -          also have "\<dots> = c * ((column i A)$j) + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U"
  12.365 -            unfolding setsum.delta[OF fU]
  12.366 +          also have "\<dots> = sum (\<lambda>xa. if xa = i then c * ((column i A)$j) else 0) ?U + sum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U"
  12.367 +            by (simp add: sum.distrib)
  12.368 +          also have "\<dots> = c * ((column i A)$j) + sum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U"
  12.369 +            unfolding sum.delta[OF fU]
  12.370              using i(1) by simp
  12.371 -          finally show "setsum (\<lambda>xa. if xa = i then (c + (x$i)) * ((column xa A)$j)
  12.372 -            else (x$xa) * ((column xa A$j))) ?U = c * ((column i A)$j) + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U" .
  12.373 +          finally show "sum (\<lambda>xa. if xa = i then (c + (x$i)) * ((column xa A)$j)
  12.374 +            else (x$xa) * ((column xa A$j))) ?U = c * ((column i A)$j) + sum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U" .
  12.375          qed
  12.376        next
  12.377          show "y \<in> span (columns A)"
  12.378 @@ -984,9 +984,9 @@
  12.379      { fix n
  12.380        assume n: "\<forall>i. dist (f (r n) $ i) (l $ i) < e / (real_of_nat (card ?d))"
  12.381        have "dist (f (r n)) l \<le> (\<Sum>i\<in>?d. dist (f (r n) $ i) (l $ i))"
  12.382 -        unfolding dist_vec_def using zero_le_dist by (rule setL2_le_setsum)
  12.383 +        unfolding dist_vec_def using zero_le_dist by (rule setL2_le_sum)
  12.384        also have "\<dots> < (\<Sum>i\<in>?d. e / (real_of_nat (card ?d)))"
  12.385 -        by (rule setsum_strict_mono) (simp_all add: n)
  12.386 +        by (rule sum_strict_mono) (simp_all add: n)
  12.387        finally have "dist (f (r n)) l < e" by simp
  12.388      }
  12.389      ultimately have "eventually (\<lambda>n. dist (f (r n)) l < e) sequentially"
  12.390 @@ -1235,7 +1235,7 @@
  12.391      where "finite s" "cbox (x - (\<chi> i. d)) (x + (\<chi> i. d)) = convex hull s"
  12.392  proof -
  12.393    from assms obtain s where "finite s"
  12.394 -    and "cbox (x - setsum (op *\<^sub>R d) Basis) (x + setsum (op *\<^sub>R d) Basis) = convex hull s"
  12.395 +    and "cbox (x - sum (op *\<^sub>R d) Basis) (x + sum (op *\<^sub>R d) Basis) = convex hull s"
  12.396      by (rule cube_convex_hull)
  12.397    with that[of s] show thesis
  12.398      by (simp add: const_vector_cart)
  12.399 @@ -1314,13 +1314,13 @@
  12.400  lemma UNIV_3: "UNIV = {1::3, 2::3, 3::3}"
  12.401    using exhaust_3 by auto
  12.402  
  12.403 -lemma setsum_1: "setsum f (UNIV::1 set) = f 1"
  12.404 +lemma sum_1: "sum f (UNIV::1 set) = f 1"
  12.405    unfolding UNIV_1 by simp
  12.406  
  12.407 -lemma setsum_2: "setsum f (UNIV::2 set) = f 1 + f 2"
  12.408 +lemma sum_2: "sum f (UNIV::2 set) = f 1 + f 2"
  12.409    unfolding UNIV_2 by simp
  12.410  
  12.411 -lemma setsum_3: "setsum f (UNIV::3 set) = f 1 + f 2 + f 3"
  12.412 +lemma sum_3: "sum f (UNIV::3 set) = f 1 + f 2 + f 3"
  12.413    unfolding UNIV_3 by (simp add: ac_simps)
  12.414  
  12.415  instantiation num1 :: cart_one
    13.1 --- a/src/HOL/Analysis/Cauchy_Integral_Theorem.thy	Sun Oct 16 22:43:51 2016 +0200
    13.2 +++ b/src/HOL/Analysis/Cauchy_Integral_Theorem.thy	Mon Oct 17 11:46:22 2016 +0200
    13.3 @@ -1551,9 +1551,9 @@
    13.4      "(\<And>z. z \<in> path_image g \<Longrightarrow> f z = 0) \<Longrightarrow> (f has_contour_integral 0) g"
    13.5    by (rule has_contour_integral_eq [OF has_contour_integral_0]) auto
    13.6  
    13.7 -lemma has_contour_integral_setsum:
    13.8 +lemma has_contour_integral_sum:
    13.9      "\<lbrakk>finite s; \<And>a. a \<in> s \<Longrightarrow> (f a has_contour_integral i a) p\<rbrakk>
   13.10 -     \<Longrightarrow> ((\<lambda>x. setsum (\<lambda>a. f a x) s) has_contour_integral setsum i s) p"
   13.11 +     \<Longrightarrow> ((\<lambda>x. sum (\<lambda>a. f a x) s) has_contour_integral sum i s) p"
   13.12    by (induction s rule: finite_induct) (auto simp: has_contour_integral_0 has_contour_integral_add)
   13.13  
   13.14  
   13.15 @@ -1613,10 +1613,10 @@
   13.16  lemma contour_integral_0 [simp]: "contour_integral g (\<lambda>x. 0) = 0"
   13.17    by (simp add: contour_integral_unique has_contour_integral_0)
   13.18  
   13.19 -lemma contour_integral_setsum:
   13.20 +lemma contour_integral_sum:
   13.21      "\<lbrakk>finite s; \<And>a. a \<in> s \<Longrightarrow> (f a) contour_integrable_on p\<rbrakk>
   13.22 -     \<Longrightarrow> contour_integral p (\<lambda>x. setsum (\<lambda>a. f a x) s) = setsum (\<lambda>a. contour_integral p (f a)) s"
   13.23 -  by (auto simp: contour_integral_unique has_contour_integral_setsum has_contour_integral_integral)
   13.24 +     \<Longrightarrow> contour_integral p (\<lambda>x. sum (\<lambda>a. f a x) s) = sum (\<lambda>a. contour_integral p (f a)) s"
   13.25 +  by (auto simp: contour_integral_unique has_contour_integral_sum has_contour_integral_integral)
   13.26  
   13.27  lemma contour_integrable_eq:
   13.28      "\<lbrakk>f contour_integrable_on p; \<And>x. x \<in> path_image p \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> g contour_integrable_on p"
   13.29 @@ -1655,11 +1655,11 @@
   13.30    using has_contour_integral_div contour_integrable_on_def
   13.31    by fastforce
   13.32  
   13.33 -lemma contour_integrable_setsum:
   13.34 +lemma contour_integrable_sum:
   13.35      "\<lbrakk>finite s; \<And>a. a \<in> s \<Longrightarrow> (f a) contour_integrable_on p\<rbrakk>
   13.36 -     \<Longrightarrow> (\<lambda>x. setsum (\<lambda>a. f a x) s) contour_integrable_on p"
   13.37 +     \<Longrightarrow> (\<lambda>x. sum (\<lambda>a. f a x) s) contour_integrable_on p"
   13.38     unfolding contour_integrable_on_def
   13.39 -   by (metis has_contour_integral_setsum)
   13.40 +   by (metis has_contour_integral_sum)
   13.41  
   13.42  
   13.43  subsection\<open>Reversing a path integral\<close>
   13.44 @@ -5919,9 +5919,9 @@
   13.45    have sumeq: "(\<Sum>i = 0..n.
   13.46                 of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z + deriv ((deriv ^^ (n - i)) g) z * (deriv ^^ i) f z)) =
   13.47              g z * deriv ((deriv ^^ n) f) z + (\<Sum>i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))"
   13.48 -    apply (simp add: bb algebra_simps setsum.distrib)
   13.49 -    apply (subst (4) setsum_Suc_reindex)
   13.50 -    apply (auto simp: algebra_simps Suc_diff_le intro: setsum.cong)
   13.51 +    apply (simp add: bb algebra_simps sum.distrib)
   13.52 +    apply (subst (4) sum_Suc_reindex)
   13.53 +    apply (auto simp: algebra_simps Suc_diff_le intro: sum.cong)
   13.54      done
   13.55    show ?case
   13.56      apply (simp only: funpow.simps o_apply)
   13.57 @@ -5929,7 +5929,7 @@
   13.58      apply (rule DERIV_transform_within_open
   13.59               [of "\<lambda>w. (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f w * (deriv ^^ (n - i)) g w)"])
   13.60      apply (simp add: algebra_simps)
   13.61 -    apply (rule DERIV_cong [OF DERIV_setsum])
   13.62 +    apply (rule DERIV_cong [OF DERIV_sum])
   13.63      apply (rule DERIV_cmult)
   13.64      apply (auto simp: intro: DERIV_mult * sumeq \<open>open s\<close> Suc.prems Suc.IH [symmetric])
   13.65      done
   13.66 @@ -6210,7 +6210,7 @@
   13.67          by (metis (no_types) dist_norm divide_eq_1_iff less_irrefl mem_ball norm_minus_commute r w)
   13.68        have "norm ((\<Sum>k<N. (w - z) ^ k * f u / (u - z) ^ Suc k) * (u - w) - f u)
   13.69              = norm ((\<Sum>k<N. (((w - z) / (u - z)) ^ k)) * f u * (u - w) / (u - z) - f u)"
   13.70 -        unfolding setsum_distrib_right setsum_divide_distrib power_divide by (simp add: algebra_simps)
   13.71 +        unfolding sum_distrib_right sum_divide_distrib power_divide by (simp add: algebra_simps)
   13.72        also have "... = norm ((((w - z) / (u - z)) ^ N - 1) * (u - w) / (((w - z) / (u - z) - 1) * (u - z)) - 1) * norm (f u)"
   13.73          using \<open>0 < B\<close>
   13.74          apply (auto simp: geometric_sum [OF wzu_not1])
   13.75 @@ -6242,7 +6242,7 @@
   13.76               contour_integral (circlepath z r) (\<lambda>u. \<Sum>k<x. (w - z) ^ k * (f u / (u - z) ^ Suc k)) =
   13.77               (\<Sum>k<x. contour_integral (circlepath z r) (\<lambda>u. f u / (u - z) ^ Suc k) * (w - z) ^ k)"
   13.78      apply (rule eventuallyI)
   13.79 -    apply (subst contour_integral_setsum, simp)
   13.80 +    apply (subst contour_integral_sum, simp)
   13.81      using contour_integrable_lmul [OF cint, of "(w - z) ^ a" for a] apply (simp add: field_simps)
   13.82      apply (simp only: contour_integral_lmul cint algebra_simps)
   13.83      done
   13.84 @@ -6251,7 +6251,7 @@
   13.85      unfolding sums_def
   13.86      apply (rule Lim_transform_eventually [OF eq])
   13.87      apply (rule contour_integral_uniform_limit_circlepath [OF eventuallyI *])
   13.88 -    apply (rule contour_integrable_setsum, simp)
   13.89 +    apply (rule contour_integrable_sum, simp)
   13.90      apply (rule contour_integrable_lmul)
   13.91      apply (rule Cauchy_higher_derivative_integral_circlepath [OF contf holf])
   13.92      using \<open>0 < r\<close>
   13.93 @@ -6589,7 +6589,7 @@
   13.94    have "(\<forall>x\<in>s. (\<lambda>n. \<Sum>i<n. f i x) \<longlonglongrightarrow> g x)"
   13.95      using g by (force simp add: lim_sequentially)
   13.96    moreover have "\<exists>g'. \<forall>x\<in>s. (g has_field_derivative g' x) (at x) \<and> (\<lambda>n. \<Sum>i<n. f' i x) \<longlonglongrightarrow> g' x"
   13.97 -    by (rule has_complex_derivative_uniform_sequence [OF s]) (auto intro: * hfd DERIV_setsum)+
   13.98 +    by (rule has_complex_derivative_uniform_sequence [OF s]) (auto intro: * hfd DERIV_sum)+
   13.99    ultimately show ?thesis
  13.100      by (force simp add: sums_def  conj_commute intro: that)
  13.101  qed
    14.1 --- a/src/HOL/Analysis/Complex_Analysis_Basics.thy	Sun Oct 16 22:43:51 2016 +0200
    14.2 +++ b/src/HOL/Analysis/Complex_Analysis_Basics.thy	Mon Oct 17 11:46:22 2016 +0200
    14.3 @@ -269,7 +269,7 @@
    14.4    fixes l::complex
    14.5    shows "f sums l \<Longrightarrow> (\<And>n. f n \<in> \<real>) \<Longrightarrow> l \<in> \<real>"
    14.6  unfolding sums_def
    14.7 -by (metis real_lim_sequentially setsum_in_Reals)
    14.8 +by (metis real_lim_sequentially sum_in_Reals)
    14.9  
   14.10  lemma Lim_null_comparison_Re:
   14.11    assumes "eventually (\<lambda>x. norm(f x) \<le> Re(g x)) F" "(g \<longlongrightarrow> 0) F" shows "(f \<longlongrightarrow> 0) F"
   14.12 @@ -335,7 +335,7 @@
   14.13       "op + c field_differentiable F"
   14.14    by (simp add: field_differentiable_add)
   14.15  
   14.16 -lemma field_differentiable_setsum [derivative_intros]:
   14.17 +lemma field_differentiable_sum [derivative_intros]:
   14.18    "(\<And>i. i \<in> I \<Longrightarrow> (f i) field_differentiable F) \<Longrightarrow> (\<lambda>z. \<Sum>i\<in>I. f i z) field_differentiable F"
   14.19    by (induct I rule: infinite_finite_induct)
   14.20       (auto intro: field_differentiable_add field_differentiable_const)
   14.21 @@ -502,9 +502,9 @@
   14.22    "f holomorphic_on s \<Longrightarrow> (\<lambda>z. (f z)^n) holomorphic_on s"
   14.23    unfolding holomorphic_on_def by (metis field_differentiable_power)
   14.24  
   14.25 -lemma holomorphic_on_setsum [holomorphic_intros]:
   14.26 -  "(\<And>i. i \<in> I \<Longrightarrow> (f i) holomorphic_on s) \<Longrightarrow> (\<lambda>x. setsum (\<lambda>i. f i x) I) holomorphic_on s"
   14.27 -  unfolding holomorphic_on_def by (metis field_differentiable_setsum)
   14.28 +lemma holomorphic_on_sum [holomorphic_intros]:
   14.29 +  "(\<And>i. i \<in> I \<Longrightarrow> (f i) holomorphic_on s) \<Longrightarrow> (\<lambda>x. sum (\<lambda>i. f i x) I) holomorphic_on s"
   14.30 +  unfolding holomorphic_on_def by (metis field_differentiable_sum)
   14.31  
   14.32  lemma DERIV_deriv_iff_field_differentiable:
   14.33    "DERIV f x :> deriv f x \<longleftrightarrow> f field_differentiable at x"
   14.34 @@ -788,8 +788,8 @@
   14.35    "f analytic_on s \<Longrightarrow> (\<lambda>z. (f z) ^ n) analytic_on s"
   14.36  by (induct n) (auto simp: analytic_on_const analytic_on_mult)
   14.37  
   14.38 -lemma analytic_on_setsum:
   14.39 -  "(\<And>i. i \<in> I \<Longrightarrow> (f i) analytic_on s) \<Longrightarrow> (\<lambda>x. setsum (\<lambda>i. f i x) I) analytic_on s"
   14.40 +lemma analytic_on_sum:
   14.41 +  "(\<And>i. i \<in> I \<Longrightarrow> (f i) analytic_on s) \<Longrightarrow> (\<lambda>x. sum (\<lambda>i. f i x) I) analytic_on s"
   14.42    by (induct I rule: infinite_finite_induct) (auto simp: analytic_on_const analytic_on_add)
   14.43  
   14.44  lemma deriv_left_inverse:
   14.45 @@ -951,7 +951,7 @@
   14.46        then have "cmod h * cmod ((\<Sum>i<n. f' i y) - g' y) \<le> cmod h * e"
   14.47          by (auto simp: antisym_conv2 mult_le_cancel_left norm_triangle_ineq2)
   14.48        then show "cmod ((\<Sum>i<n. h * f' i y) - g' y * h) \<le> e * cmod h"
   14.49 -        by (simp add: norm_mult [symmetric] field_simps setsum_distrib_left)
   14.50 +        by (simp add: norm_mult [symmetric] field_simps sum_distrib_left)
   14.51      qed
   14.52    } note ** = this
   14.53    show ?thesis
   14.54 @@ -1064,9 +1064,9 @@
   14.55  
   14.56  subsection \<open>Taylor on Complex Numbers\<close>
   14.57  
   14.58 -lemma setsum_Suc_reindex:
   14.59 +lemma sum_Suc_reindex:
   14.60    fixes f :: "nat \<Rightarrow> 'a::ab_group_add"
   14.61 -    shows  "setsum f {0..n} = f 0 - f (Suc n) + setsum (\<lambda>i. f (Suc i)) {0..n}"
   14.62 +    shows  "sum f {0..n} = f 0 - f (Suc n) + sum (\<lambda>i. f (Suc i)) {0..n}"
   14.63  by (induct n) auto
   14.64  
   14.65  lemma complex_taylor:
   14.66 @@ -1146,7 +1146,7 @@
   14.67    have "(\<Sum>i\<le>n. f i z * (z - z) ^ i / (fact i)) = (\<Sum>i\<le>n. (f i z / (fact i)) * 0 ^ i)"
   14.68      by simp
   14.69    also have "\<dots> = f 0 z / (fact 0)"
   14.70 -    by (subst setsum_zero_power) simp
   14.71 +    by (subst sum_zero_power) simp
   14.72    finally have "cmod (f 0 z - (\<Sum>i\<le>n. f i w * (z - w) ^ i / (fact i)))
   14.73                  \<le> cmod ((\<Sum>i\<le>n. f i w * (z - w) ^ i / (fact i)) -
   14.74                          (\<Sum>i\<le>n. f i z * (z - z) ^ i / (fact i)))"
   14.75 @@ -1203,7 +1203,7 @@
   14.76               (\<Sum>i = 0..n.
   14.77                   (f (Suc (Suc i)) u * ((z-u) ^ Suc i) - of_nat (Suc i) * (f (Suc i) u * (z-u) ^ i)) /
   14.78                   (fact (Suc i)))"
   14.79 -       by (subst setsum_Suc_reindex) simp
   14.80 +       by (subst sum_Suc_reindex) simp
   14.81      also have "... = f (Suc 0) u -
   14.82               (f (Suc (Suc n)) u * ((z-u) ^ Suc n) - (of_nat (Suc n)) * (z-u) ^ n * f (Suc n) u) /
   14.83               (fact (Suc n)) +
   14.84 @@ -1215,7 +1215,7 @@
   14.85               (f (Suc (Suc n)) u * (z-u) ^ Suc n - of_nat (Suc n) * (z-u) ^ n * f (Suc n) u) /
   14.86               (fact (Suc n)) +
   14.87               f (Suc (Suc n)) u * (z-u) ^ Suc n / (fact (Suc n)) - f (Suc 0) u"
   14.88 -      by (subst setsum_Suc_diff) auto
   14.89 +      by (subst sum_Suc_diff) auto
   14.90      also have "... = f (Suc n) u * (z-u) ^ n / (fact n)"
   14.91        by (simp only: algebra_simps diff_divide_distrib fact_cancel)
   14.92      finally have "(\<Sum>i = 0..n. (f (Suc i) u * (z - u) ^ i
    15.1 --- a/src/HOL/Analysis/Complex_Transcendental.thy	Sun Oct 16 22:43:51 2016 +0200
    15.2 +++ b/src/HOL/Analysis/Complex_Transcendental.thy	Mon Oct 17 11:46:22 2016 +0200
    15.3 @@ -597,7 +597,7 @@
    15.4  text\<open>32-bit Approximation to e\<close>
    15.5  lemma e_approx_32: "\<bar>exp(1) - 5837465777 / 2147483648\<bar> \<le> (inverse(2 ^ 32)::real)"
    15.6    using Taylor_exp [of 1 14] exp_le
    15.7 -  apply (simp add: setsum_distrib_right in_Reals_norm Re_exp atMost_nat_numeral fact_numeral)
    15.8 +  apply (simp add: sum_distrib_right in_Reals_norm Re_exp atMost_nat_numeral fact_numeral)
    15.9    apply (simp only: pos_le_divide_eq [symmetric], linarith)
   15.10    done
   15.11  
    16.1 --- a/src/HOL/Analysis/Conformal_Mappings.thy	Sun Oct 16 22:43:51 2016 +0200
    16.2 +++ b/src/HOL/Analysis/Conformal_Mappings.thy	Mon Oct 17 11:46:22 2016 +0200
    16.3 @@ -612,7 +612,7 @@
    16.4      have "powf sums f w"
    16.5        unfolding powf_def by (rule holomorphic_power_series [OF holfb w])
    16.6      moreover have "(\<Sum>i<n. powf i) = f \<xi>"
    16.7 -      apply (subst Groups_Big.comm_monoid_add_class.setsum.setdiff_irrelevant [symmetric])
    16.8 +      apply (subst Groups_Big.comm_monoid_add_class.sum.setdiff_irrelevant [symmetric])
    16.9        apply (simp add:)
   16.10        apply (simp only: dfz sing)
   16.11        apply (simp add: powf_def)
   16.12 @@ -1052,7 +1052,7 @@
   16.13    proof (cases "\<forall>i\<le>n. 0<i \<longrightarrow> a i = 0")
   16.14      case True
   16.15      then have [simp]: "\<And>z. f z = a 0"
   16.16 -      by (simp add: that setsum_atMost_shift)
   16.17 +      by (simp add: that sum_atMost_shift)
   16.18      have False using compf [of "{a 0}"] by simp
   16.19      then show ?thesis ..
   16.20    next
   16.21 @@ -1073,7 +1073,7 @@
   16.22        using k apply auto
   16.23        done
   16.24      with k m show ?thesis
   16.25 -      by (rule_tac x=m in exI) (auto simp: that comm_monoid_add_class.setsum.mono_neutral_right)
   16.26 +      by (rule_tac x=m in exI) (auto simp: that comm_monoid_add_class.sum.mono_neutral_right)
   16.27    qed
   16.28    have "((inverse \<circ> f) \<longlongrightarrow> 0) at_infinity"
   16.29    proof (rule Lim_at_infinityI)
   16.30 @@ -2758,9 +2758,9 @@
   16.31        finally show ?thesis .
   16.32      qed
   16.33    ultimately show ?case unfolding p_circ_def
   16.34 -    apply (subst (asm) setsum.cong[OF refl,
   16.35 +    apply (subst (asm) sum.cong[OF refl,
   16.36          of pts _ "\<lambda>p. winding_number g p * contour_integral (circlepath p (h p)) f"])
   16.37 -    by (auto simp add:setsum.insert[OF \<open>finite pts\<close> \<open>p\<notin>pts\<close>] algebra_simps)
   16.38 +    by (auto simp add:sum.insert[OF \<open>finite pts\<close> \<open>p\<notin>pts\<close>] algebra_simps)
   16.39  qed
   16.40  
   16.41  lemma Cauchy_theorem_singularities:
   16.42 @@ -2791,17 +2791,17 @@
   16.43        show "\<forall>p\<in>s. 0 < h p \<and> (\<forall>w\<in>cball p (h p). w \<in> s \<and> (w \<noteq> p \<longrightarrow> w \<notin> pts1))"
   16.44          by (simp add: avoid pts1_def)
   16.45      qed
   16.46 -  moreover have "setsum circ pts2=0"
   16.47 +  moreover have "sum circ pts2=0"
   16.48      proof -
   16.49        have "winding_number g p=0" when "p\<in>pts2" for p
   16.50          using  \<open>pts2 \<inter> s={}\<close> that homo[rule_format,of p] by auto
   16.51        thus ?thesis unfolding circ_def
   16.52 -        apply (intro setsum.neutral)
   16.53 +        apply (intro sum.neutral)
   16.54          by auto
   16.55      qed
   16.56 -  moreover have "?R=setsum circ pts1 + setsum circ pts2"
   16.57 +  moreover have "?R=sum circ pts1 + sum circ pts2"
   16.58      unfolding circ_def
   16.59 -    using setsum.union_disjoint[OF _ _ \<open>pts1 \<inter> pts2 = {}\<close>] \<open>finite pts\<close> \<open>pts=pts1 \<union> pts2\<close>
   16.60 +    using sum.union_disjoint[OF _ _ \<open>pts1 \<inter> pts2 = {}\<close>] \<open>finite pts\<close> \<open>pts=pts1 \<union> pts2\<close>
   16.61      by blast
   16.62    ultimately show ?thesis
   16.63      apply (fold circ_def)
   16.64 @@ -2826,7 +2826,7 @@
   16.65        = (\<Sum>p\<in>pts. winding_number g p * contour_integral (circlepath p (h p)) f)"
   16.66      using Cauchy_theorem_singularities[OF assms avoid] .
   16.67    also have "... = (\<Sum>p\<in>pts.  c * winding_number g p * residue f p)"
   16.68 -    proof (intro setsum.cong)
   16.69 +    proof (intro sum.cong)
   16.70        show "pts = pts" by simp
   16.71      next
   16.72        fix x assume "x \<in> pts"
   16.73 @@ -2846,7 +2846,7 @@
   16.74          qed
   16.75      qed
   16.76    also have "... = c * (\<Sum>p\<in>pts. winding_number g p * residue f p)"
   16.77 -    by (simp add: setsum_distrib_left algebra_simps)
   16.78 +    by (simp add: sum_distrib_left algebra_simps)
   16.79    finally show ?thesis unfolding c_def .
   16.80  qed
   16.81  
   16.82 @@ -3437,12 +3437,12 @@
   16.83      qed
   16.84    also have "... = (\<Sum>p\<in>zeros. w p * cont p) + (\<Sum>p\<in>poles. w p * cont p)"
   16.85      using finite
   16.86 -    apply (subst setsum.union_disjoint)
   16.87 +    apply (subst sum.union_disjoint)
   16.88      by (auto simp add:zeros_def)
   16.89    also have "... = c * ((\<Sum>p\<in>zeros. w p *  h p * zorder f p) - (\<Sum>p\<in>poles. w p *  h p * porder f p))"
   16.90      proof -
   16.91        have "(\<Sum>p\<in>zeros. w p * cont p) = (\<Sum>p\<in>zeros. c * w p *  h p * zorder f p)"
   16.92 -        proof (rule setsum.cong[of zeros zeros,simplified])
   16.93 +        proof (rule sum.cong[of zeros zeros,simplified])
   16.94            fix p assume "p \<in> zeros"
   16.95            show "w p * cont p = c * w p * h p * (zorder f p)"
   16.96              proof (cases "p\<in>s")
   16.97 @@ -3459,10 +3459,10 @@
   16.98              qed
   16.99          qed
  16.100        then have "(\<Sum>p\<in>zeros. w p * cont p) = c * (\<Sum>p\<in>zeros.  w p *  h p * zorder f p)"
  16.101 -        apply (subst setsum_distrib_left)
  16.102 +        apply (subst sum_distrib_left)
  16.103          by (simp add:algebra_simps)
  16.104        moreover have "(\<Sum>p\<in>poles. w p * cont p) = (\<Sum>p\<in>poles.  - c * w p *  h p * porder f p)"
  16.105 -        proof (rule setsum.cong[of poles poles,simplified])
  16.106 +        proof (rule sum.cong[of poles poles,simplified])
  16.107            fix p assume "p \<in> poles"
  16.108            show "w p * cont p = - c * w p * h p * (porder f p)"
  16.109              proof (cases "p\<in>s")
  16.110 @@ -3479,7 +3479,7 @@
  16.111              qed
  16.112          qed
  16.113        then have "(\<Sum>p\<in>poles. w p * cont p) = - c * (\<Sum>p\<in>poles. w p *  h p * porder f p)"
  16.114 -        apply (subst setsum_distrib_left)
  16.115 +        apply (subst sum_distrib_left)
  16.116          by (simp add:algebra_simps)
  16.117        ultimately show ?thesis by (simp add: right_diff_distrib)
  16.118      qed
    17.1 --- a/src/HOL/Analysis/Continuous_Extension.thy	Sun Oct 16 22:43:51 2016 +0200
    17.2 +++ b/src/HOL/Analysis/Continuous_Extension.thy	Mon Oct 17 11:46:22 2016 +0200
    17.3 @@ -20,19 +20,19 @@
    17.4    obtains F :: "['a set, 'a] \<Rightarrow> real"
    17.5      where "\<And>U. U \<in> \<C> \<Longrightarrow> continuous_on S (F U) \<and> (\<forall>x \<in> S. 0 \<le> F U x)"
    17.6        and "\<And>x U. \<lbrakk>U \<in> \<C>; x \<in> S; x \<notin> U\<rbrakk> \<Longrightarrow> F U x = 0"
    17.7 -      and "\<And>x. x \<in> S \<Longrightarrow> supp_setsum (\<lambda>W. F W x) \<C> = 1"
    17.8 +      and "\<And>x. x \<in> S \<Longrightarrow> supp_sum (\<lambda>W. F W x) \<C> = 1"
    17.9        and "\<And>x. x \<in> S \<Longrightarrow> \<exists>V. open V \<and> x \<in> V \<and> finite {U \<in> \<C>. \<exists>x\<in>V. F U x \<noteq> 0}"
   17.10  proof (cases "\<exists>W. W \<in> \<C> \<and> S \<subseteq> W")
   17.11    case True
   17.12      then obtain W where "W \<in> \<C>" "S \<subseteq> W" by metis
   17.13      then show ?thesis
   17.14        apply (rule_tac F = "\<lambda>V x. if V = W then 1 else 0" in that)
   17.15 -      apply (auto simp: continuous_on_const supp_setsum_def support_on_def)
   17.16 +      apply (auto simp: continuous_on_const supp_sum_def support_on_def)
   17.17        done
   17.18  next
   17.19    case False
   17.20 -    have nonneg: "0 \<le> supp_setsum (\<lambda>V. setdist {x} (S - V)) \<C>" for x
   17.21 -      by (simp add: supp_setsum_def setsum_nonneg)
   17.22 +    have nonneg: "0 \<le> supp_sum (\<lambda>V. setdist {x} (S - V)) \<C>" for x
   17.23 +      by (simp add: supp_sum_def sum_nonneg)
   17.24      have sd_pos: "0 < setdist {x} (S - V)" if "V \<in> \<C>" "x \<in> S" "x \<in> V" for V x
   17.25      proof -
   17.26        have "closedin (subtopology euclidean S) (S - V)"
   17.27 @@ -41,7 +41,7 @@
   17.28          show ?thesis
   17.29            by (simp add: order_class.order.order_iff_strict)
   17.30      qed
   17.31 -    have ss_pos: "0 < supp_setsum (\<lambda>V. setdist {x} (S - V)) \<C>" if "x \<in> S" for x
   17.32 +    have ss_pos: "0 < supp_sum (\<lambda>V. setdist {x} (S - V)) \<C>" if "x \<in> S" for x
   17.33      proof -
   17.34        obtain U where "U \<in> \<C>" "x \<in> U" using \<open>x \<in> S\<close> \<open>S \<subseteq> \<Union>\<C>\<close>
   17.35          by blast
   17.36 @@ -52,20 +52,20 @@
   17.37        have "x \<notin> closure (S - U)"
   17.38          by (metis \<open>U \<in> \<C>\<close> \<open>x \<in> U\<close> less_irrefl sd_pos setdist_eq_0_sing_1 that)
   17.39        then show ?thesis
   17.40 -        apply (simp add: setdist_eq_0_sing_1 supp_setsum_def support_on_def)
   17.41 -        apply (rule ordered_comm_monoid_add_class.setsum_pos2 [OF *, of U])
   17.42 +        apply (simp add: setdist_eq_0_sing_1 supp_sum_def support_on_def)
   17.43 +        apply (rule ordered_comm_monoid_add_class.sum_pos2 [OF *, of U])
   17.44          using \<open>U \<in> \<C>\<close> \<open>x \<in> U\<close> False
   17.45          apply (auto simp: setdist_pos_le sd_pos that)
   17.46          done
   17.47      qed
   17.48      define F where
   17.49 -      "F \<equiv> \<lambda>W x. if x \<in> S then setdist {x} (S - W) / supp_setsum (\<lambda>V. setdist {x} (S - V)) \<C>
   17.50 +      "F \<equiv> \<lambda>W x. if x \<in> S then setdist {x} (S - W) / supp_sum (\<lambda>V. setdist {x} (S - V)) \<C>
   17.51                   else 0"
   17.52      show ?thesis
   17.53      proof (rule_tac F = F in that)
   17.54        have "continuous_on S (F U)" if "U \<in> \<C>" for U
   17.55        proof -
   17.56 -        have *: "continuous_on S (\<lambda>x. supp_setsum (\<lambda>V. setdist {x} (S - V)) \<C>)"
   17.57 +        have *: "continuous_on S (\<lambda>x. supp_sum (\<lambda>V. setdist {x} (S - V)) \<C>)"
   17.58          proof (clarsimp simp add: continuous_on_eq_continuous_within)
   17.59            fix x assume "x \<in> S"
   17.60            then obtain X where "open X" and x: "x \<in> S \<inter> X" and finX: "finite {U \<in> \<C>. U \<inter> X \<noteq> {}}"
   17.61 @@ -73,15 +73,15 @@
   17.62            then have OSX: "openin (subtopology euclidean S) (S \<inter> X)" by blast
   17.63            have sumeq: "\<And>x. x \<in> S \<inter> X \<Longrightarrow>
   17.64                       (\<Sum>V | V \<in> \<C> \<and> V \<inter> X \<noteq> {}. setdist {x} (S - V))
   17.65 -                     = supp_setsum (\<lambda>V. setdist {x} (S - V)) \<C>"
   17.66 -            apply (simp add: supp_setsum_def)
   17.67 -            apply (rule setsum.mono_neutral_right [OF finX])
   17.68 +                     = supp_sum (\<lambda>V. setdist {x} (S - V)) \<C>"
   17.69 +            apply (simp add: supp_sum_def)
   17.70 +            apply (rule sum.mono_neutral_right [OF finX])
   17.71              apply (auto simp: setdist_eq_0_sing_1 support_on_def subset_iff)
   17.72              apply (meson DiffI closure_subset disjoint_iff_not_equal subsetCE)
   17.73              done
   17.74 -          show "continuous (at x within S) (\<lambda>x. supp_setsum (\<lambda>V. setdist {x} (S - V)) \<C>)"
   17.75 +          show "continuous (at x within S) (\<lambda>x. supp_sum (\<lambda>V. setdist {x} (S - V)) \<C>)"
   17.76              apply (rule continuous_transform_within_openin
   17.77 -                     [where f = "\<lambda>x. (setsum (\<lambda>V. setdist {x} (S - V)) {V \<in> \<C>. V \<inter> X \<noteq> {}})"
   17.78 +                     [where f = "\<lambda>x. (sum (\<lambda>V. setdist {x} (S - V)) {V \<in> \<C>. V \<inter> X \<noteq> {}})"
   17.79                          and S ="S \<inter> X"])
   17.80              apply (rule continuous_intros continuous_at_setdist continuous_at_imp_continuous_at_within OSX x)+
   17.81              apply (simp add: sumeq)
   17.82 @@ -101,9 +101,9 @@
   17.83        show "\<And>x U. \<lbrakk>U \<in> \<C>; x \<in> S; x \<notin> U\<rbrakk> \<Longrightarrow> F U x = 0"
   17.84          by (simp add: setdist_eq_0_sing_1 closure_def F_def)
   17.85      next
   17.86 -      show "supp_setsum (\<lambda>W. F W x) \<C> = 1" if "x \<in> S" for x
   17.87 +      show "supp_sum (\<lambda>W. F W x) \<C> = 1" if "x \<in> S" for x
   17.88          using that ss_pos [OF that]
   17.89 -        by (simp add: F_def divide_simps supp_setsum_divide_distrib [symmetric])
   17.90 +        by (simp add: F_def divide_simps supp_sum_divide_distrib [symmetric])
   17.91      next
   17.92        show "\<exists>V. open V \<and> x \<in> V \<and> finite {U \<in> \<C>. \<exists>x\<in>V. F U x \<noteq> 0}" if "x \<in> S" for x
   17.93          using fin [OF that] that
   17.94 @@ -378,11 +378,11 @@
   17.95      where Hcont: "\<And>Z. Z \<in> \<C> \<Longrightarrow> continuous_on (U-S) (H Z)"
   17.96        and Hge0: "\<And>Z x. \<lbrakk>Z \<in> \<C>; x \<in> U-S\<rbrakk> \<Longrightarrow> 0 \<le> H Z x"
   17.97        and Heq0: "\<And>x Z. \<lbrakk>Z \<in> \<C>; x \<in> U-S; x \<notin> Z\<rbrakk> \<Longrightarrow> H Z x = 0"
   17.98 -      and H1: "\<And>x. x \<in> U-S \<Longrightarrow> supp_setsum (\<lambda>W. H W x) \<C> = 1"
   17.99 +      and H1: "\<And>x. x \<in> U-S \<Longrightarrow> supp_sum (\<lambda>W. H W x) \<C> = 1"
  17.100        and Hfin: "\<And>x. x \<in> U-S \<Longrightarrow> \<exists>V. open V \<and> x \<in> V \<and> finite {U \<in> \<C>. \<exists>x\<in>V. H U x \<noteq> 0}"
  17.101      apply (rule subordinate_partition_of_unity [OF USsub _ fin])
  17.102      using nbrhd by auto
  17.103 -  define g where "g \<equiv> \<lambda>x. if x \<in> S then f x else supp_setsum (\<lambda>T. H T x *\<^sub>R f(\<A> T)) \<C>"
  17.104 +  define g where "g \<equiv> \<lambda>x. if x \<in> S then f x else supp_sum (\<lambda>T. H T x *\<^sub>R f(\<A> T)) \<C>"
  17.105    show ?thesis
  17.106    proof (rule that)
  17.107      show "continuous_on U g"
  17.108 @@ -420,8 +420,8 @@
  17.109                then show ?thesis
  17.110                  using VA [OF \<open>T \<in> \<C>\<close>] by (auto simp: d)
  17.111              qed
  17.112 -            have "supp_setsum (\<lambda>T. H T y *\<^sub>R f (\<A> T)) \<C> \<in> ball (f a) e"
  17.113 -              apply (rule convex_supp_setsum [OF convex_ball])
  17.114 +            have "supp_sum (\<lambda>T. H T y *\<^sub>R f (\<A> T)) \<C> \<in> ball (f a) e"
  17.115 +              apply (rule convex_supp_sum [OF convex_ball])
  17.116                apply (simp_all add: False H1 Hge0 \<open>y \<in> U\<close>)
  17.117                by (metis dist_commute *)
  17.118              then show ?thesis
  17.119 @@ -447,7 +447,7 @@
  17.120            done
  17.121          show ?thesis
  17.122          proof (rule continuous_transform_within_openin [OF _ oUS])
  17.123 -          show "continuous (at a within U) (\<lambda>x. supp_setsum (\<lambda>T. H T x *\<^sub>R f (\<A> T)) \<C>)"
  17.124 +          show "continuous (at a within U) (\<lambda>x. supp_sum (\<lambda>T. H T x *\<^sub>R f (\<A> T)) \<C>)"
  17.125            proof (rule continuous_transform_within_openin)
  17.126              show "continuous (at a within U)
  17.127                      (\<lambda>x. \<Sum>T\<in>{U \<in> \<C>. \<exists>x\<in>N. H U x \<noteq> 0}. H T x *\<^sub>R f (\<A> T))"
  17.128 @@ -460,21 +460,21 @@
  17.129            next
  17.130              show "\<And>x. x \<in> (U - S) \<inter> N \<Longrightarrow>
  17.131                           (\<Sum>T \<in> {U \<in> \<C>. \<exists>x\<in>N. H U x \<noteq> 0}. H T x *\<^sub>R f (\<A> T))
  17.132 -                         = supp_setsum (\<lambda>T. H T x *\<^sub>R f (\<A> T)) \<C>"
  17.133 -              by (auto simp: supp_setsum_def support_on_def
  17.134 -                       intro: setsum.mono_neutral_right [OF finN])
  17.135 +                         = supp_sum (\<lambda>T. H T x *\<^sub>R f (\<A> T)) \<C>"
  17.136 +              by (auto simp: supp_sum_def support_on_def
  17.137 +                       intro: sum.mono_neutral_right [OF finN])
  17.138            qed
  17.139          next
  17.140            show "a \<in> U - S" using False \<open>a \<in> U\<close> by blast
  17.141          next
  17.142 -          show "\<And>x. x \<in> U - S \<Longrightarrow> supp_setsum (\<lambda>T. H T x *\<^sub>R f (\<A> T)) \<C> = g x"
  17.143 +          show "\<And>x. x \<in> U - S \<Longrightarrow> supp_sum (\<lambda>T. H T x *\<^sub>R f (\<A> T)) \<C> = g x"
  17.144              by (simp add: g_def)
  17.145          qed
  17.146        qed
  17.147      qed
  17.148      show "g ` U \<subseteq> C"
  17.149        using \<open>f ` S \<subseteq> C\<close> VA
  17.150 -      by (fastforce simp: g_def Hge0 intro!: convex_supp_setsum [OF \<open>convex C\<close>] H1)
  17.151 +      by (fastforce simp: g_def Hge0 intro!: convex_supp_sum [OF \<open>convex C\<close>] H1)
  17.152      show "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
  17.153        by (simp add: g_def)
  17.154    qed
    18.1 --- a/src/HOL/Analysis/Convex_Euclidean_Space.thy	Sun Oct 16 22:43:51 2016 +0200
    18.2 +++ b/src/HOL/Analysis/Convex_Euclidean_Space.thy	Mon Oct 17 11:46:22 2016 +0200
    18.3 @@ -69,9 +69,9 @@
    18.4      by (auto intro: finite_subset[OF assms])
    18.5    have ***: "\<And>i. i \<in> Basis \<Longrightarrow> (\<Sum>i\<in>d. f i *\<^sub>R i) \<bullet> i = (\<Sum>x\<in>d. if x = i then f x else 0)"
    18.6      using d
    18.7 -    by (auto intro!: setsum.cong simp: inner_Basis inner_setsum_left)
    18.8 -  show ?thesis
    18.9 -    unfolding euclidean_eq_iff[where 'a='a] by (auto simp: setsum.delta[OF **] ***)
   18.10 +    by (auto intro!: sum.cong simp: inner_Basis inner_sum_left)
   18.11 +  show ?thesis
   18.12 +    unfolding euclidean_eq_iff[where 'a='a] by (auto simp: sum.delta[OF **] ***)
   18.13  qed
   18.14  
   18.15  lemma independent_substdbasis: "d \<subseteq> Basis \<Longrightarrow> independent d"
   18.16 @@ -106,7 +106,7 @@
   18.17    shows "finite B \<and> card B = dim (span B)"
   18.18    using assms basis_card_eq_dim[of B "span B"] span_inc by auto
   18.19  
   18.20 -lemma setsum_not_0: "setsum f A \<noteq> 0 \<Longrightarrow> \<exists>a \<in> A. f a \<noteq> 0"
   18.21 +lemma sum_not_0: "sum f A \<noteq> 0 \<Longrightarrow> \<exists>a \<in> A. f a \<noteq> 0"
   18.22    by (rule ccontr) auto
   18.23  
   18.24  lemma subset_translation_eq [simp]:
   18.25 @@ -306,7 +306,7 @@
   18.26  
   18.27  subsection \<open>Explicit expressions for convexity in terms of arbitrary sums\<close>
   18.28  
   18.29 -lemma convex_setsum:
   18.30 +lemma convex_sum:
   18.31    fixes C :: "'a::real_vector set"
   18.32    assumes "finite s"
   18.33      and "convex C"
   18.34 @@ -320,55 +320,55 @@
   18.35    then show ?case by simp
   18.36  next
   18.37    case (insert i s) note IH = this(3)
   18.38 -  have "a i + setsum a s = 1"
   18.39 +  have "a i + sum a s = 1"
   18.40      and "0 \<le> a i"
   18.41      and "\<forall>j\<in>s. 0 \<le> a j"
   18.42      and "y i \<in> C"
   18.43      and "\<forall>j\<in>s. y j \<in> C"
   18.44      using insert.hyps(1,2) insert.prems by simp_all
   18.45 -  then have "0 \<le> setsum a s"
   18.46 -    by (simp add: setsum_nonneg)
   18.47 +  then have "0 \<le> sum a s"
   18.48 +    by (simp add: sum_nonneg)
   18.49    have "a i *\<^sub>R y i + (\<Sum>j\<in>s. a j *\<^sub>R y j) \<in> C"
   18.50 -  proof (cases "setsum a s = 0")
   18.51 +  proof (cases "sum a s = 0")
   18.52      case True
   18.53 -    with \<open>a i + setsum a s = 1\<close> have "a i = 1"
   18.54 +    with \<open>a i + sum a s = 1\<close> have "a i = 1"
   18.55        by simp
   18.56 -    from setsum_nonneg_0 [OF \<open>finite s\<close> _ True] \<open>\<forall>j\<in>s. 0 \<le> a j\<close> have "\<forall>j\<in>s. a j = 0"
   18.57 +    from sum_nonneg_0 [OF \<open>finite s\<close> _ True] \<open>\<forall>j\<in>s. 0 \<le> a j\<close> have "\<forall>j\<in>s. a j = 0"
   18.58        by simp
   18.59      show ?thesis using \<open>a i = 1\<close> and \<open>\<forall>j\<in>s. a j = 0\<close> and \<open>y i \<in> C\<close>
   18.60        by simp
   18.61    next
   18.62      case False
   18.63 -    with \<open>0 \<le> setsum a s\<close> have "0 < setsum a s"
   18.64 +    with \<open>0 \<le> sum a s\<close> have "0 < sum a s"
   18.65        by simp
   18.66 -    then have "(\<Sum>j\<in>s. (a j / setsum a s) *\<^sub>R y j) \<in> C"
   18.67 +    then have "(\<Sum>j\<in>s. (a j / sum a s) *\<^sub>R y j) \<in> C"
   18.68        using \<open>\<forall>j\<in>s. 0 \<le> a j\<close> and \<open>\<forall>j\<in>s. y j \<in> C\<close>
   18.69 -      by (simp add: IH setsum_divide_distrib [symmetric])
   18.70 +      by (simp add: IH sum_divide_distrib [symmetric])
   18.71      from \<open>convex C\<close> and \<open>y i \<in> C\<close> and this and \<open>0 \<le> a i\<close>
   18.72 -      and \<open>0 \<le> setsum a s\<close> and \<open>a i + setsum a s = 1\<close>
   18.73 -    have "a i *\<^sub>R y i + setsum a s *\<^sub>R (\<Sum>j\<in>s. (a j / setsum a s) *\<^sub>R y j) \<in> C"
   18.74 +      and \<open>0 \<le> sum a s\<close> and \<open>a i + sum a s = 1\<close>
   18.75 +    have "a i *\<^sub>R y i + sum a s *\<^sub>R (\<Sum>j\<in>s. (a j / sum a s) *\<^sub>R y j) \<in> C"
   18.76        by (rule convexD)
   18.77      then show ?thesis
   18.78 -      by (simp add: scaleR_setsum_right False)
   18.79 +      by (simp add: scaleR_sum_right False)
   18.80    qed
   18.81    then show ?case using \<open>finite s\<close> and \<open>i \<notin> s\<close>
   18.82      by simp
   18.83  qed
   18.84  
   18.85  lemma convex:
   18.86 -  "convex s \<longleftrightarrow> (\<forall>(k::nat) u x. (\<forall>i. 1\<le>i \<and> i\<le>k \<longrightarrow> 0 \<le> u i \<and> x i \<in>s) \<and> (setsum u {1..k} = 1)
   18.87 -      \<longrightarrow> setsum (\<lambda>i. u i *\<^sub>R x i) {1..k} \<in> s)"
   18.88 +  "convex s \<longleftrightarrow> (\<forall>(k::nat) u x. (\<forall>i. 1\<le>i \<and> i\<le>k \<longrightarrow> 0 \<le> u i \<and> x i \<in>s) \<and> (sum u {1..k} = 1)
   18.89 +      \<longrightarrow> sum (\<lambda>i. u i *\<^sub>R x i) {1..k} \<in> s)"
   18.90  proof safe
   18.91    fix k :: nat
   18.92    fix u :: "nat \<Rightarrow> real"
   18.93    fix x
   18.94    assume "convex s"
   18.95      "\<forall>i. 1 \<le> i \<and> i \<le> k \<longrightarrow> 0 \<le> u i \<and> x i \<in> s"
   18.96 -    "setsum u {1..k} = 1"
   18.97 -  with convex_setsum[of "{1 .. k}" s] show "(\<Sum>j\<in>{1 .. k}. u j *\<^sub>R x j) \<in> s"
   18.98 -    by auto
   18.99 -next
  18.100 -  assume *: "\<forall>k u x. (\<forall> i :: nat. 1 \<le> i \<and> i \<le> k \<longrightarrow> 0 \<le> u i \<and> x i \<in> s) \<and> setsum u {1..k} = 1
  18.101 +    "sum u {1..k} = 1"
  18.102 +  with convex_sum[of "{1 .. k}" s] show "(\<Sum>j\<in>{1 .. k}. u j *\<^sub>R x j) \<in> s"
  18.103 +    by auto
  18.104 +next
  18.105 +  assume *: "\<forall>k u x. (\<forall> i :: nat. 1 \<le> i \<and> i \<le> k \<longrightarrow> 0 \<le> u i \<and> x i \<in> s) \<and> sum u {1..k} = 1
  18.106      \<longrightarrow> (\<Sum>i = 1..k. u i *\<^sub>R (x i :: 'a)) \<in> s"
  18.107    {
  18.108      fix \<mu> :: real
  18.109 @@ -381,14 +381,14 @@
  18.110        by auto
  18.111      then have card: "card ({1 :: nat .. 2} \<inter> - {x. x = 1}) = 1"
  18.112        by simp
  18.113 -    then have "setsum ?u {1 .. 2} = 1"
  18.114 -      using setsum.If_cases[of "{(1 :: nat) .. 2}" "\<lambda> x. x = 1" "\<lambda> x. \<mu>" "\<lambda> x. 1 - \<mu>"]
  18.115 +    then have "sum ?u {1 .. 2} = 1"
  18.116 +      using sum.If_cases[of "{(1 :: nat) .. 2}" "\<lambda> x. x = 1" "\<lambda> x. \<mu>" "\<lambda> x. 1 - \<mu>"]
  18.117        by auto
  18.118      with *[rule_format, of "2" ?u ?x] have s: "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) \<in> s"
  18.119        using mu xy by auto
  18.120      have grarr: "(\<Sum>j \<in> {Suc (Suc 0)..2}. ?u j *\<^sub>R ?x j) = (1 - \<mu>) *\<^sub>R y"
  18.121 -      using setsum_head_Suc[of "Suc (Suc 0)" 2 "\<lambda> j. (1 - \<mu>) *\<^sub>R y"] by auto
  18.122 -    from setsum_head_Suc[of "Suc 0" 2 "\<lambda> j. ?u j *\<^sub>R ?x j", simplified this]
  18.123 +      using sum_head_Suc[of "Suc (Suc 0)" 2 "\<lambda> j. (1 - \<mu>) *\<^sub>R y"] by auto
  18.124 +    from sum_head_Suc[of "Suc 0" 2 "\<lambda> j. ?u j *\<^sub>R ?x j", simplified this]
  18.125      have "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) = \<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y"
  18.126        by auto
  18.127      then have "(1 - \<mu>) *\<^sub>R y + \<mu> *\<^sub>R x \<in> s"
  18.128 @@ -402,18 +402,18 @@
  18.129  lemma convex_explicit:
  18.130    fixes s :: "'a::real_vector set"
  18.131    shows "convex s \<longleftrightarrow>
  18.132 -    (\<forall>t u. finite t \<and> t \<subseteq> s \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and> setsum u t = 1 \<longrightarrow> setsum (\<lambda>x. u x *\<^sub>R x) t \<in> s)"
  18.133 +    (\<forall>t u. finite t \<and> t \<subseteq> s \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and> sum u t = 1 \<longrightarrow> sum (\<lambda>x. u x *\<^sub>R x) t \<in> s)"
  18.134  proof safe
  18.135    fix t
  18.136    fix u :: "'a \<Rightarrow> real"
  18.137    assume "convex s"
  18.138      and "finite t"
  18.139 -    and "t \<subseteq> s" "\<forall>x\<in>t. 0 \<le> u x" "setsum u t = 1"
  18.140 +    and "t \<subseteq> s" "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1"
  18.141    then show "(\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
  18.142 -    using convex_setsum[of t s u "\<lambda> x. x"] by auto
  18.143 +    using convex_sum[of t s u "\<lambda> x. x"] by auto
  18.144  next
  18.145    assume *: "\<forall>t. \<forall> u. finite t \<and> t \<subseteq> s \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and>
  18.146 -    setsum u t = 1 \<longrightarrow> (\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
  18.147 +    sum u t = 1 \<longrightarrow> (\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
  18.148    show "convex s"
  18.149      unfolding convex_alt
  18.150    proof safe
  18.151 @@ -437,7 +437,7 @@
  18.152  
  18.153  lemma convex_finite:
  18.154    assumes "finite s"
  18.155 -  shows "convex s \<longleftrightarrow> (\<forall>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<longrightarrow> setsum (\<lambda>x. u x *\<^sub>R x) s \<in> s)"
  18.156 +  shows "convex s \<longleftrightarrow> (\<forall>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<longrightarrow> sum (\<lambda>x. u x *\<^sub>R x) s \<in> s)"
  18.157    unfolding convex_explicit
  18.158    apply safe
  18.159    subgoal for u by (erule allE [where x=s], erule allE [where x=u]) auto
  18.160 @@ -445,12 +445,12 @@
  18.161    proof -
  18.162      have if_distrib_arg: "\<And>P f g x. (if P then f else g) x = (if P then f x else g x)"
  18.163        by simp
  18.164 -    assume sum: "\<forall>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> s"
  18.165 -    assume *: "\<forall>x\<in>t. 0 \<le> u x" "setsum u t = 1"
  18.166 +    assume sum: "\<forall>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> s"
  18.167 +    assume *: "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1"
  18.168      assume "t \<subseteq> s"
  18.169      then have "s \<inter> t = t" by auto
  18.170      with sum[THEN spec[where x="\<lambda>x. if x\<in>t then u x else 0"]] * show "(\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
  18.171 -      by (auto simp: assms setsum.If_cases if_distrib if_distrib_arg)
  18.172 +      by (auto simp: assms sum.If_cases if_distrib if_distrib_arg)
  18.173    qed
  18.174    done
  18.175  
  18.176 @@ -704,7 +704,7 @@
  18.177      by fastforce
  18.178  qed
  18.179  
  18.180 -lemma convex_on_setsum:
  18.181 +lemma convex_on_sum:
  18.182    fixes a :: "'a \<Rightarrow> real"
  18.183      and y :: "'a \<Rightarrow> 'b::real_vector"
  18.184      and f :: "'b \<Rightarrow> real"
  18.185 @@ -736,7 +736,7 @@
  18.186      then have "(\<Sum> j \<in> s. a j) = 0"
  18.187        using insert by auto
  18.188      then have "\<And>j. j \<in> s \<Longrightarrow> a j = 0"
  18.189 -      using insert by (fastforce simp: setsum_nonneg_eq_0_iff)
  18.190 +      using insert by (fastforce simp: sum_nonneg_eq_0_iff)
  18.191      then show ?thesis
  18.192        using insert by auto
  18.193    next
  18.194 @@ -746,7 +746,7 @@
  18.195      have fis: "finite (insert i s)"
  18.196        using insert by auto
  18.197      then have ai1: "a i \<le> 1"
  18.198 -      using setsum_nonneg_leq_bound[of "insert i s" a] insert by simp
  18.199 +      using sum_nonneg_leq_bound[of "insert i s" a] insert by simp
  18.200      then have "a i < 1"
  18.201        using False by auto
  18.202      then have i0: "1 - a i > 0"
  18.203 @@ -757,23 +757,23 @@
  18.204      have "(\<Sum> j \<in> insert i s. a j) = 1"
  18.205        using insert by auto
  18.206      then have "(\<Sum> j \<in> s. a j) = 1 - a i"
  18.207 -      using setsum.insert insert by fastforce
  18.208 +      using sum.insert insert by fastforce
  18.209      then have "(\<Sum> j \<in> s. a j) / (1 - a i) = 1"
  18.210        using i0 by auto
  18.211      then have a1: "(\<Sum> j \<in> s. ?a j) = 1"
  18.212 -      unfolding setsum_divide_distrib by simp
  18.213 +      unfolding sum_divide_distrib by simp
  18.214      have "convex C" using insert by auto
  18.215      then have asum: "(\<Sum> j \<in> s. ?a j *\<^sub>R y j) \<in> C"
  18.216 -      using insert convex_setsum [OF \<open>finite s\<close> \<open>convex C\<close> a1 a_nonneg] by auto
  18.217 +      using insert convex_sum [OF \<open>finite s\<close> \<open>convex C\<close> a1 a_nonneg] by auto
  18.218      have asum_le: "f (\<Sum> j \<in> s. ?a j *\<^sub>R y j) \<le> (\<Sum> j \<in> s. ?a j * f (y j))"
  18.219        using a_nonneg a1 insert by blast
  18.220      have "f (\<Sum> j \<in> insert i s. a j *\<^sub>R y j) = f ((\<Sum> j \<in> s. a j *\<^sub>R y j) + a i *\<^sub>R y i)"
  18.221 -      using setsum.insert[of s i "\<lambda> j. a j *\<^sub>R y j", OF \<open>finite s\<close> \<open>i \<notin> s\<close>] insert
  18.222 +      using sum.insert[of s i "\<lambda> j. a j *\<^sub>R y j", OF \<open>finite s\<close> \<open>i \<notin> s\<close>] insert
  18.223        by (auto simp only: add.commute)
  18.224      also have "\<dots> = f (((1 - a i) * inverse (1 - a i)) *\<^sub>R (\<Sum> j \<in> s. a j *\<^sub>R y j) + a i *\<^sub>R y i)"
  18.225        using i0 by auto
  18.226      also have "\<dots> = f ((1 - a i) *\<^sub>R (\<Sum> j \<in> s. (a j * inverse (1 - a i)) *\<^sub>R y j) + a i *\<^sub>R y i)"
  18.227 -      using scaleR_right.setsum[of "inverse (1 - a i)" "\<lambda> j. a j *\<^sub>R y j" s, symmetric]
  18.228 +      using scaleR_right.sum[of "inverse (1 - a i)" "\<lambda> j. a j *\<^sub>R y j" s, symmetric]
  18.229        by (auto simp: algebra_simps)
  18.230      also have "\<dots> = f ((1 - a i) *\<^sub>R (\<Sum> j \<in> s. ?a j *\<^sub>R y j) + a i *\<^sub>R y i)"
  18.231        by (auto simp: divide_inverse)
  18.232 @@ -785,7 +785,7 @@
  18.233              OF asum_le less_imp_le[OF i0]], of "a i * f (y i)"]
  18.234        by simp
  18.235      also have "\<dots> = (\<Sum> j \<in> s. (1 - a i) * ?a j * f (y j)) + a i * f (y i)"
  18.236 -      unfolding setsum_distrib_left[of "1 - a i" "\<lambda> j. ?a j * f (y j)"]
  18.237 +      unfolding sum_distrib_left[of "1 - a i" "\<lambda> j. ?a j * f (y j)"]
  18.238        using i0 by auto
  18.239      also have "\<dots> = (\<Sum> j \<in> s. a j * f (y j)) + a i * f (y i)"
  18.240        using i0 by auto
  18.241 @@ -1148,19 +1148,19 @@
  18.242    finally show ?thesis .
  18.243  qed (insert assms(2), simp_all)
  18.244  
  18.245 -lemma convex_supp_setsum:
  18.246 -  assumes "convex S" and 1: "supp_setsum u I = 1"
  18.247 +lemma convex_supp_sum:
  18.248 +  assumes "convex S" and 1: "supp_sum u I = 1"
  18.249        and "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> u i \<and> (u i = 0 \<or> f i \<in> S)"
  18.250 -    shows "supp_setsum (\<lambda>i. u i *\<^sub>R f i) I \<in> S"
  18.251 +    shows "supp_sum (\<lambda>i. u i *\<^sub>R f i) I \<in> S"
  18.252  proof -
  18.253    have fin: "finite {i \<in> I. u i \<noteq> 0}"
  18.254 -    using 1 setsum.infinite by (force simp: supp_setsum_def support_on_def)
  18.255 -  then have eq: "supp_setsum (\<lambda>i. u i *\<^sub>R f i) I = setsum (\<lambda>i. u i *\<^sub>R f i) {i \<in> I. u i \<noteq> 0}"
  18.256 -    by (force intro: setsum.mono_neutral_left simp: supp_setsum_def support_on_def)
  18.257 +    using 1 sum.infinite by (force simp: supp_sum_def support_on_def)
  18.258 +  then have eq: "supp_sum (\<lambda>i. u i *\<^sub>R f i) I = sum (\<lambda>i. u i *\<^sub>R f i) {i \<in> I. u i \<noteq> 0}"
  18.259 +    by (force intro: sum.mono_neutral_left simp: supp_sum_def support_on_def)
  18.260    show ?thesis
  18.261      apply (simp add: eq)
  18.262 -    apply (rule convex_setsum [OF fin \<open>convex S\<close>])
  18.263 -    using 1 assms apply (auto simp: supp_setsum_def support_on_def)
  18.264 +    apply (rule convex_sum [OF fin \<open>convex S\<close>])
  18.265 +    using 1 assms apply (auto simp: supp_sum_def support_on_def)
  18.266      done
  18.267  qed
  18.268  
  18.269 @@ -1335,18 +1335,18 @@
  18.270    shows "sphere a r = {} \<longleftrightarrow> r < 0"
  18.271  by (auto simp: sphere_def dist_norm) (metis dist_norm le_less_linear vector_choose_dist)
  18.272  
  18.273 -lemma setsum_delta_notmem:
  18.274 +lemma sum_delta_notmem:
  18.275    assumes "x \<notin> s"
  18.276 -  shows "setsum (\<lambda>y. if (y = x) then P x else Q y) s = setsum Q s"
  18.277 -    and "setsum (\<lambda>y. if (x = y) then P x else Q y) s = setsum Q s"
  18.278 -    and "setsum (\<lambda>y. if (y = x) then P y else Q y) s = setsum Q s"
  18.279 -    and "setsum (\<lambda>y. if (x = y) then P y else Q y) s = setsum Q s"
  18.280 -  apply (rule_tac [!] setsum.cong)
  18.281 +  shows "sum (\<lambda>y. if (y = x) then P x else Q y) s = sum Q s"
  18.282 +    and "sum (\<lambda>y. if (x = y) then P x else Q y) s = sum Q s"
  18.283 +    and "sum (\<lambda>y. if (y = x) then P y else Q y) s = sum Q s"
  18.284 +    and "sum (\<lambda>y. if (x = y) then P y else Q y) s = sum Q s"
  18.285 +  apply (rule_tac [!] sum.cong)
  18.286    using assms
  18.287    apply auto
  18.288    done
  18.289  
  18.290 -lemma setsum_delta'':
  18.291 +lemma sum_delta'':
  18.292    fixes s::"'a::real_vector set"
  18.293    assumes "finite s"
  18.294    shows "(\<Sum>x\<in>s. (if y = x then f x else 0) *\<^sub>R x) = (if y\<in>s then (f y) *\<^sub>R y else 0)"
  18.295 @@ -1354,7 +1354,7 @@
  18.296    have *: "\<And>x y. (if y = x then f x else (0::real)) *\<^sub>R x = (if x=y then (f x) *\<^sub>R x else 0)"
  18.297      by auto
  18.298    show ?thesis
  18.299 -    unfolding * using setsum.delta[OF assms, of y "\<lambda>x. f x *\<^sub>R x"] by auto
  18.300 +    unfolding * using sum.delta[OF assms, of y "\<lambda>x. f x *\<^sub>R x"] by auto
  18.301  qed
  18.302  
  18.303  lemma if_smult: "(if P then x else (y::real)) *\<^sub>R v = (if P then x *\<^sub>R v else y *\<^sub>R v)"
  18.304 @@ -1429,7 +1429,7 @@
  18.305  lemma affine:
  18.306    fixes V::"'a::real_vector set"
  18.307    shows "affine V \<longleftrightarrow>
  18.308 -    (\<forall>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> V \<and> setsum u s = 1 \<longrightarrow> (setsum (\<lambda>x. (u x) *\<^sub>R x)) s \<in> V)"
  18.309 +    (\<forall>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> V \<and> sum u s = 1 \<longrightarrow> (sum (\<lambda>x. (u x) *\<^sub>R x)) s \<in> V)"
  18.310    unfolding affine_def
  18.311    apply rule
  18.312    apply(rule, rule, rule)
  18.313 @@ -1439,7 +1439,7 @@
  18.314  proof -
  18.315    fix x y u v
  18.316    assume as: "x \<in> V" "y \<in> V" "u + v = (1::real)"
  18.317 -    "\<forall>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> V \<and> setsum u s = 1 \<longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
  18.318 +    "\<forall>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> V \<and> sum u s = 1 \<longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
  18.319    then show "u *\<^sub>R x + v *\<^sub>R y \<in> V"
  18.320      apply (cases "x = y")
  18.321      using as(4)[THEN spec[where x="{x,y}"], THEN spec[where x="\<lambda>w. if w = x then u else v"]]
  18.322 @@ -1449,7 +1449,7 @@
  18.323  next
  18.324    fix s u
  18.325    assume as: "\<forall>x\<in>V. \<forall>y\<in>V. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> V"
  18.326 -    "finite s" "s \<noteq> {}" "s \<subseteq> V" "setsum u s = (1::real)"
  18.327 +    "finite s" "s \<noteq> {}" "s \<subseteq> V" "sum u s = (1::real)"
  18.328    define n where "n = card s"
  18.329    have "card s = 0 \<or> card s = 1 \<or> card s = 2 \<or> card s > 2" by auto
  18.330    then show "(\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
  18.331 @@ -1461,7 +1461,7 @@
  18.332        unfolding card_Suc_eq by auto
  18.333      then show ?thesis
  18.334        using as(1)[THEN bspec[where x=a], THEN bspec[where x=b]] using as(4,5)
  18.335 -      by (auto simp add: setsum_clauses(2))
  18.336 +      by (auto simp add: sum_clauses(2))
  18.337    next
  18.338      assume "card s > 2"
  18.339      then show ?thesis using as and n_def
  18.340 @@ -1473,15 +1473,15 @@
  18.341        fix s :: "'a set" and u :: "'a \<Rightarrow> real"
  18.342        assume IA:
  18.343          "\<And>u s.  \<lbrakk>2 < card s; \<forall>x\<in>V. \<forall>y\<in>V. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> V; finite s;
  18.344 -          s \<noteq> {}; s \<subseteq> V; setsum u s = 1; n = card s \<rbrakk> \<Longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
  18.345 +          s \<noteq> {}; s \<subseteq> V; sum u s = 1; n = card s \<rbrakk> \<Longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
  18.346          and as:
  18.347            "Suc n = card s" "2 < card s" "\<forall>x\<in>V. \<forall>y\<in>V. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> V"
  18.348 -           "finite s" "s \<noteq> {}" "s \<subseteq> V" "setsum u s = 1"
  18.349 +           "finite s" "s \<noteq> {}" "s \<subseteq> V" "sum u s = 1"
  18.350        have "\<exists>x\<in>s. u x \<noteq> 1"
  18.351        proof (rule ccontr)
  18.352          assume "\<not> ?thesis"
  18.353 -        then have "setsum u s = real_of_nat (card s)"
  18.354 -          unfolding card_eq_setsum by auto
  18.355 +        then have "sum u s = real_of_nat (card s)"
  18.356 +          unfolding card_eq_sum by auto
  18.357          then show False
  18.358            using as(7) and \<open>card s > 2\<close>
  18.359            by (metis One_nat_def less_Suc0 Zero_not_Suc of_nat_1 of_nat_eq_iff numeral_2_eq_2)
  18.360 @@ -1495,9 +1495,9 @@
  18.361          done
  18.362        have *: "s = insert x (s - {x})" "finite (s - {x})"
  18.363          using \<open>x\<in>s\<close> and as(4) by auto
  18.364 -      have **: "setsum u (s - {x}) = 1 - u x"
  18.365 -        using setsum_clauses(2)[OF *(2), of u x, unfolded *(1)[symmetric] as(7)] by auto
  18.366 -      have ***: "inverse (1 - u x) * setsum u (s - {x}) = 1"
  18.367 +      have **: "sum u (s - {x}) = 1 - u x"
  18.368 +        using sum_clauses(2)[OF *(2), of u x, unfolded *(1)[symmetric] as(7)] by auto
  18.369 +      have ***: "inverse (1 - u x) * sum u (s - {x}) = 1"
  18.370          unfolding ** using \<open>u x \<noteq> 1\<close> by auto
  18.371        have "(\<Sum>xa\<in>s - {x}. (inverse (1 - u x) * u xa) *\<^sub>R xa) \<in> V"
  18.372        proof (cases "card (s - {x}) > 2")
  18.373 @@ -1511,7 +1511,7 @@
  18.374          qed auto
  18.375          then show ?thesis
  18.376            apply (rule_tac IA[of "s - {x}" "\<lambda>y. (inverse (1 - u x) * u y)"])
  18.377 -          unfolding setsum_distrib_left[symmetric]
  18.378 +          unfolding sum_distrib_left[symmetric]
  18.379            using as and *** and True
  18.380            apply auto
  18.381            done
  18.382 @@ -1524,21 +1524,21 @@
  18.383          then show ?thesis
  18.384            using as(3)[THEN bspec[where x=a], THEN bspec[where x=b]]
  18.385            using *** *(2) and \<open>s \<subseteq> V\<close>
  18.386 -          unfolding setsum_distrib_left
  18.387 -          by (auto simp add: setsum_clauses(2))
  18.388 +          unfolding sum_distrib_left
  18.389 +          by (auto simp add: sum_clauses(2))
  18.390        qed
  18.391        then have "u x + (1 - u x) = 1 \<Longrightarrow>
  18.392            u x *\<^sub>R x + (1 - u x) *\<^sub>R ((\<Sum>xa\<in>s - {x}. u xa *\<^sub>R xa) /\<^sub>R (1 - u x)) \<in> V"
  18.393          apply -
  18.394          apply (rule as(3)[rule_format])
  18.395 -        unfolding  Real_Vector_Spaces.scaleR_right.setsum
  18.396 +        unfolding  Real_Vector_Spaces.scaleR_right.sum
  18.397          using x(1) as(6)
  18.398          apply auto
  18.399          done
  18.400        then show "(\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
  18.401 -        unfolding scaleR_scaleR[symmetric] and scaleR_right.setsum [symmetric]
  18.402 +        unfolding scaleR_scaleR[symmetric] and scaleR_right.sum [symmetric]
  18.403          apply (subst *)
  18.404 -        unfolding setsum_clauses(2)[OF *(2)]
  18.405 +        unfolding sum_clauses(2)[OF *(2)]
  18.406          using \<open>u x \<noteq> 1\<close>
  18.407          apply auto
  18.408          done
  18.409 @@ -1554,7 +1554,7 @@
  18.410  
  18.411  lemma affine_hull_explicit:
  18.412    "affine hull p =
  18.413 -    {y. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> setsum (\<lambda>v. (u v) *\<^sub>R v) s = y}"
  18.414 +    {y. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> sum u s = 1 \<and> sum (\<lambda>v. (u v) *\<^sub>R v) s = y}"
  18.415    apply (rule hull_unique)
  18.416    apply (subst subset_eq)
  18.417    prefer 3
  18.418 @@ -1567,7 +1567,7 @@
  18.419  proof -
  18.420    fix x
  18.421    assume "x\<in>p"
  18.422 -  then show "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.423 +  then show "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.424      apply (rule_tac x="{x}" in exI)
  18.425      apply (rule_tac x="\<lambda>x. 1" in exI)
  18.426      apply auto
  18.427 @@ -1575,12 +1575,12 @@
  18.428  next
  18.429    fix t x s u
  18.430    assume as: "p \<subseteq> t" "affine t" "finite s" "s \<noteq> {}"
  18.431 -    "s \<subseteq> p" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.432 +    "s \<subseteq> p" "sum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.433    then show "x \<in> t"
  18.434      using as(2)[unfolded affine, THEN spec[where x=s], THEN spec[where x=u]]
  18.435      by auto
  18.436  next
  18.437 -  show "affine {y. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y}"
  18.438 +  show "affine {y. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y}"
  18.439      unfolding affine_def
  18.440      apply (rule, rule, rule, rule, rule)
  18.441      unfolding mem_Collect_eq
  18.442 @@ -1588,26 +1588,26 @@
  18.443      fix u v :: real
  18.444      assume uv: "u + v = 1"
  18.445      fix x
  18.446 -    assume "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.447 +    assume "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.448      then obtain sx ux where
  18.449 -      x: "finite sx" "sx \<noteq> {}" "sx \<subseteq> p" "setsum ux sx = 1" "(\<Sum>v\<in>sx. ux v *\<^sub>R v) = x"
  18.450 +      x: "finite sx" "sx \<noteq> {}" "sx \<subseteq> p" "sum ux sx = 1" "(\<Sum>v\<in>sx. ux v *\<^sub>R v) = x"
  18.451        by auto
  18.452      fix y
  18.453 -    assume "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
  18.454 +    assume "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
  18.455      then obtain sy uy where
  18.456 -      y: "finite sy" "sy \<noteq> {}" "sy \<subseteq> p" "setsum uy sy = 1" "(\<Sum>v\<in>sy. uy v *\<^sub>R v) = y" by auto
  18.457 +      y: "finite sy" "sy \<noteq> {}" "sy \<subseteq> p" "sum uy sy = 1" "(\<Sum>v\<in>sy. uy v *\<^sub>R v) = y" by auto
  18.458      have xy: "finite (sx \<union> sy)"
  18.459        using x(1) y(1) by auto
  18.460      have **: "(sx \<union> sy) \<inter> sx = sx" "(sx \<union> sy) \<inter> sy = sy"
  18.461        by auto
  18.462      show "\<exists>s ua. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and>
  18.463 -        setsum ua s = 1 \<and> (\<Sum>v\<in>s. ua v *\<^sub>R v) = u *\<^sub>R x + v *\<^sub>R y"
  18.464 +        sum ua s = 1 \<and> (\<Sum>v\<in>s. ua v *\<^sub>R v) = u *\<^sub>R x + v *\<^sub>R y"
  18.465        apply (rule_tac x="sx \<union> sy" in exI)
  18.466        apply (rule_tac x="\<lambda>a. (if a\<in>sx then u * ux a else 0) + (if a\<in>sy then v * uy a else 0)" in exI)
  18.467 -      unfolding scaleR_left_distrib setsum.distrib if_smult scaleR_zero_left
  18.468 -        ** setsum.inter_restrict[OF xy, symmetric]
  18.469 -      unfolding scaleR_scaleR[symmetric] Real_Vector_Spaces.scaleR_right.setsum [symmetric]
  18.470 -        and setsum_distrib_left[symmetric]
  18.471 +      unfolding scaleR_left_distrib sum.distrib if_smult scaleR_zero_left
  18.472 +        ** sum.inter_restrict[OF xy, symmetric]
  18.473 +      unfolding scaleR_scaleR[symmetric] Real_Vector_Spaces.scaleR_right.sum [symmetric]
  18.474 +        and sum_distrib_left[symmetric]
  18.475        unfolding x y
  18.476        using x(1-3) y(1-3) uv
  18.477        apply simp
  18.478 @@ -1617,7 +1617,7 @@
  18.479  
  18.480  lemma affine_hull_finite:
  18.481    assumes "finite s"
  18.482 -  shows "affine hull s = {y. \<exists>u. setsum u s = 1 \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = y}"
  18.483 +  shows "affine hull s = {y. \<exists>u. sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
  18.484    unfolding affine_hull_explicit and set_eq_iff and mem_Collect_eq
  18.485    apply (rule, rule)
  18.486    apply (erule exE)+
  18.487 @@ -1627,9 +1627,9 @@
  18.488    apply (erule conjE)
  18.489  proof -
  18.490    fix x u
  18.491 -  assume "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.492 +  assume "sum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.493    then show "\<exists>sa u. finite sa \<and>
  18.494 -      \<not> (\<forall>x. (x \<in> sa) = (x \<in> {})) \<and> sa \<subseteq> s \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = x"
  18.495 +      \<not> (\<forall>x. (x \<in> sa) = (x \<in> {})) \<and> sa \<subseteq> s \<and> sum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = x"
  18.496      apply (rule_tac x=s in exI, rule_tac x=u in exI)
  18.497      using assms
  18.498      apply auto
  18.499 @@ -1639,10 +1639,10 @@
  18.500    assume "t \<subseteq> s"
  18.501    then have *: "s \<inter> t = t"
  18.502      by auto
  18.503 -  assume "finite t" "\<not> (\<forall>x. (x \<in> t) = (x \<in> {}))" "setsum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = x"
  18.504 -  then show "\<exists>u. setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.505 +  assume "finite t" "\<not> (\<forall>x. (x \<in> t) = (x \<in> {}))" "sum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = x"
  18.506 +  then show "\<exists>u. sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.507      apply (rule_tac x="\<lambda>x. if x\<in>t then u x else 0" in exI)
  18.508 -    unfolding if_smult scaleR_zero_left and setsum.inter_restrict[OF assms, symmetric] and *
  18.509 +    unfolding if_smult scaleR_zero_left and sum.inter_restrict[OF assms, symmetric] and *
  18.510      apply auto
  18.511      done
  18.512  qed
  18.513 @@ -1653,22 +1653,22 @@
  18.514  lemma affine_hull_empty[simp]: "affine hull {} = {}"
  18.515    by (rule hull_unique) auto
  18.516  
  18.517 -(*could delete: it simply rewrites setsum expressions, but it's used twice*)
  18.518 +(*could delete: it simply rewrites sum expressions, but it's used twice*)
  18.519  lemma affine_hull_finite_step:
  18.520    fixes y :: "'a::real_vector"
  18.521    shows
  18.522 -    "(\<exists>u. setsum u {} = w \<and> setsum (\<lambda>x. u x *\<^sub>R x) {} = y) \<longleftrightarrow> w = 0 \<and> y = 0" (is ?th1)
  18.523 +    "(\<exists>u. sum u {} = w \<and> sum (\<lambda>x. u x *\<^sub>R x) {} = y) \<longleftrightarrow> w = 0 \<and> y = 0" (is ?th1)
  18.524      and
  18.525      "finite s \<Longrightarrow>
  18.526 -      (\<exists>u. setsum u (insert a s) = w \<and> setsum (\<lambda>x. u x *\<^sub>R x) (insert a s) = y) \<longleftrightarrow>
  18.527 -      (\<exists>v u. setsum u s = w - v \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y - v *\<^sub>R a)" (is "_ \<Longrightarrow> ?lhs = ?rhs")
  18.528 +      (\<exists>u. sum u (insert a s) = w \<and> sum (\<lambda>x. u x *\<^sub>R x) (insert a s) = y) \<longleftrightarrow>
  18.529 +      (\<exists>v u. sum u s = w - v \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y - v *\<^sub>R a)" (is "_ \<Longrightarrow> ?lhs = ?rhs")
  18.530  proof -
  18.531    show ?th1 by simp
  18.532    assume fin: "finite s"
  18.533    show "?lhs = ?rhs"
  18.534    proof
  18.535      assume ?lhs
  18.536 -    then obtain u where u: "setsum u (insert a s) = w \<and> (\<Sum>x\<in>insert a s. u x *\<^sub>R x) = y"
  18.537 +    then obtain u where u: "sum u (insert a s) = w \<and> (\<Sum>x\<in>insert a s. u x *\<^sub>R x) = y"
  18.538        by auto
  18.539      show ?rhs
  18.540      proof (cases "a \<in> s")
  18.541 @@ -1689,7 +1689,7 @@
  18.542      qed
  18.543    next
  18.544      assume ?rhs
  18.545 -    then obtain v u where vu: "setsum u s = w - v"  "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
  18.546 +    then obtain v u where vu: "sum u s = w - v"  "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
  18.547        by auto
  18.548      have *: "\<And>x M. (if x = a then v else M) *\<^sub>R x = (if x = a then v *\<^sub>R x else M *\<^sub>R x)"
  18.549        by auto
  18.550 @@ -1698,11 +1698,11 @@
  18.551        case True
  18.552        then show ?thesis
  18.553          apply (rule_tac x="\<lambda>x. (if x=a then v else 0) + u x" in exI)
  18.554 -        unfolding setsum_clauses(2)[OF fin]
  18.555 +        unfolding sum_clauses(2)[OF fin]
  18.556          apply simp
  18.557 -        unfolding scaleR_left_distrib and setsum.distrib
  18.558 +        unfolding scaleR_left_distrib and sum.distrib
  18.559          unfolding vu and * and scaleR_zero_left
  18.560 -        apply (auto simp add: setsum.delta[OF fin])
  18.561 +        apply (auto simp add: sum.delta[OF fin])
  18.562          done
  18.563      next
  18.564        case False
  18.565 @@ -1711,9 +1711,9 @@
  18.566          "\<And>x. x \<in> s \<Longrightarrow> u x *\<^sub>R x = (if x = a then v *\<^sub>R x else u x *\<^sub>R x)" by auto
  18.567        from False show ?thesis
  18.568          apply (rule_tac x="\<lambda>x. if x=a then v else u x" in exI)
  18.569 -        unfolding setsum_clauses(2)[OF fin] and * using vu
  18.570 -        using setsum.cong [of s _ "\<lambda>x. u x *\<^sub>R x" "\<lambda>x. if x = a then v *\<^sub>R x else u x *\<^sub>R x", OF _ **(2)]
  18.571 -        using setsum.cong [of s _ u "\<lambda>x. if x = a then v else u x", OF _ **(1)]
  18.572 +        unfolding sum_clauses(2)[OF fin] and * using vu
  18.573 +        using sum.cong [of s _ "\<lambda>x. u x *\<^sub>R x" "\<lambda>x. if x = a then v *\<^sub>R x else u x *\<^sub>R x", OF _ **(2)]
  18.574 +        using sum.cong [of s _ u "\<lambda>x. if x = a then v else u x", OF _ **(1)]
  18.575          apply auto
  18.576          done
  18.577      qed
  18.578 @@ -1728,7 +1728,7 @@
  18.579    have *:
  18.580      "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::real)"
  18.581      "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::'a)" by auto
  18.582 -  have "?lhs = {y. \<exists>u. setsum u {a, b} = 1 \<and> (\<Sum>v\<in>{a, b}. u v *\<^sub>R v) = y}"
  18.583 +  have "?lhs = {y. \<exists>u. sum u {a, b} = 1 \<and> (\<Sum>v\<in>{a, b}. u v *\<^sub>R v) = y}"
  18.584      using affine_hull_finite[of "{a,b}"] by auto
  18.585    also have "\<dots> = {y. \<exists>v u. u b = 1 - v \<and> u b *\<^sub>R b = y - v *\<^sub>R a}"
  18.586      by (simp add: affine_hull_finite_step(2)[of "{b}" a])
  18.587 @@ -1797,7 +1797,7 @@
  18.588    apply (erule conjE)+
  18.589  proof -
  18.590    fix x t u
  18.591 -  assume as: "finite t" "t \<noteq> {}" "t \<subseteq> insert a s" "setsum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = x"
  18.592 +  assume as: "finite t" "t \<noteq> {}" "t \<subseteq> insert a s" "sum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = x"
  18.593    have "(\<lambda>x. x - a) ` (t - {a}) \<subseteq> {x - a |x. x \<in> s}"
  18.594      using as(3) by auto
  18.595    then show "\<exists>v. x = a + v \<and> (\<exists>S u. finite S \<and> S \<subseteq> {x - a |x. x \<in> s} \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = v)"
  18.596 @@ -1808,8 +1808,8 @@
  18.597      apply (rule conjI) using as(1) apply simp
  18.598      apply (erule conjI)
  18.599      using as(1)
  18.600 -    apply (simp add: setsum.reindex[unfolded inj_on_def] scaleR_right_diff_distrib
  18.601 -      setsum_subtractf scaleR_left.setsum[symmetric] setsum_diff1 scaleR_left_diff_distrib)
  18.602 +    apply (simp add: sum.reindex[unfolded inj_on_def] scaleR_right_diff_distrib
  18.603 +      sum_subtractf scaleR_left.sum[symmetric] sum_diff1 scaleR_left_diff_distrib)
  18.604      unfolding as
  18.605      apply simp
  18.606      done
  18.607 @@ -1828,16 +1828,16 @@
  18.608      unfolding span_explicit by auto
  18.609    define f where "f = (\<lambda>x. x + a) ` t"
  18.610    have f: "finite f" "f \<subseteq> s" "(\<Sum>v\<in>f. u (v - a) *\<^sub>R (v - a)) = y - a"
  18.611 -    unfolding f_def using obt by (auto simp add: setsum.reindex[unfolded inj_on_def])
  18.612 +    unfolding f_def using obt by (auto simp add: sum.reindex[unfolded inj_on_def])
  18.613    have *: "f \<inter> {a} = {}" "f \<inter> - {a} = f"
  18.614      using f(2) assms by auto
  18.615 -  show "\<exists>sa u. finite sa \<and> sa \<noteq> {} \<and> sa \<subseteq> insert a s \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y"
  18.616 +  show "\<exists>sa u. finite sa \<and> sa \<noteq> {} \<and> sa \<subseteq> insert a s \<and> sum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y"
  18.617      apply (rule_tac x = "insert a f" in exI)
  18.618 -    apply (rule_tac x = "\<lambda>x. if x=a then 1 - setsum (\<lambda>x. u (x - a)) f else u (x - a)" in exI)
  18.619 +    apply (rule_tac x = "\<lambda>x. if x=a then 1 - sum (\<lambda>x. u (x - a)) f else u (x - a)" in exI)
  18.620      using assms and f
  18.621 -    unfolding setsum_clauses(2)[OF f(1)] and if_smult
  18.622 -    unfolding setsum.If_cases[OF f(1), of "\<lambda>x. x = a"]
  18.623 -    apply (auto simp add: setsum_subtractf scaleR_left.setsum algebra_simps *)
  18.624 +    unfolding sum_clauses(2)[OF f(1)] and if_smult
  18.625 +    unfolding sum.If_cases[OF f(1), of "\<lambda>x. x = a"]
  18.626 +    apply (auto simp add: sum_subtractf scaleR_left.sum algebra_simps *)
  18.627      done
  18.628  qed
  18.629  
  18.630 @@ -2281,8 +2281,8 @@
  18.631  
  18.632  lemma affine_dependent_explicit:
  18.633    "affine_dependent p \<longleftrightarrow>
  18.634 -    (\<exists>s u. finite s \<and> s \<subseteq> p \<and> setsum u s = 0 \<and>
  18.635 -      (\<exists>v\<in>s. u v \<noteq> 0) \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = 0)"
  18.636 +    (\<exists>s u. finite s \<and> s \<subseteq> p \<and> sum u s = 0 \<and>
  18.637 +      (\<exists>v\<in>s. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) s = 0)"
  18.638    unfolding affine_dependent_def affine_hull_explicit mem_Collect_eq
  18.639    apply rule
  18.640    apply (erule bexE, erule exE, erule exE)
  18.641 @@ -2293,25 +2293,25 @@
  18.642    apply (erule bexE)
  18.643  proof -
  18.644    fix x s u
  18.645 -  assume as: "x \<in> p" "finite s" "s \<noteq> {}" "s \<subseteq> p - {x}" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.646 +  assume as: "x \<in> p" "finite s" "s \<noteq> {}" "s \<subseteq> p - {x}" "sum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.647    have "x \<notin> s" using as(1,4) by auto
  18.648 -  show "\<exists>s u. finite s \<and> s \<subseteq> p \<and> setsum u s = 0 \<and> (\<exists>v\<in>s. u v \<noteq> 0) \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
  18.649 +  show "\<exists>s u. finite s \<and> s \<subseteq> p \<and> sum u s = 0 \<and> (\<exists>v\<in>s. u v \<noteq> 0) \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
  18.650      apply (rule_tac x="insert x s" in exI, rule_tac x="\<lambda>v. if v = x then - 1 else u v" in exI)
  18.651 -    unfolding if_smult and setsum_clauses(2)[OF as(2)] and setsum_delta_notmem[OF \<open>x\<notin>s\<close>] and as
  18.652 +    unfolding if_smult and sum_clauses(2)[OF as(2)] and sum_delta_notmem[OF \<open>x\<notin>s\<close>] and as
  18.653      using as
  18.654      apply auto
  18.655      done
  18.656  next
  18.657    fix s u v
  18.658 -  assume as: "finite s" "s \<subseteq> p" "setsum u s = 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0" "v \<in> s" "u v \<noteq> 0"
  18.659 +  assume as: "finite s" "s \<subseteq> p" "sum u s = 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0" "v \<in> s" "u v \<noteq> 0"
  18.660    have "s \<noteq> {v}"
  18.661      using as(3,6) by auto
  18.662 -  then show "\<exists>x\<in>p. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p - {x} \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.663 +  then show "\<exists>x\<in>p. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p - {x} \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.664      apply (rule_tac x=v in bexI)
  18.665      apply (rule_tac x="s - {v}" in exI)
  18.666      apply (rule_tac x="\<lambda>x. - (1 / u v) * u x" in exI)
  18.667 -    unfolding scaleR_scaleR[symmetric] and scaleR_right.setsum [symmetric]
  18.668 -    unfolding setsum_distrib_left[symmetric] and setsum_diff1[OF as(1)]
  18.669 +    unfolding scaleR_scaleR[symmetric] and scaleR_right.sum [symmetric]
  18.670 +    unfolding sum_distrib_left[symmetric] and sum_diff1[OF as(1)]
  18.671      using as
  18.672      apply auto
  18.673      done
  18.674 @@ -2321,24 +2321,24 @@
  18.675    fixes s :: "'a::real_vector set"
  18.676    assumes "finite s"
  18.677    shows "affine_dependent s \<longleftrightarrow>
  18.678 -    (\<exists>u. setsum u s = 0 \<and> (\<exists>v\<in>s. u v \<noteq> 0) \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = 0)"
  18.679 +    (\<exists>u. sum u s = 0 \<and> (\<exists>v\<in>s. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) s = 0)"
  18.680    (is "?lhs = ?rhs")
  18.681  proof
  18.682    have *: "\<And>vt u v. (if vt then u v else 0) *\<^sub>R v = (if vt then (u v) *\<^sub>R v else 0::'a)"
  18.683      by auto
  18.684    assume ?lhs
  18.685    then obtain t u v where
  18.686 -    "finite t" "t \<subseteq> s" "setsum u t = 0" "v\<in>t" "u v \<noteq> 0"  "(\<Sum>v\<in>t. u v *\<^sub>R v) = 0"
  18.687 +    "finite t" "t \<subseteq> s" "sum u t = 0" "v\<in>t" "u v \<noteq> 0"  "(\<Sum>v\<in>t. u v *\<^sub>R v) = 0"
  18.688      unfolding affine_dependent_explicit by auto
  18.689    then show ?rhs
  18.690      apply (rule_tac x="\<lambda>x. if x\<in>t then u x else 0" in exI)
  18.691 -    apply auto unfolding * and setsum.inter_restrict[OF assms, symmetric]
  18.692 +    apply auto unfolding * and sum.inter_restrict[OF assms, symmetric]
  18.693      unfolding Int_absorb1[OF \<open>t\<subseteq>s\<close>]
  18.694      apply auto
  18.695      done
  18.696  next
  18.697    assume ?rhs
  18.698 -  then obtain u v where "setsum u s = 0"  "v\<in>s" "u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
  18.699 +  then obtain u v where "sum u s = 0"  "v\<in>s" "u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
  18.700      by auto
  18.701    then show ?lhs unfolding affine_dependent_explicit
  18.702      using assms by auto
  18.703 @@ -2718,7 +2718,7 @@
  18.704    shows "convex hull s =
  18.705      {y. \<exists>k u x.
  18.706        (\<forall>i\<in>{1::nat .. k}. 0 \<le> u i \<and> x i \<in> s) \<and>
  18.707 -      (setsum u {1..k} = 1) \<and> (setsum (\<lambda>i. u i *\<^sub>R x i) {1..k} = y)}"
  18.708 +      (sum u {1..k} = 1) \<and> (sum (\<lambda>i. u i *\<^sub>R x i) {1..k} = y)}"
  18.709    (is "?xyz = ?hull")
  18.710    apply (rule hull_unique)
  18.711    apply rule
  18.712 @@ -2743,7 +2743,7 @@
  18.713      fix x k u y
  18.714      assume assm:
  18.715        "\<forall>i\<in>{1::nat..k}. 0 \<le> u i \<and> y i \<in> s"
  18.716 -      "setsum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
  18.717 +      "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
  18.718      show "x\<in>t"
  18.719        unfolding assm(3) [symmetric]
  18.720        apply (rule as(2)[unfolded convex, rule_format])
  18.721 @@ -2755,10 +2755,10 @@
  18.722    assume uv: "0 \<le> u" "0 \<le> v" "u + v = (1::real)"
  18.723    assume xy: "x \<in> ?hull" "y \<in> ?hull"
  18.724    from xy obtain k1 u1 x1 where
  18.725 -    x: "\<forall>i\<in>{1::nat..k1}. 0\<le>u1 i \<and> x1 i \<in> s" "setsum u1 {Suc 0..k1} = 1" "(\<Sum>i = Suc 0..k1. u1 i *\<^sub>R x1 i) = x"
  18.726 +    x: "\<forall>i\<in>{1::nat..k1}. 0\<le>u1 i \<and> x1 i \<in> s" "sum u1 {Suc 0..k1} = 1" "(\<Sum>i = Suc 0..k1. u1 i *\<^sub>R x1 i) = x"
  18.727      by auto
  18.728    from xy obtain k2 u2 x2 where
  18.729 -    y: "\<forall>i\<in>{1::nat..k2}. 0\<le>u2 i \<and> x2 i \<in> s" "setsum u2 {Suc 0..k2} = 1" "(\<Sum>i = Suc 0..k2. u2 i *\<^sub>R x2 i) = y"
  18.730 +    y: "\<forall>i\<in>{1::nat..k2}. 0\<le>u2 i \<and> x2 i \<in> s" "sum u2 {Suc 0..k2} = 1" "(\<Sum>i = Suc 0..k2. u2 i *\<^sub>R x2 i) = y"
  18.731      by auto
  18.732    have *: "\<And>P (x1::'a) x2 s1 s2 i.
  18.733      (if P i then s1 else s2) *\<^sub>R (if P i then x1 else x2) = (if P i then s1 *\<^sub>R x1 else s2 *\<^sub>R x2)"
  18.734 @@ -2779,9 +2779,9 @@
  18.735      apply (rule, rule)
  18.736      defer
  18.737      apply rule
  18.738 -    unfolding * and setsum.If_cases[OF finite_atLeastAtMost[of 1 "k1 + k2"]] and
  18.739 -      setsum.reindex[OF inj] and o_def Collect_mem_eq
  18.740 -    unfolding scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] setsum_distrib_left[symmetric]
  18.741 +    unfolding * and sum.If_cases[OF finite_atLeastAtMost[of 1 "k1 + k2"]] and
  18.742 +      sum.reindex[OF inj] and o_def Collect_mem_eq
  18.743 +    unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] sum_distrib_left[symmetric]
  18.744    proof -
  18.745      fix i
  18.746      assume i: "i \<in> {1..k1+k2}"
  18.747 @@ -2807,22 +2807,22 @@
  18.748    fixes s :: "'a::real_vector set"
  18.749    assumes "finite s"
  18.750    shows "convex hull s = {y. \<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and>
  18.751 -    setsum u s = 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y}"
  18.752 +    sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
  18.753    (is "?HULL = ?set")
  18.754  proof (rule hull_unique, auto simp add: convex_def[of ?set])
  18.755    fix x
  18.756    assume "x \<in> s"
  18.757 -  then show "\<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = x"
  18.758 +  then show "\<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = x"
  18.759      apply (rule_tac x="\<lambda>y. if x=y then 1 else 0" in exI)
  18.760      apply auto
  18.761 -    unfolding setsum.delta'[OF assms] and setsum_delta''[OF assms]
  18.762 +    unfolding sum.delta'[OF assms] and sum_delta''[OF assms]
  18.763      apply auto
  18.764      done
  18.765  next
  18.766    fix u v :: real
  18.767    assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
  18.768 -  fix ux assume ux: "\<forall>x\<in>s. 0 \<le> ux x" "setsum ux s = (1::real)"
  18.769 -  fix uy assume uy: "\<forall>x\<in>s. 0 \<le> uy x" "setsum uy s = (1::real)"
  18.770 +  fix ux assume ux: "\<forall>x\<in>s. 0 \<le> ux x" "sum ux s = (1::real)"
  18.771 +  fix uy assume uy: "\<forall>x\<in>s. 0 \<le> uy x" "sum uy s = (1::real)"
  18.772    {
  18.773      fix x
  18.774      assume "x\<in>s"
  18.775 @@ -2832,15 +2832,15 @@
  18.776    }
  18.777    moreover
  18.778    have "(\<Sum>x\<in>s. u * ux x + v * uy x) = 1"
  18.779 -    unfolding setsum.distrib and setsum_distrib_left[symmetric] and ux(2) uy(2)
  18.780 +    unfolding sum.distrib and sum_distrib_left[symmetric] and ux(2) uy(2)
  18.781      using uv(3) by auto
  18.782    moreover
  18.783    have "(\<Sum>x\<in>s. (u * ux x + v * uy x) *\<^sub>R x) = u *\<^sub>R (\<Sum>x\<in>s. ux x *\<^sub>R x) + v *\<^sub>R (\<Sum>x\<in>s. uy x *\<^sub>R x)"
  18.784 -    unfolding scaleR_left_distrib and setsum.distrib and scaleR_scaleR[symmetric]
  18.785 -      and scaleR_right.setsum [symmetric]
  18.786 +    unfolding scaleR_left_distrib and sum.distrib and scaleR_scaleR[symmetric]
  18.787 +      and scaleR_right.sum [symmetric]
  18.788      by auto
  18.789    ultimately
  18.790 -  show "\<exists>uc. (\<forall>x\<in>s. 0 \<le> uc x) \<and> setsum uc s = 1 \<and>
  18.791 +  show "\<exists>uc. (\<forall>x\<in>s. 0 \<le> uc x) \<and> sum uc s = 1 \<and>
  18.792        (\<Sum>x\<in>s. uc x *\<^sub>R x) = u *\<^sub>R (\<Sum>x\<in>s. ux x *\<^sub>R x) + v *\<^sub>R (\<Sum>x\<in>s. uy x *\<^sub>R x)"
  18.793      apply (rule_tac x="\<lambda>x. u * ux x + v * uy x" in exI)
  18.794      apply auto
  18.795 @@ -2849,7 +2849,7 @@
  18.796    fix t
  18.797    assume t: "s \<subseteq> t" "convex t"
  18.798    fix u
  18.799 -  assume u: "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = (1::real)"
  18.800 +  assume u: "\<forall>x\<in>s. 0 \<le> u x" "sum u s = (1::real)"
  18.801    then show "(\<Sum>x\<in>s. u x *\<^sub>R x) \<in> t"
  18.802      using t(2)[unfolded convex_explicit, THEN spec[where x=s], THEN spec[where x=u]]
  18.803      using assms and t(1) by auto
  18.804 @@ -2861,14 +2861,14 @@
  18.805  lemma convex_hull_explicit:
  18.806    fixes p :: "'a::real_vector set"
  18.807    shows "convex hull p =
  18.808 -    {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = y}"
  18.809 +    {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
  18.810    (is "?lhs = ?rhs")
  18.811  proof -
  18.812    {
  18.813      fix x
  18.814      assume "x\<in>?lhs"
  18.815      then obtain k u y where
  18.816 -        obt: "\<forall>i\<in>{1::nat..k}. 0 \<le> u i \<and> y i \<in> p" "setsum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
  18.817 +        obt: "\<forall>i\<in>{1::nat..k}. 0 \<le> u i \<and> y i \<in> p" "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
  18.818        unfolding convex_hull_indexed by auto
  18.819  
  18.820      have fin: "finite {1..k}" by auto
  18.821 @@ -2876,24 +2876,24 @@
  18.822      {
  18.823        fix j
  18.824        assume "j\<in>{1..k}"
  18.825 -      then have "y j \<in> p" "0 \<le> setsum u {i. Suc 0 \<le> i \<and> i \<le> k \<and> y i = y j}"
  18.826 +      then have "y j \<in> p" "0 \<le> sum u {i. Suc 0 \<le> i \<and> i \<le> k \<and> y i = y j}"
  18.827          using obt(1)[THEN bspec[where x=j]] and obt(2)
  18.828          apply simp
  18.829 -        apply (rule setsum_nonneg)
  18.830 +        apply (rule sum_nonneg)
  18.831          using obt(1)
  18.832          apply auto
  18.833          done
  18.834      }
  18.835      moreover
  18.836 -    have "(\<Sum>v\<in>y ` {1..k}. setsum u {i \<in> {1..k}. y i = v}) = 1"
  18.837 -      unfolding setsum_image_gen[OF fin, symmetric] using obt(2) by auto
  18.838 -    moreover have "(\<Sum>v\<in>y ` {1..k}. setsum u {i \<in> {1..k}. y i = v} *\<^sub>R v) = x"
  18.839 -      using setsum_image_gen[OF fin, of "\<lambda>i. u i *\<^sub>R y i" y, symmetric]
  18.840 -      unfolding scaleR_left.setsum using obt(3) by auto
  18.841 +    have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v}) = 1"
  18.842 +      unfolding sum_image_gen[OF fin, symmetric] using obt(2) by auto
  18.843 +    moreover have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v} *\<^sub>R v) = x"
  18.844 +      using sum_image_gen[OF fin, of "\<lambda>i. u i *\<^sub>R y i" y, symmetric]
  18.845 +      unfolding scaleR_left.sum using obt(3) by auto
  18.846      ultimately
  18.847 -    have "\<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.848 +    have "\<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
  18.849        apply (rule_tac x="y ` {1..k}" in exI)
  18.850 -      apply (rule_tac x="\<lambda>v. setsum u {i\<in>{1..k}. y i = v}" in exI)
  18.851 +      apply (rule_tac x="\<lambda>v. sum u {i\<in>{1..k}. y i = v}" in exI)
  18.852        apply auto
  18.853        done
  18.854      then have "x\<in>?rhs" by auto
  18.855 @@ -2903,7 +2903,7 @@
  18.856      fix y
  18.857      assume "y\<in>?rhs"
  18.858      then obtain s u where
  18.859 -      obt: "finite s" "s \<subseteq> p" "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = y"
  18.860 +      obt: "finite s" "s \<subseteq> p" "\<forall>x\<in>s. 0 \<le> u x" "sum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = y"
  18.861        by auto
  18.862  
  18.863      obtain f where f: "inj_on f {1..card s}" "f ` {1..card s} = s"
  18.864 @@ -2934,18 +2934,18 @@
  18.865        then have "card {x. Suc 0 \<le> x \<and> x \<le> card s \<and> f x = y} = 1" by auto
  18.866        then have "(\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x)) = u y"
  18.867            "(\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x) *\<^sub>R f x) = u y *\<^sub>R y"
  18.868 -        by (auto simp add: setsum_constant_scaleR)
  18.869 +        by (auto simp add: sum_constant_scaleR)
  18.870      }
  18.871      then have "(\<Sum>x = 1..card s. u (f x)) = 1" "(\<Sum>i = 1..card s. u (f i) *\<^sub>R f i) = y"
  18.872 -      unfolding setsum_image_gen[OF *(1), of "\<lambda>x. u (f x) *\<^sub>R f x" f]
  18.873 -        and setsum_image_gen[OF *(1), of "\<lambda>x. u (f x)" f]
  18.874 +      unfolding sum_image_gen[OF *(1), of "\<lambda>x. u (f x) *\<^sub>R f x" f]
  18.875 +        and sum_image_gen[OF *(1), of "\<lambda>x. u (f x)" f]
  18.876        unfolding f
  18.877 -      using setsum.cong [of s s "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x) *\<^sub>R f x)" "\<lambda>v. u v *\<^sub>R v"]
  18.878 -      using setsum.cong [of s s "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x))" u]
  18.879 +      using sum.cong [of s s "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x) *\<^sub>R f x)" "\<lambda>v. u v *\<^sub>R v"]
  18.880 +      using sum.cong [of s s "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x))" u]
  18.881        unfolding obt(4,5)
  18.882        by auto
  18.883      ultimately
  18.884 -    have "\<exists>k u x. (\<forall>i\<in>{1..k}. 0 \<le> u i \<and> x i \<in> p) \<and> setsum u {1..k} = 1 \<and>
  18.885 +    have "\<exists>k u x. (\<forall>i\<in>{1..k}. 0 \<le> u i \<and> x i \<in> p) \<and> sum u {1..k} = 1 \<and>
  18.886          (\<Sum>i::nat = 1..k. u i *\<^sub>R x i) = y"
  18.887        apply (rule_tac x="card s" in exI)
  18.888        apply (rule_tac x="u \<circ> f" in exI)
  18.889 @@ -2966,8 +2966,8 @@
  18.890    fixes s :: "'a::real_vector set"
  18.891    assumes "finite s"
  18.892    shows
  18.893 -    "(\<exists>u. (\<forall>x\<in>insert a s. 0 \<le> u x) \<and> setsum u (insert a s) = w \<and> setsum (\<lambda>x. u x *\<^sub>R x) (insert a s) = y)
  18.894 -      \<longleftrightarrow> (\<exists>v\<ge>0. \<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = w - v \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y - v *\<^sub>R a)"
  18.895 +    "(\<exists>u. (\<forall>x\<in>insert a s. 0 \<le> u x) \<and> sum u (insert a s) = w \<and> sum (\<lambda>x. u x *\<^sub>R x) (insert a s) = y)
  18.896 +      \<longleftrightarrow> (\<exists>v\<ge>0. \<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = w - v \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y - v *\<^sub>R a)"
  18.897    (is "?lhs = ?rhs")
  18.898  proof (rule, case_tac[!] "a\<in>s")
  18.899    assume "a \<in> s"
  18.900 @@ -2981,7 +2981,7 @@
  18.901  next
  18.902    assume ?lhs
  18.903    then obtain u where
  18.904 -      u: "\<forall>x\<in>insert a s. 0 \<le> u x" "setsum u (insert a s) = w" "(\<Sum>x\<in>insert a s. u x *\<^sub>R x) = y"
  18.905 +      u: "\<forall>x\<in>insert a s. 0 \<le> u x" "sum u (insert a s) = w" "(\<Sum>x\<in>insert a s. u x *\<^sub>R x) = y"
  18.906      by auto
  18.907    assume "a \<notin> s"
  18.908    then show ?rhs
  18.909 @@ -2989,7 +2989,7 @@
  18.910      using u(1)[THEN bspec[where x=a]]
  18.911      apply simp
  18.912      apply (rule_tac x=u in exI)
  18.913 -    using u[unfolded setsum_clauses(2)[OF assms]] and \<open>a\<notin>s\<close>
  18.914 +    using u[unfolded sum_clauses(2)[OF assms]] and \<open>a\<notin>s\<close>
  18.915      apply auto
  18.916      done
  18.917  next
  18.918 @@ -2997,34 +2997,34 @@
  18.919    then have *: "insert a s = s" by auto
  18.920    have fin: "finite (insert a s)" using assms by auto
  18.921    assume ?rhs
  18.922 -  then obtain v u where uv: "v\<ge>0" "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = w - v" "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
  18.923 +  then obtain v u where uv: "v\<ge>0" "\<forall>x\<in>s. 0 \<le> u x" "sum u s = w - v" "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
  18.924      by auto
  18.925    show ?lhs
  18.926      apply (rule_tac x = "\<lambda>x. (if a = x then v else 0) + u x" in exI)
  18.927 -    unfolding scaleR_left_distrib and setsum.distrib and setsum_delta''[OF fin] and setsum.delta'[OF fin]
  18.928 -    unfolding setsum_clauses(2)[OF assms]
  18.929 +    unfolding scaleR_left_distrib and sum.distrib and sum_delta''[OF fin] and sum.delta'[OF fin]
  18.930 +    unfolding sum_clauses(2)[OF assms]
  18.931      using uv and uv(2)[THEN bspec[where x=a]] and \<open>a\<in>s\<close>
  18.932      apply auto
  18.933      done
  18.934  next
  18.935    assume ?rhs
  18.936    then obtain v u where
  18.937 -    uv: "v\<ge>0" "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = w - v" "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
  18.938 +    uv: "v\<ge>0" "\<forall>x\<in>s. 0 \<le> u x" "sum u s = w - v" "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
  18.939      by auto
  18.940    moreover
  18.941    assume "a \<notin> s"
  18.942    moreover
  18.943 -  have "(\<Sum>x\<in>s. if a = x then v else u x) = setsum u s"
  18.944 +  have "(\<Sum>x\<in>s. if a = x then v else u x) = sum u s"
  18.945      and "(\<Sum>x\<in>s. (if a = x then v else u x) *\<^sub>R x) = (\<Sum>x\<in>s. u x *\<^sub>R x)"
  18.946 -    apply (rule_tac setsum.cong) apply rule
  18.947 +    apply (rule_tac sum.cong) apply rule
  18.948      defer
  18.949 -    apply (rule_tac setsum.cong) apply rule
  18.950 +    apply (rule_tac sum.cong) apply rule
  18.951      using \<open>a \<notin> s\<close>
  18.952      apply auto
  18.953      done
  18.954    ultimately show ?lhs
  18.955      apply (rule_tac x="\<lambda>x. if a = x then v else u x" in exI)
  18.956 -    unfolding setsum_clauses(2)[OF assms]
  18.957 +    unfolding sum_clauses(2)[OF assms]
  18.958      apply auto
  18.959      done
  18.960  qed
  18.961 @@ -3150,12 +3150,12 @@
  18.962    then have "finite (insert a t)" and "insert a t \<subseteq> insert a s"
  18.963      by auto
  18.964    moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x)) = (\<Sum>x\<in>t. Q x)"
  18.965 -    apply (rule setsum.cong)
  18.966 +    apply (rule sum.cong)
  18.967      using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
  18.968      apply auto
  18.969      done
  18.970    have "(\<Sum>x\<in>insert a t. if x = a then - (\<Sum>x\<in>t. u (x - a)) else u (x - a)) = 0"
  18.971 -    unfolding setsum_clauses(2)[OF fin]
  18.972 +    unfolding sum_clauses(2)[OF fin]
  18.973      using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
  18.974      apply auto
  18.975      unfolding *
  18.976 @@ -3168,17 +3168,17 @@
  18.977      apply auto
  18.978      done
  18.979    moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x) *\<^sub>R x) = (\<Sum>x\<in>t. Q x *\<^sub>R x)"
  18.980 -    apply (rule setsum.cong)
  18.981 +    apply (rule sum.cong)
  18.982      using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
  18.983      apply auto
  18.984      done
  18.985    have "(\<Sum>x\<in>t. u (x - a)) *\<^sub>R a = (\<Sum>v\<in>t. u (v - a) *\<^sub>R v)"
  18.986 -    unfolding scaleR_left.setsum
  18.987 -    unfolding t_def and setsum.reindex[OF inj] and o_def
  18.988 +    unfolding scaleR_left.sum
  18.989 +    unfolding t_def and sum.reindex[OF inj] and o_def
  18.990      using obt(5)
  18.991 -    by (auto simp add: setsum.distrib scaleR_right_distrib)
  18.992 +    by (auto simp add: sum.distrib scaleR_right_distrib)
  18.993    then have "(\<Sum>v\<in>insert a t. (if v = a then - (\<Sum>x\<in>t. u (x - a)) else u (v - a)) *\<^sub>R v) = 0"
  18.994 -    unfolding setsum_clauses(2)[OF fin]
  18.995 +    unfolding sum_clauses(2)[OF fin]
  18.996      using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
  18.997      by (auto simp add: *)
  18.998    ultimately show ?thesis
  18.999 @@ -3337,10 +3337,10 @@
 18.1000    assumes "0 \<in> affine hull S"
 18.1001    shows "dependent S"
 18.1002  proof -
 18.1003 -  obtain s u where s_u: "finite s \<and> s \<noteq> {} \<and> s \<subseteq> S \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
 18.1004 +  obtain s u where s_u: "finite s \<and> s \<noteq> {} \<and> s \<subseteq> S \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
 18.1005      using assms affine_hull_explicit[of S] by auto
 18.1006    then have "\<exists>v\<in>s. u v \<noteq> 0"
 18.1007 -    using setsum_not_0[of "u" "s"] by auto
 18.1008 +    using sum_not_0[of "u" "s"] by auto
 18.1009    then have "finite s \<and> s \<subseteq> S \<and> (\<exists>v\<in>s. u v \<noteq> 0 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0)"
 18.1010      using s_u by auto
 18.1011    then show ?thesis
 18.1012 @@ -4131,18 +4131,18 @@
 18.1013    { fix y
 18.1014      assume yt: "y \<in> affine hull t" and yu: "y \<in> affine hull u"
 18.1015      then obtain a b
 18.1016 -           where a1 [simp]: "setsum a t = 1" and [simp]: "setsum (\<lambda>v. a v *\<^sub>R v) t = y"
 18.1017 -             and [simp]: "setsum b u = 1" "setsum (\<lambda>v. b v *\<^sub>R v) u = y"
 18.1018 +           where a1 [simp]: "sum a t = 1" and [simp]: "sum (\<lambda>v. a v *\<^sub>R v) t = y"
 18.1019 +             and [simp]: "sum b u = 1" "sum (\<lambda>v. b v *\<^sub>R v) u = y"
 18.1020        by (auto simp: affine_hull_finite \<open>finite t\<close> \<open>finite u\<close>)
 18.1021      define c where "c x = (if x \<in> t then a x else if x \<in> u then -(b x) else 0)" for x
 18.1022      have [simp]: "s \<inter> t = t" "s \<inter> - t \<inter> u = u" using assms by auto
 18.1023 -    have "setsum c s = 0"
 18.1024 -      by (simp add: c_def comm_monoid_add_class.setsum.If_cases \<open>finite s\<close> setsum_negf)
 18.1025 +    have "sum c s = 0"
 18.1026 +      by (simp add: c_def comm_monoid_add_class.sum.If_cases \<open>finite s\<close> sum_negf)
 18.1027      moreover have "~ (\<forall>v\<in>s. c v = 0)"
 18.1028 -      by (metis (no_types) IntD1 \<open>s \<inter> t = t\<close> a1 c_def setsum_not_0 zero_neq_one)
 18.1029 +      by (metis (no_types) IntD1 \<open>s \<inter> t = t\<close> a1 c_def sum_not_0 zero_neq_one)
 18.1030      moreover have "(\<Sum>v\<in>s. c v *\<^sub>R v) = 0"
 18.1031 -      by (simp add: c_def if_smult setsum_negf
 18.1032 -             comm_monoid_add_class.setsum.If_cases \<open>finite s\<close>)
 18.1033 +      by (simp add: c_def if_smult sum_negf
 18.1034 +             comm_monoid_add_class.sum.If_cases \<open>finite s\<close>)
 18.1035      ultimately have False
 18.1036        using assms \<open>finite s\<close> by (auto simp: affine_dependent_explicit)
 18.1037    }
 18.1038 @@ -4220,13 +4220,13 @@
 18.1039    fixes p :: "('a::euclidean_space) set"
 18.1040    shows "convex hull p =
 18.1041      {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> aff_dim p + 1 \<and>
 18.1042 -      (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = y}"
 18.1043 +      (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
 18.1044    unfolding convex_hull_explicit set_eq_iff mem_Collect_eq
 18.1045  proof (intro allI iffI)
 18.1046    fix y
 18.1047    let ?P = "\<lambda>n. \<exists>s u. finite s \<and> card s = n \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and>
 18.1048 -    setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
 18.1049 -  assume "\<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
 18.1050 +    sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
 18.1051 +  assume "\<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
 18.1052    then obtain N where "?P N" by auto
 18.1053    then have "\<exists>n\<le>N. (\<forall>k<n. \<not> ?P k) \<and> ?P n"
 18.1054      apply (rule_tac ex_least_nat_le)
 18.1055 @@ -4235,7 +4235,7 @@
 18.1056    then obtain n where "?P n" and smallest: "\<forall>k<n. \<not> ?P k"
 18.1057      by blast
 18.1058    then obtain s u where obt: "finite s" "card s = n" "s\<subseteq>p" "\<forall>x\<in>s. 0 \<le> u x"
 18.1059 -    "setsum u s = 1"  "(\<Sum>v\<in>s. u v *\<^sub>R v) = y" by auto
 18.1060 +    "sum u s = 1"  "(\<Sum>v\<in>s. u v *\<^sub>R v) = y" by auto
 18.1061  
 18.1062    have "card s \<le> aff_dim p + 1"
 18.1063    proof (rule ccontr, simp only: not_le)
 18.1064 @@ -4243,19 +4243,19 @@
 18.1065      then have "affine_dependent s"
 18.1066        using affine_dependent_biggerset[OF obt(1)] independent_card_le_aff_dim not_less obt(3)
 18.1067        by blast
 18.1068 -    then obtain w v where wv: "setsum w s = 0" "v\<in>s" "w v \<noteq> 0" "(\<Sum>v\<in>s. w v *\<^sub>R v) = 0"
 18.1069 +    then obtain w v where wv: "sum w s = 0" "v\<in>s" "w v \<noteq> 0" "(\<Sum>v\<in>s. w v *\<^sub>R v) = 0"
 18.1070        using affine_dependent_explicit_finite[OF obt(1)] by auto
 18.1071      define i where "i = (\<lambda>v. (u v) / (- w v)) ` {v\<in>s. w v < 0}"
 18.1072      define t where "t = Min i"
 18.1073      have "\<exists>x\<in>s. w x < 0"
 18.1074      proof (rule ccontr, simp add: not_less)
 18.1075        assume as:"\<forall>x\<in>s. 0 \<le> w x"
 18.1076 -      then have "setsum w (s - {v}) \<ge> 0"
 18.1077 -        apply (rule_tac setsum_nonneg)
 18.1078 +      then have "sum w (s - {v}) \<ge> 0"
 18.1079 +        apply (rule_tac sum_nonneg)
 18.1080          apply auto
 18.1081          done
 18.1082 -      then have "setsum w s > 0"
 18.1083 -        unfolding setsum.remove[OF obt(1) \<open>v\<in>s\<close>]
 18.1084 +      then have "sum w s > 0"
 18.1085 +        unfolding sum.remove[OF obt(1) \<open>v\<in>s\<close>]
 18.1086          using as[THEN bspec[where x=v]]  \<open>v\<in>s\<close>  \<open>w v \<noteq> 0\<close> by auto
 18.1087        then show False using wv(1) by auto
 18.1088      qed
 18.1089 @@ -4291,12 +4291,12 @@
 18.1090      obtain a where "a \<in> s" and "t = (\<lambda>v. (u v) / (- w v)) a" and "w a < 0"
 18.1091        using Min_in[OF _ \<open>i\<noteq>{}\<close>] and obt(1) unfolding i_def t_def by auto
 18.1092      then have a: "a \<in> s" "u a + t * w a = 0" by auto
 18.1093 -    have *: "\<And>f. setsum f (s - {a}) = setsum f s - ((f a)::'b::ab_group_add)"
 18.1094 -      unfolding setsum.remove[OF obt(1) \<open>a\<in>s\<close>] by auto
 18.1095 +    have *: "\<And>f. sum f (s - {a}) = sum f s - ((f a)::'b::ab_group_add)"
 18.1096 +      unfolding sum.remove[OF obt(1) \<open>a\<in>s\<close>] by auto
 18.1097      have "(\<Sum>v\<in>s. u v + t * w v) = 1"
 18.1098 -      unfolding setsum.distrib wv(1) setsum_distrib_left[symmetric] obt(5) by auto
 18.1099 +      unfolding sum.distrib wv(1) sum_distrib_left[symmetric] obt(5) by auto
 18.1100      moreover have "(\<Sum>v\<in>s. u v *\<^sub>R v + (t * w v) *\<^sub>R v) - (u a *\<^sub>R a + (t * w a) *\<^sub>R a) = y"
 18.1101 -      unfolding setsum.distrib obt(6) scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] wv(4)
 18.1102 +      unfolding sum.distrib obt(6) scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] wv(4)
 18.1103        using a(2) [THEN eq_neg_iff_add_eq_0 [THEN iffD2]] by simp
 18.1104      ultimately have "?P (n - 1)"
 18.1105        apply (rule_tac x="(s - {a})" in exI)
 18.1106 @@ -4308,7 +4308,7 @@
 18.1107        using smallest[THEN spec[where x="n - 1"]] by auto
 18.1108    qed
 18.1109    then show "\<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> aff_dim p + 1 \<and>
 18.1110 -      (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
 18.1111 +      (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
 18.1112      using obt by auto
 18.1113  qed auto
 18.1114  
 18.1115 @@ -4332,7 +4332,7 @@
 18.1116    fixes p :: "('a::euclidean_space) set"
 18.1117    shows "convex hull p =
 18.1118              {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and>
 18.1119 -              (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = y}"
 18.1120 +              (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
 18.1121          (is "?lhs = ?rhs")
 18.1122  proof (intro set_eqI iffI)
 18.1123    fix x
 18.1124 @@ -4356,7 +4356,7 @@
 18.1125    fix x
 18.1126    assume "x \<in> convex hull p"
 18.1127    then obtain s u where "finite s" "s \<subseteq> p" "card s \<le> DIM('a) + 1"
 18.1128 -    "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
 18.1129 +    "\<forall>x\<in>s. 0 \<le> u x" "sum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
 18.1130      unfolding convex_hull_caratheodory by auto
 18.1131    then show "\<exists>s. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s"
 18.1132      apply (rule_tac x=s in exI)
 18.1133 @@ -5071,8 +5071,8 @@
 18.1134    unfolding mem_Collect_eq ball_simps(8)
 18.1135  proof (rule, rule)
 18.1136    fix a
 18.1137 -  assume "\<exists>sa u. finite sa \<and> sa \<subseteq> s \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = a"
 18.1138 -  then obtain t u where obt: "finite t" "t\<subseteq>s" "\<forall>x\<in>t. 0 \<le> u x" "setsum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = a"
 18.1139 +  assume "\<exists>sa u. finite sa \<and> sa \<subseteq> s \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> sum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = a"
 18.1140 +  then obtain t u where obt: "finite t" "t\<subseteq>s" "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = a"
 18.1141      by auto
 18.1142  
 18.1143    from assms[unfolded open_contains_cball] obtain b
 18.1144 @@ -5083,7 +5083,7 @@
 18.1145    define i where "i = b ` t"
 18.1146  
 18.1147    show "\<exists>e > 0.
 18.1148 -    cball a e \<subseteq> {y. \<exists>sa u. finite sa \<and> sa \<subseteq> s \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y}"
 18.1149 +    cball a e \<subseteq> {y. \<exists>sa u. finite sa \<and> sa \<subseteq> s \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> sum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y}"
 18.1150      apply (rule_tac x = "Min i" in exI)
 18.1151      unfolding subset_eq
 18.1152      apply rule
 18.1153 @@ -5125,12 +5125,12 @@
 18.1154      have *: "inj_on (\<lambda>v. v + (y - a)) t"
 18.1155        unfolding inj_on_def by auto
 18.1156      have "(\<Sum>v\<in>(\<lambda>v. v + (y - a)) ` t. u (v - (y - a))) = 1"
 18.1157 -      unfolding setsum.reindex[OF *] o_def using obt(4) by auto
 18.1158 +      unfolding sum.reindex[OF *] o_def using obt(4) by auto
 18.1159      moreover have "(\<Sum>v\<in>(\<lambda>v. v + (y - a)) ` t. u (v - (y - a)) *\<^sub>R v) = y"
 18.1160 -      unfolding setsum.reindex[OF *] o_def using obt(4,5)
 18.1161 -      by (simp add: setsum.distrib setsum_subtractf scaleR_left.setsum[symmetric] scaleR_right_distrib)
 18.1162 +      unfolding sum.reindex[OF *] o_def using obt(4,5)
 18.1163 +      by (simp add: sum.distrib sum_subtractf scaleR_left.sum[symmetric] scaleR_right_distrib)
 18.1164      ultimately
 18.1165 -    show "\<exists>sa u. finite sa \<and> (\<forall>x\<in>sa. x \<in> s) \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y"
 18.1166 +    show "\<exists>sa u. finite sa \<and> (\<forall>x\<in>sa. x \<in> s) \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> sum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y"
 18.1167        apply (rule_tac x="(\<lambda>v. v + (y - a)) ` t" in exI)
 18.1168        apply (rule_tac x="\<lambda>v. u (v - (y - a))" in exI)
 18.1169        using obt(1, 3)
 18.1170 @@ -6167,44 +6167,44 @@
 18.1171  
 18.1172  lemma radon_ex_lemma:
 18.1173    assumes "finite c" "affine_dependent c"
 18.1174 -  shows "\<exists>u. setsum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> setsum (\<lambda>v. u v *\<^sub>R v) c = 0"
 18.1175 +  shows "\<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) c = 0"
 18.1176  proof -
 18.1177    from assms(2)[unfolded affine_dependent_explicit]
 18.1178    obtain s u where
 18.1179 -      "finite s" "s \<subseteq> c" "setsum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
 18.1180 +      "finite s" "s \<subseteq> c" "sum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
 18.1181      by blast
 18.1182    then show ?thesis
 18.1183      apply (rule_tac x="\<lambda>v. if v\<in>s then u v else 0" in exI)
 18.1184 -    unfolding if_smult scaleR_zero_left and setsum.inter_restrict[OF assms(1), symmetric]
 18.1185 +    unfolding if_smult scaleR_zero_left and sum.inter_restrict[OF assms(1), symmetric]
 18.1186      apply (auto simp add: Int_absorb1)
 18.1187      done
 18.1188  qed
 18.1189  
 18.1190  lemma radon_s_lemma:
 18.1191    assumes "finite s"
 18.1192 -    and "setsum f s = (0::real)"
 18.1193 -  shows "setsum f {x\<in>s. 0 < f x} = - setsum f {x\<in>s. f x < 0}"
 18.1194 +    and "sum f s = (0::real)"
 18.1195 +  shows "sum f {x\<in>s. 0 < f x} = - sum f {x\<in>s. f x < 0}"
 18.1196  proof -
 18.1197    have *: "\<And>x. (if f x < 0 then f x else 0) + (if 0 < f x then f x else 0) = f x"
 18.1198      by auto
 18.1199    show ?thesis
 18.1200 -    unfolding add_eq_0_iff[symmetric] and setsum.inter_filter[OF assms(1)]
 18.1201 -      and setsum.distrib[symmetric] and *
 18.1202 +    unfolding add_eq_0_iff[symmetric] and sum.inter_filter[OF assms(1)]
 18.1203 +      and sum.distrib[symmetric] and *
 18.1204      using assms(2)
 18.1205      by assumption
 18.1206  qed
 18.1207  
 18.1208  lemma radon_v_lemma:
 18.1209    assumes "finite s"
 18.1210 -    and "setsum f s = 0"
 18.1211 +    and "sum f s = 0"
 18.1212      and "\<forall>x. g x = (0::real) \<longrightarrow> f x = (0::'a::euclidean_space)"
 18.1213 -  shows "(setsum f {x\<in>s. 0 < g x}) = - setsum f {x\<in>s. g x < 0}"
 18.1214 +  shows "(sum f {x\<in>s. 0 < g x}) = - sum f {x\<in>s. g x < 0}"
 18.1215  proof -
 18.1216    have *: "\<And>x. (if 0 < g x then f x else 0) + (if g x < 0 then f x else 0) = f x"
 18.1217      using assms(3) by auto
 18.1218    show ?thesis
 18.1219 -    unfolding eq_neg_iff_add_eq_0 and setsum.inter_filter[OF assms(1)]
 18.1220 -      and setsum.distrib[symmetric] and *
 18.1221 +    unfolding eq_neg_iff_add_eq_0 and sum.inter_filter[OF assms(1)]
 18.1222 +      and sum.distrib[symmetric] and *
 18.1223      using assms(2)
 18.1224      apply assumption
 18.1225      done
 18.1226 @@ -6214,12 +6214,12 @@
 18.1227    assumes "finite c" "affine_dependent c"
 18.1228    shows "\<exists>m p. m \<inter> p = {} \<and> m \<union> p = c \<and> (convex hull m) \<inter> (convex hull p) \<noteq> {}"
 18.1229  proof -
 18.1230 -  obtain u v where uv: "setsum u c = 0" "v\<in>c" "u v \<noteq> 0"  "(\<Sum>v\<in>c. u v *\<^sub>R v) = 0"
 18.1231 +  obtain u v where uv: "sum u c = 0" "v\<in>c" "u v \<noteq> 0"  "(\<Sum>v\<in>c. u v *\<^sub>R v) = 0"
 18.1232      using radon_ex_lemma[OF assms] by auto
 18.1233    have fin: "finite {x \<in> c. 0 < u x}" "finite {x \<in> c. 0 > u x}"
 18.1234      using assms(1) by auto
 18.1235 -  define z  where "z = inverse (setsum u {x\<in>c. u x > 0}) *\<^sub>R setsum (\<lambda>x. u x *\<^sub>R x) {x\<in>c. u x > 0}"
 18.1236 -  have "setsum u {x \<in> c. 0 < u x} \<noteq> 0"
 18.1237 +  define z  where "z = inverse (sum u {x\<in>c. u x > 0}) *\<^sub>R sum (\<lambda>x. u x *\<^sub>R x) {x\<in>c. u x > 0}"
 18.1238 +  have "sum u {x \<in> c. 0 < u x} \<noteq> 0"
 18.1239    proof (cases "u v \<ge> 0")
 18.1240      case False
 18.1241      then have "u v < 0" by auto
 18.1242 @@ -6227,36 +6227,36 @@
 18.1243      proof (cases "\<exists>w\<in>{x \<in> c. 0 < u x}. u w > 0")
 18.1244        case True
 18.1245        then show ?thesis
 18.1246 -        using setsum_nonneg_eq_0_iff[of _ u, OF fin(1)] by auto
 18.1247 +        using sum_nonneg_eq_0_iff[of _ u, OF fin(1)] by auto
 18.1248      next
 18.1249        case False
 18.1250 -      then have "setsum u c \<le> setsum (\<lambda>x. if x=v then u v else 0) c"
 18.1251 -        apply (rule_tac setsum_mono)
 18.1252 +      then have "sum u c \<le> sum (\<lambda>x. if x=v then u v else 0) c"
 18.1253 +        apply (rule_tac sum_mono)
 18.1254          apply auto
 18.1255          done
 18.1256        then show ?thesis
 18.1257 -        unfolding setsum.delta[OF assms(1)] using uv(2) and \<open>u v < 0\<close> and uv(1) by auto
 18.1258 +        unfolding sum.delta[OF assms(1)] using uv(2) and \<open>u v < 0\<close> and uv(1) by auto
 18.1259      qed
 18.1260 -  qed (insert setsum_nonneg_eq_0_iff[of _ u, OF fin(1)] uv(2-3), auto)
 18.1261 -
 18.1262 -  then have *: "setsum u {x\<in>c. u x > 0} > 0"
 18.1263 +  qed (insert sum_nonneg_eq_0_iff[of _ u, OF fin(1)] uv(2-3), auto)
 18.1264 +
 18.1265 +  then have *: "sum u {x\<in>c. u x > 0} > 0"
 18.1266      unfolding less_le
 18.1267      apply (rule_tac conjI)
 18.1268 -    apply (rule_tac setsum_nonneg)
 18.1269 -    apply auto
 18.1270 -    done
 18.1271 -  moreover have "setsum u ({x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}) = setsum u c"
 18.1272 +    apply (rule_tac sum_nonneg)
 18.1273 +    apply auto
 18.1274 +    done
 18.1275 +  moreover have "sum u ({x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}) = sum u c"
 18.1276      "(\<Sum>x\<in>{x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}. u x *\<^sub>R x) = (\<Sum>x\<in>c. u x *\<^sub>R x)"
 18.1277      using assms(1)
 18.1278 -    apply (rule_tac[!] setsum.mono_neutral_left)
 18.1279 -    apply auto
 18.1280 -    done
 18.1281 -  then have "setsum u {x \<in> c. 0 < u x} = - setsum u {x \<in> c. 0 > u x}"
 18.1282 +    apply (rule_tac[!] sum.mono_neutral_left)
 18.1283 +    apply auto
 18.1284 +    done
 18.1285 +  then have "sum u {x \<in> c. 0 < u x} = - sum u {x \<in> c. 0 > u x}"
 18.1286      "(\<Sum>x\<in>{x \<in> c. 0 < u x}. u x *\<^sub>R x) = - (\<Sum>x\<in>{x \<in> c. 0 > u x}. u x *\<^sub>R x)"
 18.1287      unfolding eq_neg_iff_add_eq_0
 18.1288      using uv(1,4)
 18.1289 -    by (auto simp add: setsum.union_inter_neutral[OF fin, symmetric])
 18.1290 -  moreover have "\<forall>x\<in>{v \<in> c. u v < 0}. 0 \<le> inverse (setsum u {x \<in> c. 0 < u x}) * - u x"
 18.1291 +    by (auto simp add: sum.union_inter_neutral[OF fin, symmetric])
 18.1292 +  moreover have "\<forall>x\<in>{v \<in> c. u v < 0}. 0 \<le> inverse (sum u {x \<in> c. 0 < u x}) * - u x"
 18.1293      apply rule
 18.1294      apply (rule mult_nonneg_nonneg)
 18.1295      using *
 18.1296 @@ -6265,11 +6265,11 @@
 18.1297    ultimately have "z \<in> convex hull {v \<in> c. u v \<le> 0}"
 18.1298      unfolding convex_hull_explicit mem_Collect_eq
 18.1299      apply (rule_tac x="{v \<in> c. u v < 0}" in exI)
 18.1300 -    apply (rule_tac x="\<lambda>y. inverse (setsum u {x\<in>c. u x > 0}) * - u y" in exI)
 18.1301 -    using assms(1) unfolding scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] and z_def
 18.1302 -    apply (auto simp add: setsum_negf setsum_distrib_left[symmetric])
 18.1303 -    done
 18.1304 -  moreover have "\<forall>x\<in>{v \<in> c. 0 < u v}. 0 \<le> inverse (setsum u {x \<in> c. 0 < u x}) * u x"
 18.1305 +    apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>c. u x > 0}) * - u y" in exI)
 18.1306 +    using assms(1) unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] and z_def
 18.1307 +    apply (auto simp add: sum_negf sum_distrib_left[symmetric])
 18.1308 +    done
 18.1309 +  moreover have "\<forall>x\<in>{v \<in> c. 0 < u v}. 0 \<le> inverse (sum u {x \<in> c. 0 < u x}) * u x"
 18.1310      apply rule
 18.1311      apply (rule mult_nonneg_nonneg)
 18.1312      using *
 18.1313 @@ -6278,11 +6278,11 @@
 18.1314    then have "z \<in> convex hull {v \<in> c. u v > 0}"
 18.1315      unfolding convex_hull_explicit mem_Collect_eq
 18.1316      apply (rule_tac x="{v \<in> c. 0 < u v}" in exI)
 18.1317 -    apply (rule_tac x="\<lambda>y. inverse (setsum u {x\<in>c. u x > 0}) * u y" in exI)
 18.1318 +    apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>c. u x > 0}) * u y" in exI)
 18.1319      using assms(1)
 18.1320 -    unfolding scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] and z_def
 18.1321 +    unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] and z_def
 18.1322      using *
 18.1323 -    apply (auto simp add: setsum_negf setsum_distrib_left[symmetric])
 18.1324 +    apply (auto simp add: sum_negf sum_distrib_left[symmetric])
 18.1325      done
 18.1326    ultimately show ?thesis
 18.1327      apply (rule_tac x="{v\<in>c. u v \<le> 0}" in exI)
 18.1328 @@ -6297,7 +6297,7 @@
 18.1329  proof -
 18.1330    from assms[unfolded affine_dependent_explicit]
 18.1331    obtain s u where
 18.1332 -      "finite s" "s \<subseteq> c" "setsum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
 18.1333 +      "finite s" "s \<subseteq> c" "sum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
 18.1334      by blast
 18.1335    then have *: "finite s" "affine_dependent s" and s: "s \<subseteq> c"
 18.1336      unfolding affine_dependent_explicit by auto
 18.1337 @@ -6460,10 +6460,10 @@
 18.1338  lemma convex_on:
 18.1339    assumes "convex s"
 18.1340    shows "convex_on s f \<longleftrightarrow>
 18.1341 -    (\<forall>k u x. (\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> x i \<in> s) \<and> setsum u {1..k} = 1 \<longrightarrow>
 18.1342 -      f (setsum (\<lambda>i. u i *\<^sub>R x i) {1..k} ) \<le> setsum (\<lambda>i. u i * f(x i)) {1..k})"
 18.1343 +    (\<forall>k u x. (\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> x i \<in> s) \<and> sum u {1..k} = 1 \<longrightarrow>
 18.1344 +      f (sum (\<lambda>i. u i *\<^sub>R x i) {1..k} ) \<le> sum (\<lambda>i. u i * f(x i)) {1..k})"
 18.1345    unfolding convex_epigraph_convex[OF assms] convex epigraph_def Ball_def mem_Collect_eq
 18.1346 -  unfolding fst_setsum snd_setsum fst_scaleR snd_scaleR
 18.1347 +  unfolding fst_sum snd_sum fst_scaleR snd_scaleR
 18.1348    apply safe
 18.1349    apply (drule_tac x=k in spec)
 18.1350    apply (drule_tac x=u in spec)
 18.1351 @@ -6473,7 +6473,7 @@
 18.1352    apply simp
 18.1353    apply (rule_tac y="\<Sum>i = 1..k. u i * f (fst (x i))" in order_trans)
 18.1354    defer
 18.1355 -  apply (rule setsum_mono)
 18.1356 +  apply (rule sum_mono)
 18.1357    apply (erule_tac x=i in allE)
 18.1358    unfolding real_scaleR_def
 18.1359    apply (rule mult_left_mono)
 18.1360 @@ -6692,11 +6692,11 @@
 18.1361    fix x
 18.1362    assume "x \<in> convex hull s"
 18.1363    then obtain k u v where
 18.1364 -    obt: "\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> v i \<in> s" "setsum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R v i) = x"
 18.1365 +    obt: "\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> v i \<in> s" "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R v i) = x"
 18.1366      unfolding convex_hull_indexed mem_Collect_eq by auto
 18.1367    have "(\<Sum>i = 1..k. u i * f (v i)) \<le> b"
 18.1368 -    using setsum_mono[of "{1..k}" "\<lambda>i. u i * f (v i)" "\<lambda>i. u i * b"]
 18.1369 -    unfolding setsum_distrib_right[symmetric] obt(2) mult_1
 18.1370 +    using sum_mono[of "{1..k}" "\<lambda>i. u i * f (v i)" "\<lambda>i. u i * b"]
 18.1371 +    unfolding sum_distrib_right[symmetric] obt(2) mult_1
 18.1372      apply (drule_tac meta_mp)
 18.1373      apply (rule mult_left_mono)
 18.1374      using assms(2) obt(1)
 18.1375 @@ -6709,8 +6709,8 @@
 18.1376      by auto
 18.1377  qed
 18.1378  
 18.1379 -lemma inner_setsum_Basis[simp]: "i \<in> Basis \<Longrightarrow> (\<Sum>Basis) \<bullet> i = 1"
 18.1380 -  by (simp add: inner_setsum_left setsum.If_cases inner_Basis)
 18.1381 +lemma inner_sum_Basis[simp]: "i \<in> Basis \<Longrightarrow> (\<Sum>Basis) \<bullet> i = 1"
 18.1382 +  by (simp add: inner_sum_left sum.If_cases inner_Basis)
 18.1383  
 18.1384  lemma convex_set_plus:
 18.1385    assumes "convex s" and "convex t" shows "convex (s + t)"
 18.1386 @@ -6722,7 +6722,7 @@
 18.1387    finally show "convex (s + t)" .
 18.1388  qed
 18.1389  
 18.1390 -lemma convex_set_setsum:
 18.1391 +lemma convex_set_sum:
 18.1392    assumes "\<And>i. i \<in> A \<Longrightarrow> convex (B i)"
 18.1393    shows "convex (\<Sum>i\<in>A. B i)"
 18.1394  proof (cases "finite A")
 18.1395 @@ -6730,11 +6730,11 @@
 18.1396      by induct (auto simp: convex_set_plus)
 18.1397  qed auto
 18.1398  
 18.1399 -lemma finite_set_setsum:
 18.1400 +lemma finite_set_sum:
 18.1401    assumes "finite A" and "\<forall>i\<in>A. finite (B i)" shows "finite (\<Sum>i\<in>A. B i)"
 18.1402    using assms by (induct set: finite, simp, simp add: finite_set_plus)
 18.1403  
 18.1404 -lemma set_setsum_eq:
 18.1405 +lemma set_sum_eq:
 18.1406    "finite A \<Longrightarrow> (\<Sum>i\<in>A. B i) = {\<Sum>i\<in>A. f i |f. \<forall>i\<in>A. f i \<in> B i}"
 18.1407    apply (induct set: finite)
 18.1408    apply simp
 18.1409 @@ -6743,24 +6743,24 @@
 18.1410    apply (rule_tac x="fun_upd f x a" in exI)
 18.1411    apply simp
 18.1412    apply (rule_tac f="\<lambda>x. a + x" in arg_cong)
 18.1413 -  apply (rule setsum.cong [OF refl])
 18.1414 +  apply (rule sum.cong [OF refl])
 18.1415    apply clarsimp
 18.1416    apply fast
 18.1417    done
 18.1418  
 18.1419 -lemma box_eq_set_setsum_Basis:
 18.1420 +lemma box_eq_set_sum_Basis:
 18.1421    shows "{x. \<forall>i\<in>Basis. x\<bullet>i \<in> B i} = (\<Sum>i\<in>Basis. image (\<lambda>x. x *\<^sub>R i) (B i))"
 18.1422 -  apply (subst set_setsum_eq [OF finite_Basis])
 18.1423 +  apply (subst set_sum_eq [OF finite_Basis])
 18.1424    apply safe
 18.1425    apply (fast intro: euclidean_representation [symmetric])
 18.1426 -  apply (subst inner_setsum_left)
 18.1427 +  apply (subst inner_sum_left)
 18.1428    apply (subgoal_tac "(\<Sum>x\<in>Basis. f x \<bullet> i) = f i \<bullet> i")
 18.1429    apply (drule (1) bspec)
 18.1430    apply clarsimp
 18.1431 -  apply (frule setsum.remove [OF finite_Basis])
 18.1432 +  apply (frule sum.remove [OF finite_Basis])
 18.1433    apply (erule trans)
 18.1434    apply simp
 18.1435 -  apply (rule setsum.neutral)
 18.1436 +  apply (rule sum.neutral)
 18.1437    apply clarsimp
 18.1438    apply (frule_tac x=i in bspec, assumption)
 18.1439    apply (drule_tac x=x in bspec, assumption)
 18.1440 @@ -6770,7 +6770,7 @@
 18.1441    apply simp
 18.1442    done
 18.1443  
 18.1444 -lemma convex_hull_set_setsum:
 18.1445 +lemma convex_hull_set_sum:
 18.1446    "convex hull (\<Sum>i\<in>A. B i) = (\<Sum>i\<in>A. convex hull (B i))"
 18.1447  proof (cases "finite A")
 18.1448    assume "finite A" then show ?thesis
 18.1449 @@ -6796,19 +6796,19 @@
 18.1450    (is "?int = convex hull ?points")
 18.1451  proof -
 18.1452    have One[simp]: "\<And>i. i \<in> Basis \<Longrightarrow> One \<bullet> i = 1"
 18.1453 -    by (simp add: inner_setsum_left setsum.If_cases inner_Basis)
 18.1454 +    by (simp add: inner_sum_left sum.If_cases inner_Basis)
 18.1455    have "?int = {x. \<forall>i\<in>Basis. x \<bullet> i \<in> cbox 0 1}"
 18.1456      by (auto simp: cbox_def)
 18.1457    also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` cbox 0 1)"
 18.1458 -    by (simp only: box_eq_set_setsum_Basis)
 18.1459 +    by (simp only: box_eq_set_sum_Basis)
 18.1460    also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` (convex hull {0, 1}))"
 18.1461      by (simp only: convex_hull_eq_real_cbox zero_le_one)
 18.1462    also have "\<dots> = (\<Sum>i\<in>Basis. convex hull ((\<lambda>x. x *\<^sub>R i) ` {0, 1}))"
 18.1463      by (simp only: convex_hull_linear_image linear_scaleR_left)
 18.1464    also have "\<dots> = convex hull (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` {0, 1})"
 18.1465 -    by (simp only: convex_hull_set_setsum)
 18.1466 +    by (simp only: convex_hull_set_sum)
 18.1467    also have "\<dots> = convex hull {x. \<forall>i\<in>Basis. x\<bullet>i \<in> {0, 1}}"
 18.1468 -    by (simp only: box_eq_set_setsum_Basis)
 18.1469 +    by (simp only: box_eq_set_sum_Basis)
 18.1470    also have "convex hull {x. \<forall>i\<in>Basis. x\<bullet>i \<in> {0, 1}} = convex hull ?points"
 18.1471      by simp
 18.1472    finally show ?thesis .
 18.1473 @@ -6939,7 +6939,7 @@
 18.1474             op + a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` cbox 0 One"
 18.1475  using assms
 18.1476  apply (simp add: box_ne_empty image_stretch_interval cbox_translation [symmetric])
 18.1477 -apply (simp add: min_def max_def algebra_simps setsum_subtractf euclidean_representation)
 18.1478 +apply (simp add: min_def max_def algebra_simps sum_subtractf euclidean_representation)
 18.1479  done
 18.1480  
 18.1481  lemma closed_interval_as_convex_hull:
 18.1482 @@ -6953,7 +6953,7 @@
 18.1483    obtain s::"'a set" where "finite s" and eq: "cbox 0 One = convex hull s"
 18.1484      by (blast intro: unit_cube_convex_hull)
 18.1485    have lin: "linear (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k)"
 18.1486 -    by (rule linear_compose_setsum) (auto simp: algebra_simps linearI)
 18.1487 +    by (rule linear_compose_sum) (auto simp: algebra_simps linearI)
 18.1488    have "finite (op + a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` s)"
 18.1489      by (rule finite_imageI \<open>finite s\<close>)+
 18.1490    then show ?thesis
 18.1491 @@ -7141,13 +7141,13 @@
 18.1492    proof
 18.1493      define c where "c = (\<Sum>i\<in>Basis. (\<lambda>a. a *\<^sub>R i) ` {x\<bullet>i - d, x\<bullet>i + d})"
 18.1494      show "finite c"
 18.1495 -      unfolding c_def by (simp add: finite_set_setsum)
 18.1496 +      unfolding c_def by (simp add: finite_set_sum)
 18.1497      have 1: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> cbox (x \<bullet> i - d) (x \<bullet> i + d)}"
 18.1498 -      unfolding box_eq_set_setsum_Basis
 18.1499 -      unfolding c_def convex_hull_set_setsum
 18.1500 +      unfolding box_eq_set_sum_Basis
 18.1501 +      unfolding c_def convex_hull_set_sum
 18.1502        apply (subst convex_hull_linear_image [symmetric])
 18.1503        apply (simp add: linear_iff scaleR_add_left)
 18.1504 -      apply (rule setsum.cong [OF refl])
 18.1505 +      apply (rule sum.cong [OF refl])
 18.1506        apply (rule image_cong [OF _ refl])
 18.1507        apply (rule convex_hull_eq_real_cbox)
 18.1508        apply (cut_tac \<open>0 < d\<close>, simp)
 18.1509 @@ -7168,10 +7168,10 @@
 18.1510        unfolding 2
 18.1511        apply clarsimp
 18.1512        apply (subst euclidean_dist_l2)
 18.1513 -      apply (rule order_trans [OF setL2_le_setsum])
 18.1514 +      apply (rule order_trans [OF setL2_le_sum])
 18.1515        apply (rule zero_le_dist)
 18.1516        unfolding e'
 18.1517 -      apply (rule setsum_mono)
 18.1518 +      apply (rule sum_mono)
 18.1519        apply simp
 18.1520        done
 18.1521    qed
 18.1522 @@ -8232,18 +8232,18 @@
 18.1523    assumes "finite s"
 18.1524      and "0 \<notin> s"
 18.1525    shows "convex hull (insert 0 s) =
 18.1526 -    {y. (\<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s \<le> 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y)}"
 18.1527 +    {y. (\<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s \<le> 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y)}"
 18.1528    unfolding convex_hull_finite[OF finite.insertI[OF assms(1)]]
 18.1529    apply (rule set_eqI, rule)
 18.1530    unfolding mem_Collect_eq
 18.1531    apply (erule_tac[!] exE)
 18.1532    apply (erule_tac[!] conjE)+
 18.1533 -  unfolding setsum_clauses(2)[OF \<open>finite s\<close>]
 18.1534 +  unfolding sum_clauses(2)[OF \<open>finite s\<close>]
 18.1535    apply (rule_tac x=u in exI)
 18.1536    defer
 18.1537 -  apply (rule_tac x="\<lambda>x. if x = 0 then 1 - setsum u s else u x" in exI)
 18.1538 +  apply (rule_tac x="\<lambda>x. if x = 0 then 1 - sum u s else u x" in exI)
 18.1539    using assms(2)
 18.1540 -  unfolding if_smult and setsum_delta_notmem[OF assms(2)]
 18.1541 +  unfolding if_smult and sum_delta_notmem[OF assms(2)]
 18.1542    apply auto
 18.1543    done
 18.1544  
 18.1545 @@ -8268,19 +8268,19 @@
 18.1546    proof -
 18.1547      fix x :: "'a::euclidean_space"
 18.1548      fix u
 18.1549 -    assume as: "\<forall>x\<in>?D. 0 \<le> u x" "setsum u ?D \<le> 1" "(\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
 18.1550 +    assume as: "\<forall>x\<in>?D. 0 \<le> u x" "sum u ?D \<le> 1" "(\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
 18.1551      have *: "\<forall>i\<in>Basis. i:d \<longrightarrow> u i = x\<bullet>i"
 18.1552        and "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
 18.1553        using as(3)
 18.1554        unfolding substdbasis_expansion_unique[OF assms]
 18.1555        by auto
 18.1556 -    then have **: "setsum u ?D = setsum (op \<bullet> x) ?D"
 18.1557 +    then have **: "sum u ?D = sum (op \<bullet> x) ?D"
 18.1558        apply -
 18.1559 -      apply (rule setsum.cong)
 18.1560 +      apply (rule sum.cong)
 18.1561        using assms
 18.1562        apply auto
 18.1563        done
 18.1564 -    have "(\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (op \<bullet> x) ?D \<le> 1"
 18.1565 +    have "(\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> sum (op \<bullet> x) ?D \<le> 1"
 18.1566      proof (rule,rule)
 18.1567        fix i :: 'a
 18.1568        assume i: "i \<in> Basis"
 18.1569 @@ -8293,12 +8293,12 @@
 18.1570          using \<open>(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)\<close>[rule_format, OF i] by auto
 18.1571        ultimately show "0 \<le> x\<bullet>i" by auto
 18.1572      qed (insert as(2)[unfolded **], auto)
 18.1573 -    then show "(\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (op \<bullet> x) ?D \<le> 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
 18.1574 +    then show "(\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> sum (op \<bullet> x) ?D \<le> 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
 18.1575        using \<open>(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)\<close> by auto
 18.1576    next
 18.1577      fix x :: "'a::euclidean_space"
 18.1578 -    assume as: "\<forall>i\<in>Basis. 0 \<le> x \<bullet> i" "setsum (op \<bullet> x) ?D \<le> 1" "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
 18.1579 -    show "\<exists>u. (\<forall>x\<in>?D. 0 \<le> u x) \<and> setsum u ?D \<le> 1 \<and> (\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
 18.1580 +    assume as: "\<forall>i\<in>Basis. 0 \<le> x \<bullet> i" "sum (op \<bullet> x) ?D \<le> 1" "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
 18.1581 +    show "\<exists>u. (\<forall>x\<in>?D. 0 \<le> u x) \<and> sum u ?D \<le> 1 \<and> (\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
 18.1582        using as d
 18.1583        unfolding substdbasis_expansion_unique[OF assms]
 18.1584        apply (rule_tac x="inner x" in exI)
 18.1585 @@ -8309,12 +8309,12 @@
 18.1586  
 18.1587  lemma std_simplex:
 18.1588    "convex hull (insert 0 Basis) =
 18.1589 -    {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (\<lambda>i. x\<bullet>i) Basis \<le> 1}"
 18.1590 +    {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> sum (\<lambda>i. x\<bullet>i) Basis \<le> 1}"
 18.1591    using substd_simplex[of Basis] by auto
 18.1592  
 18.1593  lemma interior_std_simplex:
 18.1594    "interior (convex hull (insert 0 Basis)) =
 18.1595 -    {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 < x\<bullet>i) \<and> setsum (\<lambda>i. x\<bullet>i) Basis < 1}"
 18.1596 +    {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 < x\<bullet>i) \<and> sum (\<lambda>i. x\<bullet>i) Basis < 1}"
 18.1597    apply (rule set_eqI)
 18.1598    unfolding mem_interior std_simplex
 18.1599    unfolding subset_eq mem_Collect_eq Ball_def mem_ball
 18.1600 @@ -8326,8 +8326,8 @@
 18.1601  proof -
 18.1602    fix x :: 'a
 18.1603    fix e
 18.1604 -  assume "e > 0" and as: "\<forall>xa. dist x xa < e \<longrightarrow> (\<forall>x\<in>Basis. 0 \<le> xa \<bullet> x) \<and> setsum (op \<bullet> xa) Basis \<le> 1"
 18.1605 -  show "(\<forall>xa\<in>Basis. 0 < x \<bullet> xa) \<and> setsum (op \<bullet> x) Basis < 1"
 18.1606 +  assume "e > 0" and as: "\<forall>xa. dist x xa < e \<longrightarrow> (\<forall>x\<in>Basis. 0 \<le> xa \<bullet> x) \<and> sum (op \<bullet> xa) Basis \<le> 1"
 18.1607 +  show "(\<forall>xa\<in>Basis. 0 < x \<bullet> xa) \<and> sum (op \<bullet> x) Basis < 1"
 18.1608      apply safe
 18.1609    proof -
 18.1610      fix i :: 'a
 18.1611 @@ -8343,15 +8343,15 @@
 18.1612      have "\<And>i. i \<in> Basis \<Longrightarrow> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis)) \<bullet> i =
 18.1613        x\<bullet>i + (if i = (SOME i. i\<in>Basis) then e/2 else 0)"
 18.1614        by (auto simp: SOME_Basis inner_Basis inner_simps)
 18.1615 -    then have *: "setsum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis =
 18.1616 -      setsum (\<lambda>i. x\<bullet>i + (if (SOME i. i\<in>Basis) = i then e/2 else 0)) Basis"
 18.1617 -      apply (rule_tac setsum.cong)
 18.1618 +    then have *: "sum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis =
 18.1619 +      sum (\<lambda>i. x\<bullet>i + (if (SOME i. i\<in>Basis) = i then e/2 else 0)) Basis"
 18.1620 +      apply (rule_tac sum.cong)
 18.1621        apply auto
 18.1622        done
 18.1623 -    have "setsum (op \<bullet> x) Basis < setsum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis"
 18.1624 -      unfolding * setsum.distrib
 18.1625 +    have "sum (op \<bullet> x) Basis < sum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis"
 18.1626 +      unfolding * sum.distrib
 18.1627        using \<open>e > 0\<close> DIM_positive[where 'a='a]
 18.1628 -      apply (subst setsum.delta')
 18.1629 +      apply (subst sum.delta')
 18.1630        apply (auto simp: SOME_Basis)
 18.1631        done
 18.1632      also have "\<dots> \<le> 1"
 18.1633 @@ -8359,13 +8359,13 @@
 18.1634        apply (drule_tac as[rule_format])
 18.1635        apply auto
 18.1636        done
 18.1637 -    finally show "setsum (op \<bullet> x) Basis < 1" by auto
 18.1638 +    finally show "sum (op \<bullet> x) Basis < 1" by auto
 18.1639    qed
 18.1640  next
 18.1641    fix x :: 'a
 18.1642 -  assume as: "\<forall>i\<in>Basis. 0 < x \<bullet> i" "setsum (op \<bullet> x) Basis < 1"
 18.1643 +  assume as: "\<forall>i\<in>Basis. 0 < x \<bullet> i" "sum (op \<bullet> x) Basis < 1"
 18.1644    obtain a :: 'b where "a \<in> UNIV" using UNIV_witness ..
 18.1645 -  let ?d = "(1 - setsum (op \<bullet> x) Basis) / real (DIM('a))"
 18.1646 +  let ?d = "(1 - sum (op \<bullet> x) Basis) / real (DIM('a))"
 18.1647    have "Min ((op \<bullet> x) ` Basis) > 0"
 18.1648      apply (rule Min_grI)
 18.1649      using as(1)
 18.1650 @@ -8373,7 +8373,7 @@
 18.1651      done
 18.1652    moreover have "?d > 0"
 18.1653      using as(2) by (auto simp: Suc_le_eq DIM_positive)
 18.1654 -  ultimately show "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> (\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> setsum (op \<bullet> y) Basis \<le> 1"
 18.1655 +  ultimately show "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> (\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> sum (op \<bullet> y) Basis \<le> 1"
 18.1656      apply (rule_tac x="min (Min ((op \<bullet> x) ` Basis)) D" for D in exI)
 18.1657      apply rule
 18.1658      defer
 18.1659 @@ -8381,8 +8381,8 @@
 18.1660    proof -
 18.1661      fix y
 18.1662      assume y: "dist x y < min (Min (op \<bullet> x ` Basis)) ?d"
 18.1663 -    have "setsum (op \<bullet> y) Basis \<le> setsum (\<lambda>i. x\<bullet>i + ?d) Basis"
 18.1664 -    proof (rule setsum_mono)
 18.1665 +    have "sum (op \<bullet> y) Basis \<le> sum (\<lambda>i. x\<bullet>i + ?d) Basis"
 18.1666 +    proof (rule sum_mono)
 18.1667        fix i :: 'a
 18.1668        assume i: "i \<in> Basis"
 18.1669        then have "\<bar>y\<bullet>i - x\<bullet>i\<bar> < ?d"
 18.1670 @@ -8395,9 +8395,9 @@
 18.1671        then show "y \<bullet> i \<le> x \<bullet> i + ?d" by auto
 18.1672      qed
 18.1673      also have "\<dots> \<le> 1"
 18.1674 -      unfolding setsum.distrib setsum_constant
 18.1675 +      unfolding sum.distrib sum_constant
 18.1676        by (auto simp add: Suc_le_eq)
 18.1677 -    finally show "(\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> setsum (op \<bullet> y) Basis \<le> 1"
 18.1678 +    finally show "(\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> sum (op \<bullet> y) Basis \<le> 1"
 18.1679      proof safe
 18.1680        fix i :: 'a
 18.1681        assume i: "i \<in> Basis"
 18.1682 @@ -8419,13 +8419,13 @@
 18.1683      "a \<in> interior(convex hull (insert 0 Basis))"
 18.1684  proof -
 18.1685    let ?D = "Basis :: 'a set"
 18.1686 -  let ?a = "setsum (\<lambda>b::'a. inverse (2 * real DIM('a)) *\<^sub>R b) Basis"
 18.1687 +  let ?a = "sum (\<lambda>b::'a. inverse (2 * real DIM('a)) *\<^sub>R b) Basis"
 18.1688    {
 18.1689      fix i :: 'a
 18.1690      assume i: "i \<in> Basis"
 18.1691      have "?a \<bullet> i = inverse (2 * real DIM('a))"
 18.1692 -      by (rule trans[of _ "setsum (\<lambda>j. if i = j then inverse (2 * real DIM('a)) else 0) ?D"])
 18.1693 -         (simp_all add: setsum.If_cases i) }
 18.1694 +      by (rule trans[of _ "sum (\<lambda>j. if i = j then inverse (2 * real DIM('a)) else 0) ?D"])
 18.1695 +         (simp_all add: sum.If_cases i) }
 18.1696    note ** = this
 18.1697    show ?thesis
 18.1698      apply (rule that[of ?a])
 18.1699 @@ -8436,15 +8436,15 @@
 18.1700      show "0 < ?a \<bullet> i"
 18.1701        unfolding **[OF i] by (auto simp add: Suc_le_eq DIM_positive)
 18.1702    next
 18.1703 -    have "setsum (op \<bullet> ?a) ?D = setsum (\<lambda>i. inverse (2 * real DIM('a))) ?D"
 18.1704 -      apply (rule setsum.cong)
 18.1705 +    have "sum (op \<bullet> ?a) ?D = sum (\<lambda>i. inverse (2 * real DIM('a))) ?D"
 18.1706 +      apply (rule sum.cong)
 18.1707        apply rule
 18.1708        apply auto
 18.1709        done
 18.1710      also have "\<dots> < 1"
 18.1711 -      unfolding setsum_constant divide_inverse[symmetric]
 18.1712 +      unfolding sum_constant divide_inverse[symmetric]
 18.1713        by (auto simp add: field_simps)
 18.1714 -    finally show "setsum (op \<bullet> ?a) ?D < 1" by auto
 18.1715 +    finally show "sum (op \<bullet> ?a) ?D < 1" by auto
 18.1716    qed
 18.1717  qed
 18.1718  
 18.1719 @@ -8478,11 +8478,11 @@
 18.1720          "ball x e \<inter> {xa. (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> xa\<bullet>i = 0)} \<subseteq> convex hull (insert 0 ?p)"
 18.1721          using mem_rel_interior_ball[of x "convex hull (insert 0 ?p)"] h0 by auto
 18.1722        then have as: "\<forall>xa. dist x xa < e \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> xa\<bullet>i = 0) \<longrightarrow>
 18.1723 -        (\<forall>i\<in>d. 0 \<le> xa \<bullet> i) \<and> setsum (op \<bullet> xa) d \<le> 1"
 18.1724 +        (\<forall>i\<in>d. 0 \<le> xa \<bullet> i) \<and> sum (op \<bullet> xa) d \<le> 1"
 18.1725          unfolding ball_def unfolding substd_simplex[OF assms] using assms by auto
 18.1726        have x0: "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
 18.1727          using x rel_interior_subset  substd_simplex[OF assms] by auto
 18.1728 -      have "(\<forall>i\<in>d. 0 < x \<bullet> i) \<and> setsum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
 18.1729 +      have "(\<forall>i\<in>d. 0 < x \<bullet> i) \<and> sum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
 18.1730          apply rule
 18.1731          apply rule
 18.1732        proof -
 18.1733 @@ -8509,22 +8509,22 @@
 18.1734            by auto
 18.1735          have "\<And>i. i \<in> Basis \<Longrightarrow> (x + (e / 2) *\<^sub>R a) \<bullet> i = x\<bullet>i + (if i = a then e/2 else 0)"
 18.1736            using a d by (auto simp: inner_simps inner_Basis)
 18.1737 -        then have *: "setsum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d =
 18.1738 -          setsum (\<lambda>i. x\<bullet>i + (if a = i then e/2 else 0)) d"
 18.1739 -          using d by (intro setsum.cong) auto
 18.1740 +        then have *: "sum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d =
 18.1741 +          sum (\<lambda>i. x\<bullet>i + (if a = i then e/2 else 0)) d"
 18.1742 +          using d by (intro sum.cong) auto
 18.1743          have "a \<in> Basis"
 18.1744            using \<open>a \<in> d\<close> d by auto
 18.1745          then have h1: "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> (x + (e / 2) *\<^sub>R a) \<bullet> i = 0)"
 18.1746            using x0 d \<open>a\<in>d\<close> by (auto simp add: inner_add_left inner_Basis)
 18.1747 -        have "setsum (op \<bullet> x) d < setsum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d"
 18.1748 -          unfolding * setsum.distrib
 18.1749 +        have "sum (op \<bullet> x) d < sum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d"
 18.1750 +          unfolding * sum.distrib
 18.1751            using \<open>e > 0\<close> \<open>a \<in> d\<close>
 18.1752            using \<open>finite d\<close>
 18.1753 -          by (auto simp add: setsum.delta')
 18.1754 +          by (auto simp add: sum.delta')
 18.1755          also have "\<dots> \<le> 1"
 18.1756            using ** h1 as[rule_format, of "x + (e / 2) *\<^sub>R a"]
 18.1757            by auto
 18.1758 -        finally show "setsum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
 18.1759 +        finally show "sum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
 18.1760            using x0 by auto
 18.1761        qed
 18.1762      }
 18.1763 @@ -8543,7 +8543,7 @@
 18.1764          unfolding substd_simplex[OF assms] by fastforce
 18.1765        obtain a where a: "a \<in> d"
 18.1766          using \<open>d \<noteq> {}\<close> by auto
 18.1767 -      let ?d = "(1 - setsum (op \<bullet> x) d) / real (card d)"
 18.1768 +      let ?d = "(1 - sum (op \<bullet> x) d) / real (card d)"
 18.1769        have "0 < card d" using \<open>d \<noteq> {}\<close> \<open>finite d\<close>
 18.1770          by (simp add: card_gt_0_iff)
 18.1771        have "Min ((op \<bullet> x) ` d) > 0"
 18.1772 @@ -8564,8 +8564,8 @@
 18.1773          fix y :: 'a
 18.1774          assume y: "dist x y < min (Min (op \<bullet> x ` d)) ?d"
 18.1775          assume y2: "\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> y\<bullet>i = 0"
 18.1776 -        have "setsum (op \<bullet> y) d \<le> setsum (\<lambda>i. x\<bullet>i + ?d) d"
 18.1777 -        proof (rule setsum_mono)
 18.1778 +        have "sum (op \<bullet> y) d \<le> sum (\<lambda>i. x\<bullet>i + ?d) d"
 18.1779 +        proof (rule sum_mono)
 18.1780            fix i
 18.1781            assume "i \<in> d"
 18.1782            with d have i: "i \<in> Basis"
 18.1783 @@ -8579,9 +8579,9 @@
 18.1784            then show "y \<bullet> i \<le> x \<bullet> i + ?d" by auto
 18.1785          qed
 18.1786          also have "\<dots> \<le> 1"
 18.1787 -          unfolding setsum.distrib setsum_constant  using \<open>0 < card d\<close>
 18.1788 +          unfolding sum.distrib sum_constant  using \<open>0 < card d\<close>
 18.1789            by auto
 18.1790 -        finally show "setsum (op \<bullet> y) d \<le> 1" .
 18.1791 +        finally show "sum (op \<bullet> y) d \<le> 1" .
 18.1792  
 18.1793          fix i :: 'a
 18.1794          assume i: "i \<in> Basis"
 18.1795 @@ -8600,7 +8600,7 @@
 18.1796      }
 18.1797      ultimately have
 18.1798        "\<And>x. x \<in> rel_interior (convex hull insert 0 d) \<longleftrightarrow>
 18.1799 -        x \<in> {x. (\<forall>i\<in>d. 0 < x \<bullet> i) \<and> setsum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)}"
 18.1800 +        x \<in> {x. (\<forall>i\<in>d. 0 < x \<bullet> i) \<and> sum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)}"
 18.1801        by blast
 18.1802      then show ?thesis by (rule set_eqI)
 18.1803    qed
 18.1804 @@ -8613,7 +8613,7 @@
 18.1805      where "a \<in> rel_interior (convex hull (insert 0 d))"
 18.1806  proof -
 18.1807    let ?D = d
 18.1808 -  let ?a = "setsum (\<lambda>b::'a::euclidean_space. inverse (2 * real (card d)) *\<^sub>R b) ?D"
 18.1809 +  let ?a = "sum (\<lambda>b::'a::euclidean_space. inverse (2 * real (card d)) *\<^sub>R b) ?D"
 18.1810    have "finite d"
 18.1811      apply (rule finite_subset)
 18.1812      using assms(2)
 18.1813 @@ -8625,10 +8625,10 @@
 18.1814      fix i
 18.1815      assume "i \<in> d"
 18.1816      have "?a \<bullet> i = inverse (2 * real (card d))"
 18.1817 -      apply (rule trans[of _ "setsum (\<lambda>j. if i = j then inverse (2 * real (card d)) else 0) ?D"])
 18.1818 -      unfolding inner_setsum_left
 18.1819 -      apply (rule setsum.cong)
 18.1820 -      using \<open>i \<in> d\<close> \<open>finite d\<close> setsum.delta'[of d i "(\<lambda>k. inverse (2 * real (card d)))"]
 18.1821 +      apply (rule trans[of _ "sum (\<lambda>j. if i = j then inverse (2 * real (card d)) else 0) ?D"])
 18.1822 +      unfolding inner_sum_left
 18.1823 +      apply (rule sum.cong)
 18.1824 +      using \<open>i \<in> d\<close> \<open>finite d\<close> sum.delta'[of d i "(\<lambda>k. inverse (2 * real (card d)))"]
 18.1825          d1 assms(2)
 18.1826        by (auto simp: inner_Basis set_rev_mp[OF _ assms(2)])
 18.1827    }
 18.1828 @@ -8645,17 +8645,17 @@
 18.1829        by auto
 18.1830      finally show "0 < ?a \<bullet> i" by auto
 18.1831    next
 18.1832 -    have "setsum (op \<bullet> ?a) ?D = setsum (\<lambda>i. inverse (2 * real (card d))) ?D"
 18.1833 -      by (rule setsum.cong) (rule refl, rule **)
 18.1834 +    have "sum (op \<bullet> ?a) ?D = sum (\<lambda>i. inverse (2 * real (card d))) ?D"
 18.1835 +      by (rule sum.cong) (rule refl, rule **)
 18.1836      also have "\<dots> < 1"
 18.1837 -      unfolding setsum_constant divide_real_def[symmetric]
 18.1838 +      unfolding sum_constant divide_real_def[symmetric]
 18.1839        by (auto simp add: field_simps)
 18.1840 -    finally show "setsum (op \<bullet> ?a) ?D < 1" by auto
 18.1841 +    finally show "sum (op \<bullet> ?a) ?D < 1" by auto
 18.1842    next
 18.1843      fix i
 18.1844      assume "i \<in> Basis" and "i \<notin> d"
 18.1845      have "?a \<in> span d"
 18.1846 -    proof (rule span_setsum[of d "(\<lambda>b. b /\<^sub>R (2 * real (card d)))" d])
 18.1847 +    proof (rule span_sum[of d "(\<lambda>b. b /\<^sub>R (2 * real (card d)))" d])
 18.1848        {
 18.1849          fix x :: "'a::euclidean_space"
 18.1850          assume "x \<in> d"
 18.1851 @@ -10232,20 +10232,20 @@
 18.1852    assumes "finite I"
 18.1853    assumes "\<forall>i\<in>I. convex (S i) \<and> (S i) \<noteq> {}"
 18.1854    shows "convex hull (\<Union>(S ` I)) =
 18.1855 -    {setsum (\<lambda>i. c i *\<^sub>R s i) I | c s. (\<forall>i\<in>I. c i \<ge> 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}"
 18.1856 +    {sum (\<lambda>i. c i *\<^sub>R s i) I | c s. (\<forall>i\<in>I. c i \<ge> 0) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}"
 18.1857    (is "?lhs = ?rhs")
 18.1858  proof -
 18.1859    have "?lhs \<supseteq> ?rhs"
 18.1860    proof
 18.1861      fix x
 18.1862      assume "x : ?rhs"
 18.1863 -    then obtain c s where *: "setsum (\<lambda>i. c i *\<^sub>R s i) I = x" "setsum c I = 1"
 18.1864 +    then obtain c s where *: "sum (\<lambda>i. c i *\<^sub>R s i) I = x" "sum c I = 1"
 18.1865        "(\<forall>i\<in>I. c i \<ge> 0) \<and> (\<forall>i\<in>I. s i \<in> S i)" by auto
 18.1866      then have "\<forall>i\<in>I. s i \<in> convex hull (\<Union>(S ` I))"
 18.1867        using hull_subset[of "\<Union>(S ` I)" convex] by auto
 18.1868      then show "x \<in> ?lhs"
 18.1869        unfolding *(1)[symmetric]
 18.1870 -      apply (subst convex_setsum[of I "convex hull \<Union>(S ` I)" c s])
 18.1871 +      apply (subst convex_sum[of I "convex hull \<Union>(S ` I)" c s])
 18.1872        using * assms convex_convex_hull
 18.1873        apply auto
 18.1874        done
 18.1875 @@ -10265,14 +10265,14 @@
 18.1876        fix x
 18.1877        assume "x \<in> S i"
 18.1878        define c where "c j = (if j = i then 1::real else 0)" for j
 18.1879 -      then have *: "setsum c I = 1"
 18.1880 -        using \<open>finite I\<close> \<open>i \<in> I\<close> setsum.delta[of I i "\<lambda>j::'a. 1::real"]
 18.1881 +      then have *: "sum c I = 1"
 18.1882 +        using \<open>finite I\<close> \<open>i \<in> I\<close> sum.delta[of I i "\<lambda>j::'a. 1::real"]
 18.1883          by auto
 18.1884        define s where "s j = (if j = i then x else p j)" for j
 18.1885        then have "\<forall>j. c j *\<^sub>R s j = (if j = i then x else 0)"
 18.1886          using c_def by (auto simp add: algebra_simps)
 18.1887 -      then have "x = setsum (\<lambda>i. c i *\<^sub>R s i) I"
 18.1888 -        using s_def c_def \<open>finite I\<close> \<open>i \<in> I\<close> setsum.delta[of I i "\<lambda>j::'a. x"]
 18.1889 +      then have "x = sum (\<lambda>i. c i *\<^sub>R s i) I"
 18.1890 +        using s_def c_def \<open>finite I\<close> \<open>i \<in> I\<close> sum.delta[of I i "\<lambda>j::'a. x"]
 18.1891          by auto
 18.1892        then have "x \<in> ?rhs"
 18.1893          apply auto
 18.1894 @@ -10292,20 +10292,20 @@
 18.1895      fix x y
 18.1896      assume xy: "x \<in> ?rhs \<and> y \<in> ?rhs"
 18.1897      from xy obtain c s where
 18.1898 -      xc: "x = setsum (\<lambda>i. c i *\<^sub>R s i) I \<and> (\<forall>i\<in>I. c i \<ge> 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)"
 18.1899 +      xc: "x = sum (\<lambda>i. c i *\<^sub>R s i) I \<and> (\<forall>i\<in>I. c i \<ge> 0) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)"
 18.1900        by auto
 18.1901      from xy obtain d t where
 18.1902 -      yc: "y = setsum (\<lambda>i. d i *\<^sub>R t i) I \<and> (\<forall>i\<in>I. d i \<ge> 0) \<and> setsum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)"
 18.1903 +      yc: "y = sum (\<lambda>i. d i *\<^sub>R t i) I \<and> (\<forall>i\<in>I. d i \<ge> 0) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)"
 18.1904        by auto
 18.1905      define e where "e i = u * c i + v * d i" for i
 18.1906      have ge0: "\<forall>i\<in>I. e i \<ge> 0"
 18.1907        using e_def xc yc uv by simp
 18.1908 -    have "setsum (\<lambda>i. u * c i) I = u * setsum c I"
 18.1909 -      by (simp add: setsum_distrib_left)
 18.1910 -    moreover have "setsum (\<lambda>i. v * d i) I = v * setsum d I"
 18.1911 -      by (simp add: setsum_distrib_left)
 18.1912 -    ultimately have sum1: "setsum e I = 1"
 18.1913 -      using e_def xc yc uv by (simp add: setsum.distrib)
 18.1914 +    have "sum (\<lambda>i. u * c i) I = u * sum c I"
 18.1915 +      by (simp add: sum_distrib_left)
 18.1916 +    moreover have "sum (\<lambda>i. v * d i) I = v * sum d I"
 18.1917 +      by (simp add: sum_distrib_left)
 18.1918 +    ultimately have sum1: "sum e I = 1"
 18.1919 +      using e_def xc yc uv by (simp add: sum.distrib)
 18.1920      define q where "q i = (if e i = 0 then p i else (u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i)"
 18.1921        for i
 18.1922      {
 18.1923 @@ -10348,11 +10348,11 @@
 18.1924      }
 18.1925      then have *: "\<forall>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i"
 18.1926        by auto
 18.1927 -    have "u *\<^sub>R x + v *\<^sub>R y = setsum (\<lambda>i. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i) I"
 18.1928 -      using xc yc by (simp add: algebra_simps scaleR_right.setsum setsum.distrib)
 18.1929 -    also have "\<dots> = setsum (\<lambda>i. e i *\<^sub>R q i) I"
 18.1930 +    have "u *\<^sub>R x + v *\<^sub>R y = sum (\<lambda>i. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i) I"
 18.1931 +      using xc yc by (simp add: algebra_simps scaleR_right.sum sum.distrib)
 18.1932 +    also have "\<dots> = sum (\<lambda>i. e i *\<^sub>R q i) I"
 18.1933        using * by auto
 18.1934 -    finally have "u *\<^sub>R x + v *\<^sub>R y = setsum (\<lambda>i. (e i) *\<^sub>R (q i)) I"
 18.1935 +    finally have "u *\<^sub>R x + v *\<^sub>R y = sum (\<lambda>i. (e i) *\<^sub>R (q i)) I"
 18.1936        by auto
 18.1937      then have "u *\<^sub>R x + v *\<^sub>R y \<in> ?rhs"
 18.1938        using ge0 sum1 qs by auto
 18.1939 @@ -10380,13 +10380,13 @@
 18.1940    then have "convex hull (\<Union>(s ` I)) = convex hull (S \<union> T)"
 18.1941      by auto
 18.1942    moreover have "convex hull \<Union>(s ` I) =
 18.1943 -    {\<Sum> i\<in>I. c i *\<^sub>R sa i | c sa. (\<forall>i\<in>I. 0 \<le> c i) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. sa i \<in> s i)}"
 18.1944 +    {\<Sum> i\<in>I. c i *\<^sub>R sa i | c sa. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. sa i \<in> s i)}"
 18.1945        apply (subst convex_hull_finite_union[of I s])
 18.1946        using assms s_def I_def
 18.1947        apply auto
 18.1948        done
 18.1949    moreover have
 18.1950 -    "{\<Sum>i\<in>I. c i *\<^sub>R sa i | c sa. (\<forall>i\<in>I. 0 \<le> c i) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. sa i \<in> s i)} \<le> ?rhs"
 18.1951 +    "{\<Sum>i\<in>I. c i *\<^sub>R sa i | c sa. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. sa i \<in> s i)} \<le> ?rhs"
 18.1952      using s_def I_def by auto
 18.1953    ultimately show "?lhs \<subseteq> ?rhs" by auto
 18.1954    {
 18.1955 @@ -10432,8 +10432,8 @@
 18.1956  lemma rel_interior_sum_gen:
 18.1957    fixes S :: "'a \<Rightarrow> 'n::euclidean_space set"
 18.1958    assumes "\<forall>i\<in>I. convex (S i)"
 18.1959 -  shows "rel_interior (setsum S I) = setsum (\<lambda>i. rel_interior (S i)) I"
 18.1960 -  apply (subst setsum_set_cond_linear[of convex])
 18.1961 +  shows "rel_interior (sum S I) = sum (\<lambda>i. rel_interior (S i)) I"
 18.1962 +  apply (subst sum_set_cond_linear[of convex])
 18.1963    using rel_interior_sum rel_interior_sing[of "0"] assms
 18.1964    apply (auto simp add: convex_set_plus)
 18.1965    done
 18.1966 @@ -10460,14 +10460,14 @@
 18.1967    assumes "finite I"
 18.1968      and "I \<noteq> {}"
 18.1969    assumes "\<forall>i\<in>I. convex (S i) \<and> cone (S i) \<and> S i \<noteq> {}"
 18.1970 -  shows "convex hull (\<Union>(S ` I)) = setsum S I"
 18.1971 +  shows "convex hull (\<Union>(S ` I)) = sum S I"
 18.1972    (is "?lhs = ?rhs")
 18.1973  proof -
 18.1974    {
 18.1975      fix x
 18.1976      assume "x \<in> ?lhs"
 18.1977      then obtain c xs where
 18.1978 -      x: "x = setsum (\<lambda>i. c i *\<^sub>R xs i) I \<and> (\<forall>i\<in>I. c i \<ge> 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. xs i \<in> S i)"
 18.1979 +      x: "x = sum (\<lambda>i. c i *\<^sub>R xs i) I \<and> (\<forall>i\<in>I. c i \<ge> 0) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. xs i \<in> S i)"
 18.1980        using convex_hull_finite_union[of I S] assms by auto
 18.1981      define s where "s i = c i *\<^sub>R xs i" for i
 18.1982      {
 18.1983 @@ -10477,24 +10477,24 @@
 18.1984          using s_def x assms mem_cone[of "S i" "xs i" "c i"] by auto
 18.1985      }
 18.1986      then have "\<forall>i\<in>I. s i \<in> S i" by auto
 18.1987 -    moreover have "x = setsum s I" using x s_def by auto
 18.1988 +    moreover have "x = sum s I" using x s_def by auto
 18.1989      ultimately have "x \<in> ?rhs"
 18.1990 -      using set_setsum_alt[of I S] assms by auto
 18.1991 +      using set_sum_alt[of I S] assms by auto
 18.1992    }
 18.1993    moreover
 18.1994    {
 18.1995      fix x
 18.1996      assume "x \<in> ?rhs"
 18.1997 -    then obtain s where x: "x = setsum s I \<and> (\<forall>i\<in>I. s i \<in> S i)"
 18.1998 -      using set_setsum_alt[of I S] assms by auto
 18.1999 +    then obtain s where x: "x = sum s I \<and> (\<forall>i\<in>I. s i \<in> S i)"
 18.2000 +      using set_sum_alt[of I S] assms by auto
 18.2001      define xs where "xs i = of_nat(card I) *\<^sub>R s i" for i
 18.2002 -    then have "x = setsum (\<lambda>i. ((1 :: real) / of_nat(card I)) *\<^sub>R xs i) I"
 18.2003 +    then have "x = sum (\<lambda>i. ((1 :: real) / of_nat(card I)) *\<^sub>R xs i) I"
 18.2004        using x assms by auto
 18.2005      moreover have "\<forall>i\<in>I. xs i \<in> S i"
 18.2006        using x xs_def assms by (simp add: cone_def)
 18.2007      moreover have "\<forall>i\<in>I. (1 :: real) / of_nat (card I) \<ge> 0"
 18.2008        by auto
 18.2009 -    moreover have "setsum (\<lambda>i. (1 :: real) / of_nat (card I)) I = 1"
 18.2010 +    moreover have "sum (\<lambda>i. (1 :: real) / of_nat (card I)) I = 1"
 18.2011        using assms by auto
 18.2012      ultimately have "x \<in> ?lhs"
 18.2013        apply (subst convex_hull_finite_union[of I S])
 18.2014 @@ -10526,12 +10526,12 @@
 18.2015      using A_def I_def by auto
 18.2016    then have "convex hull (\<Union>(A ` I)) = convex hull (S \<union> T)"
 18.2017      by auto
 18.2018 -  moreover have "convex hull \<Union>(A ` I) = setsum A I"
 18.2019 +  moreover have "convex hull \<Union>(A ` I) = sum A I"
 18.2020      apply (subst convex_hull_finite_union_cones[of I A])
 18.2021      using assms A_def I_def
 18.2022      apply auto
 18.2023      done
 18.2024 -  moreover have "setsum A I = S + T"
 18.2025 +  moreover have "sum A I = S + T"
 18.2026      using A_def I_def
 18.2027      unfolding set_plus_def
 18.2028      apply auto
 18.2029 @@ -10546,7 +10546,7 @@
 18.2030    assumes "finite I"
 18.2031      and "\<forall>i\<in>I. convex (S i) \<and> S i \<noteq> {}"
 18.2032    shows "rel_interior (convex hull (\<Union>(S ` I))) =
 18.2033 -    {setsum (\<lambda>i. c i *\<^sub>R s i) I | c s. (\<forall>i\<in>I. c i > 0) \<and> setsum c I = 1 \<and>
 18.2034 +    {sum (\<lambda>i. c i *\<^sub>R s i) I | c s. (\<forall>i\<in>I. c i > 0) \<and> sum c I = 1 \<and>
 18.2035        (\<forall>i\<in>I. s i \<in> rel_interior(S i))}"
 18.2036    (is "?lhs = ?rhs")
 18.2037  proof (cases "I = {}")
 18.2038 @@ -10621,7 +10621,7 @@
 18.2039      by blast
 18.2040    then have "K0 = convex hull (\<Union>(K ` I))"
 18.2041      using geq by auto
 18.2042 -  also have "\<dots> = setsum K I"
 18.2043 +  also have "\<dots> = sum K I"
 18.2044      apply (subst convex_hull_finite_union_cones[of I K])
 18.2045      using assms
 18.2046      apply blast
 18.2047 @@ -10634,8 +10634,8 @@
 18.2048      using assms cone_cone_hull \<open>\<forall>i\<in>I. K i \<noteq> {}\<close> K_def
 18.2049      apply auto
 18.2050      done
 18.2051 -  finally have "K0 = setsum K I" by auto
 18.2052 -  then have *: "rel_interior K0 = setsum (\<lambda>i. (rel_interior (K i))) I"
 18.2053 +  finally have "K0 = sum K I" by auto
 18.2054 +  then have *: "rel_interior K0 = sum (\<lambda>i. (rel_interior (K i))) I"
 18.2055      using rel_interior_sum_gen[of I K] convK by auto
 18.2056    {
 18.2057      fix x
 18.2058 @@ -10643,8 +10643,8 @@
 18.2059      then have "(1::real, x) \<in> rel_interior K0"
 18.2060        using K0_def C0_def rel_interior_convex_cone_aux[of C0 "1::real" x] convex_convex_hull
 18.2061        by auto
 18.2062 -    then obtain k where k: "(1::real, x) = setsum k I \<and> (\<forall>i\<in>I. k i \<in> rel_interior (K i))"
 18.2063 -      using \<open>finite I\<close> * set_setsum_alt[of I "\<lambda>i. rel_interior (K i)"] by auto
 18.2064 +    then obtain k where k: "(1::real, x) = sum k I \<and> (\<forall>i\<in>I. k i \<in> rel_interior (K i))"
 18.2065 +      using \<open>finite I\<close> * set_sum_alt[of I "\<lambda>i. rel_interior (K i)"] by auto
 18.2066      {
 18.2067        fix i
 18.2068        assume "i \<in> I"
 18.2069 @@ -10656,8 +10656,8 @@
 18.2070      then obtain c s where
 18.2071        cs: "\<forall>i\<in>I. k i = (c i, c i *\<^sub>R s i) \<and> 0 < c i \<and> s i \<in> rel_interior (S i)"
 18.2072        by metis
 18.2073 -    then have "x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> setsum c I = 1"
 18.2074 -      using k by (simp add: setsum_prod)
 18.2075 +    then have "x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> sum c I = 1"
 18.2076 +      using k by (simp add: sum_prod)
 18.2077      then have "x \<in> ?rhs"
 18.2078        using k
 18.2079        apply auto
 18.2080 @@ -10671,8 +10671,8 @@
 18.2081    {
 18.2082      fix x
 18.2083      assume "x \<in> ?rhs"
 18.2084 -    then obtain c s where cs: "x = setsum (\<lambda>i. c i *\<^sub>R s i) I \<and>
 18.2085 -        (\<forall>i\<in>I. c i > 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> rel_interior (S i))"
 18.2086 +    then obtain c s where cs: "x = sum (\<lambda>i. c i *\<^sub>R s i) I \<and>
 18.2087 +        (\<forall>i\<in>I. c i > 0) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> rel_interior (S i))"
 18.2088        by auto
 18.2089      define k where "k i = (c i, c i *\<^sub>R s i)" for i
 18.2090      {
 18.2091 @@ -10682,10 +10682,10 @@
 18.2092          by auto
 18.2093      }
 18.2094      then have "(1::real, x) \<in> rel_interior K0"
 18.2095 -      using K0_def * set_setsum_alt[of I "(\<lambda>i. rel_interior (K i))"] assms k_def cs
 18.2096 +      using K0_def * set_sum_alt[of I "(\<lambda>i. rel_interior (K i))"] assms k_def cs
 18.2097        apply auto
 18.2098        apply (rule_tac x = k in exI)
 18.2099 -      apply (simp add: setsum_prod)
 18.2100 +      apply (simp add: sum_prod)
 18.2101        done
 18.2102      then have "x \<in> ?lhs"
 18.2103        using K0_def C0_def rel_interior_convex_cone_aux[of C0 1 x]
 18.2104 @@ -10801,18 +10801,18 @@
 18.2105  proof -
 18.2106    have fin: "finite s" "finite t" using assms aff_independent_finite finite_subset by auto
 18.2107      { fix u v x
 18.2108 -      assume uv: "setsum u t = 1" "\<forall>x\<in>s. 0 \<le> v x" "setsum v s = 1"
 18.2109 +      assume uv: "sum u t = 1" "\<forall>x\<in>s. 0 \<le> v x" "sum v s = 1"
 18.2110                   "(\<Sum>x\<in>s. v x *\<^sub>R x) = (\<Sum>v\<in>t. u v *\<^sub>R v)" "x \<in> t"
 18.2111        then have s: "s = (s - t) \<union> t" \<comment>\<open>split into separate cases\<close>
 18.2112          using assms by auto
 18.2113        have [simp]: "(\<Sum>x\<in>t. v x *\<^sub>R x) + (\<Sum>x\<in>s - t. v x *\<^sub>R x) = (\<Sum>x\<in>t. u x *\<^sub>R x)"
 18.2114 -                   "setsum v t + setsum v (s - t) = 1"
 18.2115 +                   "sum v t + sum v (s - t) = 1"
 18.2116          using uv fin s
 18.2117 -        by (auto simp: setsum.union_disjoint [symmetric] Un_commute)
 18.2118 +        by (auto simp: sum.union_disjoint [symmetric] Un_commute)
 18.2119        have "(\<Sum>x\<in>s. if x \<in> t then v x - u x else v x) = 0"
 18.2120             "(\<Sum>x\<in>s. (if x \<in> t then v x - u x else v x) *\<^sub>R x) = 0"
 18.2121          using uv fin
 18.2122 -        by (subst s, subst setsum.union_disjoint, auto simp: algebra_simps setsum_subtractf)+
 18.2123 +        by (subst s, subst sum.union_disjoint, auto simp: algebra_simps sum_subtractf)+
 18.2124      } note [simp] = this
 18.2125    have "convex hull t \<subseteq> affine hull t"
 18.2126      using convex_hull_subset_affine_hull by blast
 18.2127 @@ -10890,14 +10890,14 @@
 18.2128  lemma explicit_subset_rel_interior_convex_hull:
 18.2129    fixes s :: "'a::euclidean_space set"
 18.2130    shows "finite s
 18.2131 -         \<Longrightarrow> {y. \<exists>u. (\<forall>x \<in> s. 0 < u x \<and> u x < 1) \<and> setsum u s = 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y}
 18.2132 +         \<Longrightarrow> {y. \<exists>u. (\<forall>x \<in> s. 0 < u x \<and> u x < 1) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}
 18.2133               \<subseteq> rel_interior (convex hull s)"
 18.2134    by (force simp add:  rel_interior_convex_hull_union [where S="\<lambda>x. {x}" and I=s, simplified])
 18.2135  
 18.2136  lemma explicit_subset_rel_interior_convex_hull_minimal:
 18.2137    fixes s :: "'a::euclidean_space set"
 18.2138    shows "finite s
 18.2139 -         \<Longrightarrow> {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> setsum u s = 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y}
 18.2140 +         \<Longrightarrow> {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}
 18.2141               \<subseteq> rel_interior (convex hull s)"
 18.2142    by (force simp add:  rel_interior_convex_hull_union [where S="\<lambda>x. {x}" and I=s, simplified])
 18.2143  
 18.2144 @@ -10905,7 +10905,7 @@
 18.2145    fixes s :: "'a::euclidean_space set"
 18.2146    assumes "~ affine_dependent s"
 18.2147    shows "rel_interior(convex hull s) =
 18.2148 -         {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> setsum u s = 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y}"
 18.2149 +         {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
 18.2150           (is "?lhs = ?rhs")
 18.2151  proof
 18.2152    show "?rhs \<le> ?lhs"
 18.2153 @@ -10926,14 +10926,14 @@
 18.2154        have "(\<Sum>x\<in>s. if x = a then - d else if x = b then d else 0) = 0"
 18.2155             "(\<Sum>x\<in>s. (if x = a then - d else if x = b then d else 0) *\<^sub>R x) = d *\<^sub>R b - d *\<^sub>R a"
 18.2156          using ab fs
 18.2157 -        by (subst s, subst setsum.union_disjoint, auto)+
 18.2158 +        by (subst s, subst sum.union_disjoint, auto)+
 18.2159      } note [simp] = this
 18.2160      { fix y
 18.2161        assume y: "y \<in> convex hull s" "y \<notin> ?rhs"
 18.2162        { fix u T a
 18.2163 -        assume ua: "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = 1" "\<not> 0 < u a" "a \<in> s"
 18.2164 +        assume ua: "\<forall>x\<in>s. 0 \<le> u x" "sum u s = 1" "\<not> 0 < u a" "a \<in> s"
 18.2165             and yT: "y = (\<Sum>x\<in>s. u x *\<^sub>R x)" "y \<in> T" "open T"
 18.2166 -           and sb: "T \<inter> affine hull s \<subseteq> {w. \<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = w}"
 18.2167 +           and sb: "T \<inter> affine hull s \<subseteq> {w. \<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = w}"
 18.2168          have ua0: "u a = 0"
 18.2169            using ua by auto
 18.2170          obtain b where b: "b\<in>s" "a \<noteq> b"
 18.2171 @@ -10949,7 +10949,7 @@
 18.2172          then have "y - d *\<^sub>R (a - b) \<in> T \<inter> affine hull s"
 18.2173            using d e yT by auto
 18.2174          then obtain v where "\<forall>x\<in>s. 0 \<le> v x"
 18.2175 -                            "setsum v s = 1"
 18.2176 +                            "sum v s = 1"
 18.2177                              "(\<Sum>x\<in>s. v x *\<^sub>R x) = (\<Sum>x\<in>s. u x *\<^sub>R x) - d *\<^sub>R (a - b)"
 18.2178            using subsetD [OF sb] yT
 18.2179            by auto
 18.2180 @@ -10958,7 +10958,7 @@
 18.2181            apply (simp add: affine_dependent_explicit_finite fs)
 18.2182            apply (drule_tac x="\<lambda>x. (v x - u x) - (if x = a then -d else if x = b then d else 0)" in spec)
 18.2183            using ua b d
 18.2184 -          apply (auto simp: algebra_simps setsum_subtractf setsum.distrib)
 18.2185 +          apply (auto simp: algebra_simps sum_subtractf sum.distrib)
 18.2186            done
 18.2187        } note * = this
 18.2188        have "y \<notin> rel_interior (convex hull s)"
 18.2189 @@ -10979,7 +10979,7 @@
 18.2190     "~ affine_dependent s
 18.2191          ==> interior(convex hull s) =
 18.2192               (if card(s) \<le> DIM('a) then {}
 18.2193 -              else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> setsum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
 18.2194 +              else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
 18.2195    apply (simp add: aff_independent_finite empty_interior_convex_hull, clarify)
 18.2196    apply (rule trans [of _ "rel_interior(convex hull s)"])
 18.2197    apply (simp add: affine_hull_convex_hull affine_independent_span_gt rel_interior_interior)
 18.2198 @@ -10991,10 +10991,10 @@
 18.2199    shows
 18.2200     "interior(convex hull s) =
 18.2201               (if card(s) \<le> DIM('a) then {}
 18.2202 -              else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x \<and> u x < 1) \<and> setsum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
 18.2203 +              else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x \<and> u x < 1) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
 18.2204  proof -
 18.2205    { fix u :: "'a \<Rightarrow> real" and a
 18.2206 -    assume "card Basis < card s" and u: "\<And>x. x\<in>s \<Longrightarrow> 0 < u x" "setsum u s = 1" and a: "a \<in> s"
 18.2207 +    assume "card Basis < card s" and u: "\<And>x. x\<in>s \<Longrightarrow> 0 < u x" "sum u s = 1" and a: "a \<in> s"
 18.2208      then have cs: "Suc 0 < card s"
 18.2209        by (metis DIM_positive less_trans_Suc)
 18.2210      obtain b where b: "b \<in> s" "a \<noteq> b"
 18.2211 @@ -11007,10 +11007,10 @@
 18.2212        then show thesis
 18.2213        by (blast intro: that)
 18.2214      qed
 18.2215 -    have "u a + u b \<le> setsum u {a,b}"
 18.2216 +    have "u a + u b \<le> sum u {a,b}"
 18.2217        using a b by simp
 18.2218 -    also have "... \<le> setsum u s"
 18.2219 -      apply (rule Groups_Big.setsum_mono2)
 18.2220 +    also have "... \<le> sum u s"
 18.2221 +      apply (rule Groups_Big.sum_mono2)
 18.2222        using a b u
 18.2223        apply (auto simp: less_imp_le aff_independent_finite assms)
 18.2224        done
 18.2225 @@ -11156,7 +11156,7 @@
 18.2226    fixes s :: "'a::euclidean_space set"
 18.2227    assumes "~ affine_dependent s"
 18.2228    shows "rel_frontier(convex hull s) =
 18.2229 -         {y. \<exists>u. (\<forall>x \<in> s. 0 \<le> u x) \<and> (\<exists>x \<in> s. u x = 0) \<and> setsum u s = 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y}"
 18.2230 +         {y. \<exists>u. (\<forall>x \<in> s. 0 \<le> u x) \<and> (\<exists>x \<in> s. u x = 0) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
 18.2231  proof -
 18.2232    have fs: "finite s"
 18.2233      using assms by (simp add: aff_independent_finite)
 18.2234 @@ -11172,7 +11172,7 @@
 18.2235      apply (rule_tac x=s in exI)
 18.2236      apply (auto simp: fs)
 18.2237      apply (rule_tac x = "\<lambda>x. u x - v x" in exI)
 18.2238 -    apply (force simp: setsum_subtractf scaleR_diff_left)
 18.2239 +    apply (force simp: sum_subtractf scaleR_diff_left)
 18.2240      done
 18.2241  qed
 18.2242  
 18.2243 @@ -11181,7 +11181,7 @@
 18.2244    assumes "~ affine_dependent s"
 18.2245    shows "frontier(convex hull s) =
 18.2246           {y. \<exists>u. (\<forall>x \<in> s. 0 \<le> u x) \<and> (DIM ('a) < card s \<longrightarrow> (\<exists>x \<in> s. u x = 0)) \<and>
 18.2247 -             setsum u s = 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y}"
 18.2248 +             sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
 18.2249  proof -
 18.2250    have fs: "finite s"
 18.2251      using assms by (simp add: aff_independent_finite)
 18.2252 @@ -11211,21 +11211,21 @@
 18.2253    have fs: "finite s"
 18.2254      using assms by (simp add: aff_independent_finite)
 18.2255    { fix u a
 18.2256 -  have "\<forall>x\<in>s. 0 \<le> u x \<Longrightarrow> a \<in> s \<Longrightarrow> u a = 0 \<Longrightarrow> setsum u s = 1 \<Longrightarrow>
 18.2257 +  have "\<forall>x\<in>s. 0 \<le> u x \<Longrightarrow> a \<in> s \<Longrightarrow> u a = 0 \<Longrightarrow> sum u s = 1 \<Longrightarrow>
 18.2258              \<exists>x v. x \<in> s \<and>
 18.2259                    (\<forall>x\<in>s - {x}. 0 \<le> v x) \<and>
 18.2260 -                      setsum v (s - {x}) = 1 \<and> (\<Sum>x\<in>s - {x}. v x *\<^sub>R x) = (\<Sum>x\<in>s. u x *\<^sub>R x)"
 18.2261 +                      sum v (s - {x}) = 1 \<and> (\<Sum>x\<in>s - {x}. v x *\<^sub>R x) = (\<Sum>x\<in>s. u x *\<^sub>R x)"
 18.2262      apply (rule_tac x=a in exI)
 18.2263      apply (rule_tac x=u in exI)
 18.2264 -    apply (simp add: Groups_Big.setsum_diff1 fs)
 18.2265 +    apply (simp add: Groups_Big.sum_diff1 fs)
 18.2266      done }
 18.2267    moreover
 18.2268    { fix a u
 18.2269 -    have "a \<in> s \<Longrightarrow> \<forall>x\<in>s - {a}. 0 \<le> u x \<Longrightarrow> setsum u (s - {a}) = 1 \<Longrightarrow>
 18.2270 +    have "a \<in> s \<Longrightarrow> \<forall>x\<in>s - {a}. 0 \<le> u x \<Longrightarrow> sum u (s - {a}) = 1 \<Longrightarrow>
 18.2271              \<exists>v. (\<forall>x\<in>s. 0 \<le> v x) \<and>
 18.2272 -                 (\<exists>x\<in>s. v x = 0) \<and> setsum v s = 1 \<and> (\<Sum>x\<in>s. v x *\<^sub>R x) = (\<Sum>x\<in>s - {a}. u x *\<^sub>R x)"
 18.2273 +                 (\<exists>x\<in>s. v x = 0) \<and> sum v s = 1 \<and> (\<Sum>x\<in>s. v x *\<^sub>R x) = (\<Sum>x\<in>s - {a}. u x *\<^sub>R x)"
 18.2274      apply (rule_tac x="\<lambda>x. if x = a then 0 else u x" in exI)
 18.2275 -    apply (auto simp: setsum.If_cases Diff_eq if_smult fs)
 18.2276 +    apply (auto simp: sum.If_cases Diff_eq if_smult fs)
 18.2277      done }
 18.2278    ultimately show ?thesis
 18.2279      using assms
 18.2280 @@ -12496,7 +12496,7 @@
 18.2281      have "x = (\<Sum>b\<in>Basis. (x \<bullet> b) *\<^sub>R b)"
 18.2282        by (simp add: euclidean_representation)
 18.2283      also have "... = (\<Sum>b \<in> Basis - {k}. (x \<bullet> b) *\<^sub>R b)"
 18.2284 -      by (auto simp: setsum.remove [of _ k] inner_commute assms that)
 18.2285 +      by (auto simp: sum.remove [of _ k] inner_commute assms that)
 18.2286      finally have "x = (\<Sum>b\<in>Basis - {k}. (x \<bullet> b) *\<^sub>R b)" .
 18.2287      then show ?thesis
 18.2288        by (simp add: Linear_Algebra.span_finite) metis
 18.2289 @@ -12960,20 +12960,20 @@
 18.2290  proof -
 18.2291    have [simp]: "finite s" "finite t"
 18.2292      using aff_independent_finite assms by blast+
 18.2293 -    have "setsum u (s \<inter> t) = 1 \<and>
 18.2294 +    have "sum u (s \<inter> t) = 1 \<and>
 18.2295            (\<Sum>v\<in>s \<inter> t. u v *\<^sub>R v) = (\<Sum>v\<in>s. u v *\<^sub>R v)"
 18.2296 -      if [simp]:  "setsum u s = 1"
 18.2297 -                 "setsum v t = 1"
 18.2298 +      if [simp]:  "sum u s = 1"
 18.2299 +                 "sum v t = 1"
 18.2300           and eq: "(\<Sum>x\<in>t. v x *\<^sub>R x) = (\<Sum>x\<in>s. u x *\<^sub>R x)" for u v
 18.2301      proof -
 18.2302      define f where "f x = (if x \<in> s then u x else 0) - (if x \<in> t then v x else 0)" for x
 18.2303 -    have "setsum f (s \<union> t) = 0"
 18.2304 -      apply (simp add: f_def setsum_Un setsum_subtractf)
 18.2305 -      apply (simp add: setsum.inter_restrict [symmetric] Int_commute)
 18.2306 +    have "sum f (s \<union> t) = 0"
 18.2307 +      apply (simp add: f_def sum_Un sum_subtractf)
 18.2308 +      apply (simp add: sum.inter_restrict [symmetric] Int_commute)
 18.2309        done
 18.2310      moreover have "(\<Sum>x\<in>(s \<union> t). f x *\<^sub>R x) = 0"
 18.2311 -      apply (simp add: f_def setsum_Un scaleR_left_diff_distrib setsum_subtractf)
 18.2312 -      apply (simp add: if_smult setsum.inter_restrict [symmetric] Int_commute eq
 18.2313 +      apply (simp add: f_def sum_Un scaleR_left_diff_distrib sum_subtractf)
 18.2314 +      apply (simp add: if_smult sum.inter_restrict [symmetric] Int_commute eq
 18.2315            cong del: if_weak_cong)
 18.2316        done
 18.2317      ultimately have "\<And>v. v \<in> s \<union> t \<Longrightarrow> f v = 0"
 18.2318 @@ -12981,12 +12981,12 @@
 18.2319        by blast
 18.2320      then have u [simp]: "\<And>x. x \<in> s \<Longrightarrow> u x = (if x \<in> t then v x else 0)"
 18.2321        by (simp add: f_def) presburger
 18.2322 -    have "setsum u (s \<inter> t) = setsum u s"
 18.2323 -      by (simp add: setsum.inter_restrict)
 18.2324 -    then have "setsum u (s \<inter> t) = 1"
 18.2325 +    have "sum u (s \<inter> t) = sum u s"
 18.2326 +      by (simp add: sum.inter_restrict)
 18.2327 +    then have "sum u (s \<inter> t) = 1"
 18.2328        using that by linarith
 18.2329      moreover have "(\<Sum>v\<in>s \<inter> t. u v *\<^sub>R v) = (\<Sum>v\<in>s. u v *\<^sub>R v)"
 18.2330 -      by (auto simp: if_smult setsum.inter_restrict intro: setsum.cong)
 18.2331 +      by (auto simp: if_smult sum.inter_restrict intro: sum.cong)
 18.2332      ultimately show ?thesis
 18.2333        by force
 18.2334      qed
 18.2335 @@ -13063,19 +13063,19 @@
 18.2336    have [simp]: "finite S"
 18.2337      by (simp add: aff_independent_finite assms)
 18.2338    then obtain b where b0: "\<And>s. s \<in> S \<Longrightarrow> 0 \<le> b s"
 18.2339 -                  and b1: "setsum b S = 1" and aeq: "a = (\<Sum>s\<in>S. b s *\<^sub>R s)"
 18.2340 +                  and b1: "sum b S = 1" and aeq: "a = (\<Sum>s\<in>S. b s *\<^sub>R s)"
 18.2341      using a by (auto simp: convex_hull_finite)
 18.2342    have fin [simp]: "finite T" "finite T'"
 18.2343      using assms infinite_super \<open>finite S\<close> by blast+
 18.2344    then obtain c c' where c0: "\<And>t. t \<in> insert a T \<Longrightarrow> 0 \<le> c t"
 18.2345 -                     and c1: "setsum c (insert a T) = 1"
 18.2346 +                     and c1: "sum c (insert a T) = 1"
 18.2347                       and xeq: "x = (\<Sum>t \<in> insert a T. c t *\<^sub>R t)"
 18.2348                       and c'0: "\<And>t. t \<in> insert a T' \<Longrightarrow> 0 \<le> c' t"
 18.2349 -                     and c'1: "setsum c' (insert a T') = 1"
 18.2350 +                     and c'1: "sum c' (insert a T') = 1"
 18.2351                       and x'eq: "x = (\<Sum>t \<in> insert a T'. c' t *\<^sub>R t)"
 18.2352      using x x' by (auto simp: convex_hull_finite)
 18.2353    with fin anot
 18.2354 -  have sumTT': "setsum c T = 1 - c a" "setsum c' T' = 1 - c' a"
 18.2355 +  have sumTT': "sum c T = 1 - c a" "sum c' T' = 1 - c' a"
 18.2356     and wsumT: "(\<Sum>t \<in> T. c t *\<^sub>R t) = x - c a *\<^sub>R a"
 18.2357      by simp_all
 18.2358    have wsumT': "(\<Sum>t \<in> T'. c' t *\<^sub>R t) = x - c' a *\<^sub>R a"
 18.2359 @@ -13083,23 +13083,23 @@
 18.2360    define cc  where "cc \<equiv> \<lambda>x. if x \<in> T then c x else 0"
 18.2361    define cc' where "cc' \<equiv> \<lambda>x. if x \<in> T' then c' x else 0"
 18.2362    define dd  where "dd \<equiv> \<lambda>x. cc x - cc' x + (c a - c' a) * b x"
 18.2363 -  have sumSS': "setsum cc S = 1 - c a" "setsum cc' S = 1 - c' a"
 18.2364 +  have sumSS': "sum cc S = 1 - c a" "sum cc' S = 1 - c' a"
 18.2365      unfolding cc_def cc'_def  using S
 18.2366 -    by (simp_all add: Int_absorb1 Int_absorb2 setsum_subtractf setsum.inter_restrict [symmetric] sumTT')
 18.2367 +    by (simp_all add: Int_absorb1 Int_absorb2 sum_subtractf sum.inter_restrict [symmetric] sumTT')
 18.2368    have wsumSS: "(\<Sum>t \<in> S. cc t *\<^sub>R t) = x - c a *\<^sub>R a" "(\<Sum>t \<in> S. cc' t *\<^sub>R t) = x - c' a *\<^sub>R a"
 18.2369      unfolding cc_def cc'_def  using S
 18.2370 -    by (simp_all add: Int_absorb1 Int_absorb2 if_smult setsum.inter_restrict [symmetric] wsumT wsumT' cong: if_cong)
 18.2371 -  have sum_dd0: "setsum dd S = 0"
 18.2372 +    by (simp_all add: Int_absorb1 Int_absorb2 if_smult sum.inter_restrict [symmetric] wsumT wsumT' cong: if_cong)
 18.2373 +  have sum_dd0: "sum dd S = 0"
 18.2374      unfolding dd_def  using S
 18.2375 -    by (simp add: sumSS' comm_monoid_add_class.setsum.distrib setsum_subtractf
 18.2376 -                  algebra_simps setsum_distrib_right [symmetric] b1)
 18.2377 +    by (simp add: sumSS' comm_monoid_add_class.sum.distrib sum_subtractf
 18.2378 +                  algebra_simps sum_distrib_right [symmetric] b1)
 18.2379    have "(\<Sum>v\<in>S. (b v * x) *\<^sub>R v) = x *\<^sub>R (\<Sum>v\<in>S. b v *\<^sub>R v)" for x
 18.2380 -    by (simp add: pth_5 real_vector.scale_setsum_right mult.commute)
 18.2381 +    by (simp add: pth_5 real_vector.scale_sum_right mult.commute)
 18.2382    then have *: "(\<Sum>v\<in>S. (b v * x) *\<^sub>R v) = x *\<^sub>R a" for x
 18.2383      using aeq by blast
 18.2384    have "(\<Sum>v \<in> S. dd v *\<^sub>R v) = 0"
 18.2385      unfolding dd_def using S
 18.2386 -    by (simp add: * wsumSS setsum.distrib setsum_subtractf algebra_simps)
 18.2387 +    by (simp add: * wsumSS sum.distrib sum_subtractf algebra_simps)
 18.2388    then have dd0: "dd v = 0" if "v \<in> S" for v
 18.2389      using naff that \<open>finite S\<close> sum_dd0 unfolding affine_dependent_explicit
 18.2390      apply (simp only: not_ex)
 18.2391 @@ -13110,7 +13110,7 @@
 18.2392    then show ?thesis
 18.2393    proof cases
 18.2394      case 1
 18.2395 -    then have "setsum cc S \<le> setsum cc' S"
 18.2396 +    then have "sum cc S \<le> sum cc' S"
 18.2397        by (simp add: sumSS')
 18.2398      then have le: "cc x \<le> cc' x" if "x \<in> S" for x
 18.2399        using dd0 [OF that] 1 b0 mult_left_mono that
 18.2400 @@ -13124,32 +13124,32 @@
 18.2401          by (simp add: c0 cc_def)
 18.2402        show "0 \<le> (cc(a := c a)) a"
 18.2403          by (simp add: c0)
 18.2404 -      have "setsum (cc(a := c a)) (insert a (T \<inter> T')) = c a + setsum (cc(a := c a)) (T \<inter> T')"
 18.2405 +      have "sum (cc(a := c a)) (insert a (T \<inter> T')) = c a + sum (cc(a := c a)) (T \<inter> T')"
 18.2406          by (simp add: anot)
 18.2407 -      also have "... = c a + setsum (cc(a := c a)) S"
 18.2408 +      also have "... = c a + sum (cc(a := c a)) S"
 18.2409          apply simp
 18.2410 -        apply (rule setsum.mono_neutral_left)
 18.2411 +        apply (rule sum.mono_neutral_left)
 18.2412          using \<open>T \<subseteq> S\<close> apply (auto simp: \<open>a \<notin> S\<close> cc0)
 18.2413          done
 18.2414        also have "... = c a + (1 - c a)"
 18.2415 -        by (metis \<open>a \<notin> S\<close> fun_upd_other setsum.cong sumSS')
 18.2416 -      finally show "setsum (cc(a := c a)) (insert a (T \<inter> T')) = 1"
 18.2417 +        by (metis \<open>a \<notin> S\<close> fun_upd_other sum.cong sumSS')
 18.2418 +      finally show "sum (cc(a := c a)) (insert a (T \<inter> T')) = 1"
 18.2419          by simp
 18.2420        have "(\<Sum>x\<in>insert a (T \<inter> T'). (cc(a := c a)) x *\<^sub>R x) = c a *\<^sub>R a + (\<Sum>x \<in> T \<inter> T'. (cc(a := c a)) x *\<^sub>R x)"
 18.2421          by (simp add: anot)
 18.2422        also have "... = c a *\<^sub>R a + (\<Sum>x \<in> S. (cc(a := c a)) x *\<^sub>R x)"
 18.2423          apply simp
 18.2424 -        apply (rule setsum.mono_neutral_left)
 18.2425 +        apply (rule sum.mono_neutral_left)
 18.2426          using \<open>T \<subseteq> S\<close> apply (auto simp: \<open>a \<notin> S\<close> cc0)
 18.2427          done
 18.2428        also have "... = c a *\<^sub>R a + x - c a *\<^sub>R a"
 18.2429 -        by (simp add: wsumSS \<open>a \<notin> S\<close> if_smult setsum_delta_notmem)
 18.2430 +        by (simp add: wsumSS \<open>a \<notin> S\<close> if_smult sum_delta_notmem)
 18.2431        finally show "(\<Sum>x\<in>insert a (T \<inter> T'). (cc(a := c a)) x *\<^sub>R x) = x"
 18.2432          by simp
 18.2433      qed
 18.2434    next
 18.2435      case 2
 18.2436 -    then have "setsum cc' S \<le> setsum cc S"
 18.2437 +    then have "sum cc' S \<le> sum cc S"
 18.2438        by (simp add: sumSS')
 18.2439      then have le: "cc' x \<le> cc x" if "x \<in> S" for x
 18.2440        using dd0 [OF that] 2 b0 mult_left_mono that
 18.2441 @@ -13163,26 +13163,26 @@
 18.2442          by (simp add: c'0 cc'_def)
 18.2443        show "0 \<le> (cc'(a := c' a)) a"
 18.2444          by (simp add: c'0)
 18.2445 -      have "setsum (cc'(a := c' a)) (insert a (T \<inter> T')) = c' a + setsum (cc'(a := c' a)) (T \<inter> T')"
 18.2446 +      have "sum (cc'(a := c' a)) (insert a (T \<inter> T')) = c' a + sum (cc'(a := c' a)) (T \<inter> T')"
 18.2447          by (simp add: anot)
 18.2448 -      also have "... = c' a + setsum (cc'(a := c' a)) S"
 18.2449 +      also have "... = c' a + sum (cc'(a := c' a)) S"
 18.2450          apply simp
 18.2451 -        apply (rule setsum.mono_neutral_left)
 18.2452 +        apply (rule sum.mono_neutral_left)
 18.2453          using \<open>T \<subseteq> S\<close> apply (auto simp: \<open>a \<notin> S\<close> cc0)
 18.2454          done
 18.2455        also have "... = c' a + (1 - c' a)"
 18.2456 -        by (metis \<open>a \<notin> S\<close> fun_upd_other setsum.cong sumSS')
 18.2457 -      finally show "setsum (cc'(a := c' a)) (insert a (T \<inter> T')) = 1"
 18.2458 +        by (metis \<open>a \<notin> S\<close> fun_upd_other sum.cong sumSS')
 18.2459 +      finally show "sum (cc'(a := c' a)) (insert a (T \<inter> T')) = 1"
 18.2460          by simp
 18.2461        have "(\<Sum>x\<in>insert a (T \<inter> T'). (cc'(a := c' a)) x *\<^sub>R x) = c' a *\<^sub>R a + (\<Sum>x \<in> T \<inter> T'. (cc'(a := c' a)) x *\<^sub>R x)"
 18.2462          by (simp add: anot)
 18.2463        also have "... = c' a *\<^sub>R a + (\<Sum>x \<in> S. (cc'(a := c' a)) x *\<^sub>R x)"
 18.2464          apply simp
 18.2465 -        apply (rule setsum.mono_neutral_left)
 18.2466 +        apply (rule sum.mono_neutral_left)
 18.2467          using \<open>T \<subseteq> S\<close> apply (auto simp: \<open>a \<notin> S\<close> cc0)
 18.2468          done
 18.2469        also have "... = c a *\<^sub>R a + x - c a *\<^sub>R a"
 18.2470 -        by (simp add: wsumSS \<open>a \<notin> S\<close> if_smult setsum_delta_notmem)
 18.2471 +        by (simp add: wsumSS \<open>a \<notin> S\<close> if_smult sum_delta_notmem)
 18.2472        finally show "(\<Sum>x\<in>insert a (T \<inter> T'). (cc'(a := c' a)) x *\<^sub>R x) = x"
 18.2473          by simp
 18.2474      qed
 18.2475 @@ -13458,10 +13458,10 @@
 18.2476      have "(\<Sum>v\<in>D - C. a v *\<^sub>R v) \<in> S"
 18.2477        apply (subst eq)
 18.2478        apply (rule subspace_neg [OF \<open>subspace S\<close>])
 18.2479 -      apply (rule subspace_setsum [OF \<open>subspace S\<close>])
 18.2480 +      apply (rule subspace_sum [OF \<open>subspace S\<close>])
 18.2481        by (meson subsetCE subspace_mul \<open>C \<subseteq> S\<close> \<open>subspace S\<close>)
 18.2482      moreover have "(\<Sum>v\<in>D - C. a v *\<^sub>R v) \<in> T"
 18.2483 -      apply (rule subspace_setsum [OF \<open>subspace T\<close>])
 18.2484 +      apply (rule subspace_sum [OF \<open>subspace T\<close>])
 18.2485        by (meson DiffD1 \<open>D \<subseteq> T\<close> \<open>subspace T\<close> subset_eq subspace_def)
 18.2486      ultimately have "(\<Sum>v \<in> D-C. a v *\<^sub>R v) \<in> span B"
 18.2487        using B by blast
 18.2488 @@ -13475,12 +13475,12 @@
 18.2489      have f2: "(\<Sum>v\<in>C \<inter> D. e v *\<^sub>R v) = (\<Sum>v\<in>D - C. a v *\<^sub>R v)"
 18.2490        using Beq e by presburger
 18.2491      have f3: "(\<Sum>v\<in>C \<union> D. a v *\<^sub>R v) = (\<Sum>v\<in>C - D. a v *\<^sub>R v) + (\<Sum>v\<in>D - C. a v *\<^sub>R v) + (\<Sum>v\<in>C \<inter> D. a v *\<^sub>R v)"
 18.2492 -      using \<open>finite C\<close> \<open>finite D\<close> setsum.union_diff2 by blast
 18.2493 +      using \<open>finite C\<close> \<open>finite D\<close> sum.union_diff2 by blast
 18.2494      have f4: "(\<Sum>v\<in>C \<union> (D - C). a v *\<^sub>R v) = (\<Sum>v\<in>C. a v *\<^sub>R v) + (\<Sum>v\<in>D - C. a v *\<^sub>R v)"
 18.2495 -      by (meson Diff_disjoint \<open>finite C\<close> \<open>finite D\<close> finite_Diff setsum.union_disjoint)
 18.2496 +      by (meson Diff_disjoint \<open>finite C\<close> \<open>finite D\<close> finite_Diff sum.union_disjoint)
 18.2497      have "(\<Sum>v\<in>C. cc v *\<^sub>R v) = 0"
 18.2498        using 0 f2 f3 f4
 18.2499 -      apply (simp add: cc_def Beq if_smult \<open>finite C\<close> setsum.If_cases algebra_simps setsum.distrib)
 18.2500 +      apply (simp add: cc_def Beq if_smult \<open>finite C\<close> sum.If_cases algebra_simps sum.distrib)
 18.2501        apply (simp add: add.commute add.left_commute diff_eq)
 18.2502        done
 18.2503      then have "\<And>v. v \<in> C \<Longrightarrow> cc v = 0"
 18.2504 @@ -13498,14 +13498,14 @@
 18.2505      qed
 18.2506      with 0 have Dcc0: "(\<Sum>v\<in>D. a v *\<^sub>R v) = 0"
 18.2507        apply (subst Deq)
 18.2508 -      by (simp add: \<open>finite B\<close> \<open>finite D\<close> setsum_Un)
 18.2509 +      by (simp add: \<open>finite B\<close> \<open>finite D\<close> sum_Un)
 18.2510      then have D0: "\<And>v. v \<in> D \<Longrightarrow> a v = 0"
 18.2511        using independent_explicit \<open>independent D\<close> by blast
 18.2512      show ?thesis
 18.2513        using v C0 D0 Beq by blast
 18.2514    qed
 18.2515    then have "independent (C \<union> (D - C))"
 18.2516 -    by (simp add: independent_explicit \<open>finite C\<close> \<open>finite D\<close> setsum_Un del: Un_Diff_cancel)
 18.2517 +    by (simp add: independent_explicit \<open>finite C\<close> \<open>finite D\<close> sum_Un del: Un_Diff_cancel)
 18.2518    then have indCUD: "independent (C \<union> D)" by simp
 18.2519    have "dim (S \<inter> T) = card B"
 18.2520      by (rule dim_unique [OF B indB refl])
 18.2521 @@ -13660,8 +13660,8 @@
 18.2522      then have "a \<bullet> a = a \<bullet> (\<Sum>v\<in>T. U v *\<^sub>R v)"
 18.2523        by simp
 18.2524      also have "... = 0"
 18.2525 -      apply (simp add: inner_setsum_right)
 18.2526 -      apply (rule comm_monoid_add_class.setsum.neutral)
 18.2527 +      apply (simp add: inner_sum_right)
 18.2528 +      apply (rule comm_monoid_add_class.sum.neutral)
 18.2529        by (metis "0" DiffE \<open>T \<subseteq> S - {a}\<close> mult_not_zero singletonI subsetCE \<open>a \<in> S\<close>)
 18.2530      finally show ?thesis
 18.2531        using \<open>0 \<notin> S\<close> \<open>a \<in> S\<close> by auto
 18.2532 @@ -13707,12 +13707,12 @@
 18.2533         if "x \<in> S" for x
 18.2534    proof -
 18.2535      have "a \<bullet> x = (\<Sum>y\<in>S. if y = x then y \<bullet> a else 0)"
 18.2536 -      by (simp add: \<open>finite S\<close> inner_commute setsum.delta that)
 18.2537 +      by (simp add: \<open>finite S\<close> inner_commute sum.delta that)
 18.2538      also have "... =  (\<Sum>b\<in>S. b \<bullet> a * (b \<bullet> x) / (b \<bullet> b))"
 18.2539 -      apply (rule setsum.cong [OF refl], simp)
 18.2540 +      apply (rule sum.cong [OF refl], simp)
 18.2541        by (meson S orthogonal_def pairwise_def that)
 18.2542     finally show ?thesis
 18.2543 -     by (simp add: orthogonal_def algebra_simps inner_setsum_left)
 18.2544 +     by (simp add: orthogonal_def algebra_simps inner_sum_left)
 18.2545    qed
 18.2546    then show ?thesis
 18.2547      using orthogonal_to_span orthogonal_commute x by blast
 18.2548 @@ -13746,7 +13746,7 @@
 18.2549      using spanU by simp
 18.2550    also have "... = span (insert a (S \<union> T))"
 18.2551      apply (rule eq_span_insert_eq)
 18.2552 -    apply (simp add: a'_def span_neg span_setsum span_clauses(1) span_mul)
 18.2553 +    apply (simp add: a'_def span_neg span_sum span_clauses(1) span_mul)
 18.2554      done
 18.2555    also have "... = span (S \<union> insert a T)"
 18.2556      by simp
 18.2557 @@ -13866,7 +13866,7 @@
 18.2558      by (simp add: Gram_Schmidt_step \<open>pairwise orthogonal T\<close> \<open>span T = span S\<close> orthogonal_commute that)
 18.2559    show ?thesis
 18.2560      apply (rule_tac y = "?a" and z = "x - ?a" in that)
 18.2561 -      apply (meson \<open>T \<subseteq> span S\<close> span_mul span_setsum subsetCE)
 18.2562 +      apply (meson \<open>T \<subseteq> span S\<close> span_mul span_sum subsetCE)
 18.2563       apply (fact orth, simp)
 18.2564      done
 18.2565  qed
    19.1 --- a/src/HOL/Analysis/Derivative.thy	Sun Oct 16 22:43:51 2016 +0200
    19.2 +++ b/src/HOL/Analysis/Derivative.thy	Mon Oct 17 11:46:22 2016 +0200
    19.3 @@ -2195,13 +2195,13 @@
    19.4    fixes f :: "nat \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::banach"
    19.5    assumes "convex s"
    19.6      and "\<And>n x. x \<in> s \<Longrightarrow> ((f n) has_derivative (f' n x)) (at x within s)"
    19.7 -    and "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (setsum (\<lambda>i. f' i x h) {..<n} - g' x h) \<le> e * norm h"
    19.8 +    and "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (sum (\<lambda>i. f' i x h) {..<n} - g' x h) \<le> e * norm h"
    19.9      and "x \<in> s"
   19.10      and "(\<lambda>n. f n x) sums l"
   19.11    shows "\<exists>g. \<forall>x\<in>s. (\<lambda>n. f n x) sums (g x) \<and> (g has_derivative g' x) (at x within s)"
   19.12    unfolding sums_def
   19.13    apply (rule has_derivative_sequence[OF assms(1) _ assms(3)])
   19.14 -  apply (metis assms(2) has_derivative_setsum)
   19.15 +  apply (metis assms(2) has_derivative_sum)
   19.16    using assms(4-5)
   19.17    unfolding sums_def
   19.18    apply auto
   19.19 @@ -2224,7 +2224,7 @@
   19.20      {
   19.21        fix n :: nat and x h :: 'a assume nx: "n \<ge> N" "x \<in> s"
   19.22        have "norm ((\<Sum>i<n. f' i x * h) - g' x * h) = norm ((\<Sum>i<n. f' i x) - g' x) * norm h"
   19.23 -        by (simp add: norm_mult [symmetric] ring_distribs setsum_distrib_right)
   19.24 +        by (simp add: norm_mult [symmetric] ring_distribs sum_distrib_right)
   19.25        also from N[OF nx] have "norm ((\<Sum>i<n. f' i x) - g' x) \<le> e" by simp
   19.26        hence "norm ((\<Sum>i<n. f' i x) - g' x) * norm h \<le> e * norm h"
   19.27          by (intro mult_right_mono) simp_all
   19.28 @@ -2591,7 +2591,7 @@
   19.29      "\<forall>\<^sub>F n in sequentially. ((\<lambda>x. \<Sum>i<n. ?e i x) \<longlongrightarrow> A) ?F"
   19.30      by eventually_elim
   19.31        (auto intro!: tendsto_eq_intros
   19.32 -        simp: power_0_left if_distrib cond_application_beta setsum.delta
   19.33 +        simp: power_0_left if_distrib cond_application_beta sum.delta
   19.34          cong: if_cong)
   19.35    ultimately
   19.36    have [tendsto_intros]: "((\<lambda>x. \<Sum>i. ?e i x) \<longlongrightarrow> A) ?F"
    20.1 --- a/src/HOL/Analysis/Determinants.thy	Sun Oct 16 22:43:51 2016 +0200
    20.2 +++ b/src/HOL/Analysis/Determinants.thy	Mon Oct 17 11:46:22 2016 +0200
    20.3 @@ -13,7 +13,7 @@
    20.4  subsection \<open>Trace\<close>
    20.5  
    20.6  definition trace :: "'a::semiring_1^'n^'n \<Rightarrow> 'a"
    20.7 -  where "trace A = setsum (\<lambda>i. ((A$i)$i)) (UNIV::'n set)"
    20.8 +  where "trace A = sum (\<lambda>i. ((A$i)$i)) (UNIV::'n set)"
    20.9  
   20.10  lemma trace_0: "trace (mat 0) = 0"
   20.11    by (simp add: trace_def mat_def)
   20.12 @@ -22,14 +22,14 @@
   20.13    by (simp add: trace_def mat_def)
   20.14  
   20.15  lemma trace_add: "trace ((A::'a::comm_semiring_1^'n^'n) + B) = trace A + trace B"
   20.16 -  by (simp add: trace_def setsum.distrib)
   20.17 +  by (simp add: trace_def sum.distrib)
   20.18  
   20.19  lemma trace_sub: "trace ((A::'a::comm_ring_1^'n^'n) - B) = trace A - trace B"
   20.20 -  by (simp add: trace_def setsum_subtractf)
   20.21 +  by (simp add: trace_def sum_subtractf)
   20.22  
   20.23  lemma trace_mul_sym: "trace ((A::'a::comm_semiring_1^'n^'m) ** B) = trace (B**A)"
   20.24    apply (simp add: trace_def matrix_matrix_mult_def)
   20.25 -  apply (subst setsum.commute)
   20.26 +  apply (subst sum.commute)
   20.27    apply (simp add: mult.commute)
   20.28    done
   20.29  
   20.30 @@ -37,7 +37,7 @@
   20.31  
   20.32  definition det:: "'a::comm_ring_1^'n^'n \<Rightarrow> 'a" where
   20.33    "det A =
   20.34 -    setsum (\<lambda>p. of_int (sign p) * setprod (\<lambda>i. A$i$p i) (UNIV :: 'n set))
   20.35 +    sum (\<lambda>p. of_int (sign p) * setprod (\<lambda>i. A$i$p i) (UNIV :: 'n set))
   20.36        {p. p permutes (UNIV :: 'n set)}"
   20.37  
   20.38  text \<open>A few general lemmas we need below.\<close>
   20.39 @@ -94,8 +94,8 @@
   20.40    }
   20.41    then show ?thesis
   20.42      unfolding det_def
   20.43 -    apply (subst setsum_permutations_inverse)
   20.44 -    apply (rule setsum.cong)
   20.45 +    apply (subst sum_permutations_inverse)
   20.46 +    apply (rule sum.cong)
   20.47      apply (rule refl)
   20.48      apply blast
   20.49      done
   20.50 @@ -128,7 +128,7 @@
   20.51    }
   20.52    then have p0: "\<forall>p \<in> ?PU - {id}. ?pp p = 0"
   20.53      by blast
   20.54 -  from setsum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis
   20.55 +  from sum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis
   20.56      unfolding det_def by (simp add: sign_id)
   20.57  qed
   20.58  
   20.59 @@ -159,7 +159,7 @@
   20.60    }
   20.61    then have p0: "\<forall>p \<in> ?PU -{id}. ?pp p = 0"
   20.62      by blast
   20.63 -  from setsum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis
   20.64 +  from sum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis
   20.65      unfolding det_def by (simp add: sign_id)
   20.66  qed
   20.67  
   20.68 @@ -189,7 +189,7 @@
   20.69    }
   20.70    then have p0: "\<forall>p \<in> ?PU - {id}. ?pp p = 0"
   20.71      by blast
   20.72 -  from setsum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis
   20.73 +  from sum.mono_neutral_cong_left[OF fPU id0 p0] show ?thesis
   20.74      unfolding det_def by (simp add: sign_id)
   20.75  qed
   20.76  
   20.77 @@ -226,9 +226,9 @@
   20.78    fixes A :: "'a::comm_ring_1^'n^'n"
   20.79    assumes p: "p permutes (UNIV :: 'n::finite set)"
   20.80    shows "det (\<chi> i. A$p i :: 'a^'n^'n) = of_int (sign p) * det A"
   20.81 -  apply (simp add: det_def setsum_distrib_left mult.assoc[symmetric])
   20.82 +  apply (simp add: det_def sum_distrib_left mult.assoc[symmetric])
   20.83    apply (subst sum_permutations_compose_right[OF p])
   20.84 -proof (rule setsum.cong)
   20.85 +proof (rule sum.cong)
   20.86    let ?U = "UNIV :: 'n set"
   20.87    let ?PU = "{p. p permutes ?U}"
   20.88    fix q
   20.89 @@ -303,7 +303,7 @@
   20.90    shows "det A = 0"
   20.91    using r
   20.92    apply (simp add: row_def det_def vec_eq_iff)
   20.93 -  apply (rule setsum.neutral)
   20.94 +  apply (rule sum.neutral)
   20.95    apply (auto simp: sign_nz)
   20.96    done
   20.97  
   20.98 @@ -321,8 +321,8 @@
   20.99    shows "det((\<chi> i. if i = k then a i + b i else c i)::'a::comm_ring_1^'n^'n) =
  20.100      det((\<chi> i. if i = k then a i else c i)::'a::comm_ring_1^'n^'n) +
  20.101      det((\<chi> i. if i = k then b i else c i)::'a::comm_ring_1^'n^'n)"
  20.102 -  unfolding det_def vec_lambda_beta setsum.distrib[symmetric]
  20.103 -proof (rule setsum.cong)
  20.104 +  unfolding det_def vec_lambda_beta sum.distrib[symmetric]
  20.105 +proof (rule sum.cong)
  20.106    let ?U = "UNIV :: 'n set"
  20.107    let ?pU = "{p. p permutes ?U}"
  20.108    let ?f = "(\<lambda>i. if i = k then a i + b i else c i)::'n \<Rightarrow> 'a::comm_ring_1^'n"
  20.109 @@ -372,8 +372,8 @@
  20.110    fixes a b :: "'n::finite \<Rightarrow> _ ^ 'n"
  20.111    shows "det((\<chi> i. if i = k then c *s a i else b i)::'a::comm_ring_1^'n^'n) =
  20.112      c * det((\<chi> i. if i = k then a i else b i)::'a::comm_ring_1^'n^'n)"
  20.113 -  unfolding det_def vec_lambda_beta setsum_distrib_left
  20.114 -proof (rule setsum.cong)
  20.115 +  unfolding det_def vec_lambda_beta sum_distrib_left
  20.116 +proof (rule sum.cong)
  20.117    let ?U = "UNIV :: 'n set"
  20.118    let ?pU = "{p. p permutes ?U}"
  20.119    let ?f = "(\<lambda>i. if i = k then c*s a i else b i)::'n \<Rightarrow> 'a::comm_ring_1^'n"
  20.120 @@ -535,15 +535,15 @@
  20.121  lemma Cart_lambda_cong: "(\<And>x. f x = g x) \<Longrightarrow> (vec_lambda f::'a^'n) = (vec_lambda g :: 'a^'n)"
  20.122    by (rule iffD1[OF vec_lambda_unique]) vector
  20.123  
  20.124 -lemma det_linear_row_setsum:
  20.125 +lemma det_linear_row_sum:
  20.126    assumes fS: "finite S"
  20.127 -  shows "det ((\<chi> i. if i = k then setsum (a i) S else c i)::'a::comm_ring_1^'n^'n) =
  20.128 -    setsum (\<lambda>j. det ((\<chi> i. if i = k then a  i j else c i)::'a^'n^'n)) S"
  20.129 +  shows "det ((\<chi> i. if i = k then sum (a i) S else c i)::'a::comm_ring_1^'n^'n) =
  20.130 +    sum (\<lambda>j. det ((\<chi> i. if i = k then a  i j else c i)::'a^'n^'n)) S"
  20.131  proof (induct rule: finite_induct[OF fS])
  20.132    case 1
  20.133    then show ?case
  20.134      apply simp
  20.135 -    unfolding setsum.empty det_row_0[of k]
  20.136 +    unfolding sum.empty det_row_0[of k]
  20.137      apply rule
  20.138      done
  20.139  next
  20.140 @@ -577,11 +577,11 @@
  20.141  qed
  20.142  
  20.143  
  20.144 -lemma det_linear_rows_setsum_lemma:
  20.145 +lemma det_linear_rows_sum_lemma:
  20.146    assumes fS: "finite S"
  20.147      and fT: "finite T"
  20.148 -  shows "det ((\<chi> i. if i \<in> T then setsum (a i) S else c i):: 'a::comm_ring_1^'n^'n) =
  20.149 -    setsum (\<lambda>f. det((\<chi> i. if i \<in> T then a i (f i) else c i)::'a^'n^'n))
  20.150 +  shows "det ((\<chi> i. if i \<in> T then sum (a i) S else c i):: 'a::comm_ring_1^'n^'n) =
  20.151 +    sum (\<lambda>f. det((\<chi> i. if i \<in> T then a i (f i) else c i)::'a^'n^'n))
  20.152        {f. (\<forall>i \<in> T. f i \<in> S) \<and> (\<forall>i. i \<notin> T \<longrightarrow> f i = i)}"
  20.153    using fT
  20.154  proof (induct T arbitrary: a c set: finite)
  20.155 @@ -604,48 +604,48 @@
  20.156      by simp
  20.157    from \<open>z \<notin> T\<close> have nz: "\<And>i. i \<in> T \<Longrightarrow> i = z \<longleftrightarrow> False"
  20.158      by auto
  20.159 -  have "det (\<chi> i. if i \<in> insert z T then setsum (a i) S else c i) =
  20.160 -    det (\<chi> i. if i = z then setsum (a i) S else if i \<in> T then setsum (a i) S else c i)"
  20.161 +  have "det (\<chi> i. if i \<in> insert z T then sum (a i) S else c i) =
  20.162 +    det (\<chi> i. if i = z then sum (a i) S else if i \<in> T then sum (a i) S else c i)"
  20.163      unfolding insert_iff thif ..
  20.164 -  also have "\<dots> = (\<Sum>j\<in>S. det (\<chi> i. if i \<in> T then setsum (a i) S else if i = z then a i j else c i))"
  20.165 -    unfolding det_linear_row_setsum[OF fS]
  20.166 +  also have "\<dots> = (\<Sum>j\<in>S. det (\<chi> i. if i \<in> T then sum (a i) S else if i = z then a i j else c i))"
  20.167 +    unfolding det_linear_row_sum[OF fS]
  20.168      apply (subst thif2)
  20.169      using nz
  20.170      apply (simp cong del: if_weak_cong cong add: if_cong)
  20.171      done
  20.172    finally have tha:
  20.173 -    "det (\<chi> i. if i \<in> insert z T then setsum (a i) S else c i) =
  20.174 +    "det (\<chi> i. if i \<in> insert z T then sum (a i) S else c i) =
  20.175       (\<Sum>(j, f)\<in>S \<times> ?F T. det (\<chi> i. if i \<in> T then a i (f i)
  20.176                                  else if i = z then a i j
  20.177                                  else c i))"
  20.178 -    unfolding insert.hyps unfolding setsum.cartesian_product by blast
  20.179 +    unfolding insert.hyps unfolding sum.cartesian_product by blast
  20.180    show ?case unfolding tha
  20.181      using \<open>z \<notin> T\<close>
  20.182 -    by (intro setsum.reindex_bij_witness[where i="?k" and j="?h"])
  20.183 +    by (intro sum.reindex_bij_witness[where i="?k" and j="?h"])
  20.184         (auto intro!: cong[OF refl[of det]] simp: vec_eq_iff)
  20.185  qed
  20.186  
  20.187 -lemma det_linear_rows_setsum:
  20.188 +lemma det_linear_rows_sum:
  20.189    fixes S :: "'n::finite set"
  20.190    assumes fS: "finite S"
  20.191 -  shows "det (\<chi> i. setsum (a i) S) =
  20.192 -    setsum (\<lambda>f. det (\<chi> i. a i (f i) :: 'a::comm_ring_1 ^ 'n^'n)) {f. \<forall>i. f i \<in> S}"
  20.193 +  shows "det (\<chi> i. sum (a i) S) =
  20.194 +    sum (\<lambda>f. det (\<chi> i. a i (f i) :: 'a::comm_ring_1 ^ 'n^'n)) {f. \<forall>i. f i \<in> S}"
  20.195  proof -
  20.196    have th0: "\<And>x y. ((\<chi> i. if i \<in> (UNIV:: 'n set) then x i else y i) :: 'a^'n^'n) = (\<chi> i. x i)"
  20.197      by vector
  20.198 -  from det_linear_rows_setsum_lemma[OF fS, of "UNIV :: 'n set" a, unfolded th0, OF finite]
  20.199 +  from det_linear_rows_sum_lemma[OF fS, of "UNIV :: 'n set" a, unfolded th0, OF finite]
  20.200    show ?thesis by simp
  20.201  qed
  20.202  
  20.203 -lemma matrix_mul_setsum_alt:
  20.204 +lemma matrix_mul_sum_alt:
  20.205    fixes A B :: "'a::comm_ring_1^'n^'n"
  20.206 -  shows "A ** B = (\<chi> i. setsum (\<lambda>k. A$i$k *s B $ k) (UNIV :: 'n set))"
  20.207 -  by (vector matrix_matrix_mult_def setsum_component)
  20.208 +  shows "A ** B = (\<chi> i. sum (\<lambda>k. A$i$k *s B $ k) (UNIV :: 'n set))"
  20.209 +  by (vector matrix_matrix_mult_def sum_component)
  20.210  
  20.211  lemma det_rows_mul:
  20.212    "det((\<chi> i. c i *s a i)::'a::comm_ring_1^'n^'n) =
  20.213      setprod (\<lambda>i. c i) (UNIV:: 'n set) * det((\<chi> i. a i)::'a^'n^'n)"
  20.214 -proof (simp add: det_def setsum_distrib_left cong add: setprod.cong, rule setsum.cong)
  20.215 +proof (simp add: det_def sum_distrib_left cong add: setprod.cong, rule sum.cong)
  20.216    let ?U = "UNIV :: 'n set"
  20.217    let ?PU = "{p. p permutes ?U}"
  20.218    fix p
  20.219 @@ -735,11 +735,11 @@
  20.220        by blast
  20.221      let ?s = "\<lambda>p. of_int (sign p)"
  20.222      let ?f = "\<lambda>q. ?s p * (\<Prod>i\<in> ?U. A $ i $ p i) * (?s q * (\<Prod>i\<in> ?U. B $ i $ q i))"
  20.223 -    have "(setsum (\<lambda>q. ?s q *
  20.224 +    have "(sum (\<lambda>q. ?s q *
  20.225          (\<Prod>i\<in> ?U. (\<chi> i. A $ i $ p i *s B $ p i :: 'a^'n^'n) $ i $ q i)) ?PU) =
  20.226 -      (setsum (\<lambda>q. ?s p * (\<Prod>i\<in> ?U. A $ i $ p i) * (?s q * (\<Prod>i\<in> ?U. B $ i $ q i))) ?PU)"
  20.227 +      (sum (\<lambda>q. ?s p * (\<Prod>i\<in> ?U. A $ i $ p i) * (?s q * (\<Prod>i\<in> ?U. B $ i $ q i))) ?PU)"
  20.228        unfolding sum_permutations_compose_right[OF permutes_inv[OF p], of ?f]
  20.229 -    proof (rule setsum.cong)
  20.230 +    proof (rule sum.cong)
  20.231        fix q
  20.232        assume qU: "q \<in> ?PU"
  20.233        then have q: "q permutes ?U"
  20.234 @@ -769,14 +769,14 @@
  20.235          by (simp add: sign_nz th00 field_simps sign_idempotent sign_compose)
  20.236      qed rule
  20.237    }
  20.238 -  then have th2: "setsum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU = det A * det B"
  20.239 -    unfolding det_def setsum_product
  20.240 -    by (rule setsum.cong [OF refl])
  20.241 -  have "det (A**B) = setsum (\<lambda>f.  det (\<chi> i. A $ i $ f i *s B $ f i)) ?F"
  20.242 -    unfolding matrix_mul_setsum_alt det_linear_rows_setsum[OF fU]
  20.243 +  then have th2: "sum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU = det A * det B"
  20.244 +    unfolding det_def sum_product
  20.245 +    by (rule sum.cong [OF refl])
  20.246 +  have "det (A**B) = sum (\<lambda>f.  det (\<chi> i. A $ i $ f i *s B $ f i)) ?F"
  20.247 +    unfolding matrix_mul_sum_alt det_linear_rows_sum[OF fU]
  20.248      by simp
  20.249 -  also have "\<dots> = setsum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU"
  20.250 -    using setsum.mono_neutral_cong_left[OF fF PUF zth, symmetric]
  20.251 +  also have "\<dots> = sum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU"
  20.252 +    using sum.mono_neutral_cong_left[OF fF PUF zth, symmetric]
  20.253      unfolding det_rows_mul by auto
  20.254    finally show ?thesis unfolding th2 .
  20.255  qed
  20.256 @@ -812,7 +812,7 @@
  20.257      let ?U = "UNIV :: 'n set"
  20.258      have fU: "finite ?U"
  20.259        by simp
  20.260 -    from H obtain c i where c: "setsum (\<lambda>i. c i *s row i A) ?U = 0"
  20.261 +    from H obtain c i where c: "sum (\<lambda>i. c i *s row i A) ?U = 0"
  20.262        and iU: "i \<in> ?U"
  20.263        and ci: "c i \<noteq> 0"
  20.264        unfolding invertible_righ_inverse
  20.265 @@ -824,8 +824,8 @@
  20.266        apply simp
  20.267        done
  20.268      from c ci
  20.269 -    have thr0: "- row i A = setsum (\<lambda>j. (1/ c i) *s (c j *s row j A)) (?U - {i})"
  20.270 -      unfolding setsum.remove[OF fU iU] setsum_cmul
  20.271 +    have thr0: "- row i A = sum (\<lambda>j. (1/ c i) *s (c j *s row j A)) (?U - {i})"
  20.272 +      unfolding sum.remove[OF fU iU] sum_cmul
  20.273        apply -
  20.274        apply (rule vector_mul_lcancel_imp[OF ci])
  20.275        apply (auto simp add: field_simps)
  20.276 @@ -834,7 +834,7 @@
  20.277        done
  20.278      have thr: "- row i A \<in> span {row j A| j. j \<noteq> i}"
  20.279        unfolding thr0
  20.280 -      apply (rule span_setsum)
  20.281 +      apply (rule span_sum)
  20.282        apply simp
  20.283        apply (rule span_mul [where 'a="real^'n", folded scalar_mult_eq_scaleR])+
  20.284        apply (rule span_superset)
  20.285 @@ -855,7 +855,7 @@
  20.286  lemma cramer_lemma_transpose:
  20.287    fixes A:: "real^'n^'n"
  20.288      and x :: "real^'n"
  20.289 -  shows "det ((\<chi> i. if i = k then setsum (\<lambda>i. x$i *s row i A) (UNIV::'n set)
  20.290 +  shows "det ((\<chi> i. if i = k then sum (\<lambda>i. x$i *s row i A) (UNIV::'n set)
  20.291                               else row i A)::real^'n^'n) = x$k * det A"
  20.292    (is "?lhs = ?rhs")
  20.293  proof -
  20.294 @@ -876,14 +876,14 @@
  20.295      by simp
  20.296    have thd0: "det (\<chi> i. if i = k then row k A + (\<Sum>i \<in> ?Uk. x $ i *s row i A) else row i A) = det A"
  20.297      apply (rule det_row_span)
  20.298 -    apply (rule span_setsum)
  20.299 +    apply (rule span_sum)
  20.300      apply (rule span_mul [where 'a="real^'n", folded scalar_mult_eq_scaleR])+
  20.301      apply (rule span_superset)
  20.302      apply auto
  20.303      done
  20.304    show "?lhs = x$k * det A"
  20.305      apply (subst U)
  20.306 -    unfolding setsum.insert[OF fUk kUk]
  20.307 +    unfolding sum.insert[OF fUk kUk]
  20.308      apply (subst th00)
  20.309      unfolding add.assoc
  20.310      apply (subst det_row_add)
  20.311 @@ -900,8 +900,8 @@
  20.312    shows "det((\<chi> i j. if j = k then (A *v x)$i else A$i$j):: real^'n^'n) = x$k * det A"
  20.313  proof -
  20.314    let ?U = "UNIV :: 'n set"
  20.315 -  have *: "\<And>c. setsum (\<lambda>i. c i *s row i (transpose A)) ?U = setsum (\<lambda>i. c i *s column i A) ?U"
  20.316 -    by (auto simp add: row_transpose intro: setsum.cong)
  20.317 +  have *: "\<And>c. sum (\<lambda>i. c i *s row i (transpose A)) ?U = sum (\<lambda>i. c i *s column i A) ?U"
  20.318 +    by (auto simp add: row_transpose intro: sum.cong)
  20.319    show ?thesis
  20.320      unfolding matrix_mult_vsum
  20.321      unfolding cramer_lemma_transpose[of k x "transpose A", unfolded det_transpose, symmetric]
  20.322 @@ -995,7 +995,7 @@
  20.323          simplified matrix_works[OF lf, symmetric] dot_matrix_vector_mul]
  20.324        have "?A$i$j = ?m1 $ i $ j"
  20.325          by (simp add: inner_vec_def matrix_matrix_mult_def columnvector_def rowvector_def
  20.326 -            th0 setsum.delta[OF fU] mat_def axis_def)
  20.327 +            th0 sum.delta[OF fU] mat_def axis_def)
  20.328      }
  20.329      then have "orthogonal_matrix ?mf"
  20.330        unfolding orthogonal_matrix
  20.331 @@ -1219,7 +1219,7 @@
  20.332    have f12: "finite {2::2}" "1 \<notin> {2::2}" by auto
  20.333    show ?thesis
  20.334      unfolding det_def UNIV_2
  20.335 -    unfolding setsum_over_permutations_insert[OF f12]
  20.336 +    unfolding sum_over_permutations_insert[OF f12]
  20.337      unfolding permutes_sing
  20.338      by (simp add: sign_swap_id sign_id swap_id_eq)
  20.339  qed
  20.340 @@ -1240,8 +1240,8 @@
  20.341  
  20.342    show ?thesis
  20.343      unfolding det_def UNIV_3
  20.344 -    unfolding setsum_over_permutations_insert[OF f123]
  20.345 -    unfolding setsum_over_permutations_insert[OF f23]
  20.346 +    unfolding sum_over_permutations_insert[OF f123]
  20.347 +    unfolding sum_over_permutations_insert[OF f23]
  20.348      unfolding permutes_sing
  20.349      by (simp add: sign_swap_id permutation_swap_id sign_compose sign_id swap_id_eq)
  20.350  qed
    21.1 --- a/src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy	Sun Oct 16 22:43:51 2016 +0200
    21.2 +++ b/src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy	Mon Oct 17 11:46:22 2016 +0200
    21.3 @@ -182,15 +182,15 @@
    21.4        have "(\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) =
    21.5          (\<Sum>(x, k)\<in>?T ` (p \<inter> s). content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p - s. content k *\<^sub>R f x)"
    21.6          using p(1)[THEN tagged_division_ofD(1)]
    21.7 -        by (safe intro!: setsum.union_inter_neutral) (auto simp: s_def T_def)
    21.8 +        by (safe intro!: sum.union_inter_neutral) (auto simp: s_def T_def)
    21.9        also have "(\<Sum>(x, k)\<in>?T ` (p \<inter> s). content k *\<^sub>R f x) = (\<Sum>(x, k)\<in>p \<inter> s. content k *\<^sub>R f (T X k))"
   21.10 -      proof (subst setsum.reindex_nontrivial, safe)
   21.11 +      proof (subst sum.reindex_nontrivial, safe)
   21.12          fix x1 x2 k assume 1: "(x1, k) \<in> p" "(x1, k) \<in> s" and 2: "(x2, k) \<in> p" "(x2, k) \<in> s"
   21.13            and eq: "content k *\<^sub>R f (T X k) \<noteq> 0"
   21.14          with tagged_division_ofD(5)[OF p(1), of x1 k x2 k] tagged_division_ofD(4)[OF p(1), of x1 k]
   21.15          show "x1 = x2"
   21.16            by (auto simp: content_eq_0_interior)
   21.17 -      qed (use p in \<open>auto intro!: setsum.cong\<close>)
   21.18 +      qed (use p in \<open>auto intro!: sum.cong\<close>)
   21.19        finally have eq: "(\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) =
   21.20          (\<Sum>(x, k)\<in>p \<inter> s. content k *\<^sub>R f (T X k)) + (\<Sum>(x, k)\<in>p - s. content k *\<^sub>R f x)" .
   21.21  
   21.22 @@ -270,11 +270,11 @@
   21.23          using \<open>0 < e\<close> by (simp add: split_beta)
   21.24      qed (use \<open>a < b\<close> in auto)
   21.25      also have "\<dots> = (\<Sum>(x, k)\<in>p \<inter> s. content k * (b - a))"
   21.26 -      by (simp add: setsum_distrib_right split_beta')
   21.27 +      by (simp add: sum_distrib_right split_beta')
   21.28      also have "\<dots> \<le> (\<Sum>(x, k)\<in>p \<inter> s. content k * (f (T ?F k) - f (T ?E k)))"
   21.29 -      using parts(3) by (auto intro!: setsum_mono mult_left_mono diff_mono)
   21.30 +      using parts(3) by (auto intro!: sum_mono mult_left_mono diff_mono)
   21.31      also have "\<dots> = (\<Sum>(x, k)\<in>p \<inter> s. content k * f (T ?F k)) - (\<Sum>(x, k)\<in>p \<inter> s. content k * f (T ?E k))"
   21.32 -      by (auto intro!: setsum.cong simp: field_simps setsum_subtractf[symmetric])
   21.33 +      by (auto intro!: sum.cong simp: field_simps sum_subtractf[symmetric])
   21.34      also have "\<dots> = (\<Sum>(x, k)\<in>?B. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>?A. content k *\<^sub>R f x)"
   21.35        by (subst (1 2) parts) auto
   21.36      also have "\<dots> \<le> norm ((\<Sum>(x, k)\<in>?B. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>?A. content k *\<^sub>R f x))"
   21.37 @@ -401,13 +401,13 @@
   21.38        proof (rule has_integral_monotone_convergence_increasing)
   21.39          let ?f = "\<lambda>k x. \<Sum>i<k. if x \<in> F i \<inter> box a b then 1 else 0 :: real"
   21.40          show "\<And>k. (?f k has_integral (\<Sum>i<k. ?M (F i))) (box a b)"
   21.41 -          using union.IH by (auto intro!: has_integral_setsum simp del: Int_iff)
   21.42 +          using union.IH by (auto intro!: has_integral_sum simp del: Int_iff)
   21.43          show "\<And>k x. ?f k x \<le> ?f (Suc k) x"
   21.44 -          by (intro setsum_mono2) auto
   21.45 +          by (intro sum_mono2) auto
   21.46          from union(1) have *: "\<And>x i j. x \<in> F i \<Longrightarrow> x \<in> F j \<longleftrightarrow> j = i"
   21.47            by (auto simp add: disjoint_family_on_def)
   21.48          show "\<And>x. (\<lambda>k. ?f k x) \<longlonglongrightarrow> (if x \<in> UNION UNIV F \<inter> box a b then 1 else 0)"
   21.49 -          apply (auto simp: * setsum.If_cases Iio_Int_singleton)
   21.50 +          apply (auto simp: * sum.If_cases Iio_Int_singleton)
   21.51            apply (rule_tac k="Suc xa" in LIMSEQ_offset)
   21.52            apply simp
   21.53            done
   21.54 @@ -757,7 +757,7 @@
   21.55    shows "(f has_integral (integral\<^sup>L lborel f)) UNIV"
   21.56  proof -
   21.57    have "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b)) UNIV"
   21.58 -    using f by (intro has_integral_setsum finite_Basis ballI has_integral_scaleR_left has_integral_integral_real) auto
   21.59 +    using f by (intro has_integral_sum finite_Basis ballI has_integral_scaleR_left has_integral_integral_real) auto
   21.60    also have eq_f: "(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f"
   21.61      by (simp add: fun_eq_iff euclidean_representation)
   21.62    also have "(\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b) = integral\<^sup>L lborel f"
   21.63 @@ -804,7 +804,7 @@
   21.64    shows "(f has_integral (integral\<^sup>L lebesgue f)) UNIV"
   21.65  proof -
   21.66    have "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. integral\<^sup>L lebesgue (\<lambda>x. f x \<bullet> b) *\<^sub>R b)) UNIV"
   21.67 -    using f by (intro has_integral_setsum finite_Basis ballI has_integral_scaleR_left has_integral_integral_lebesgue_real) auto
   21.68 +    using f by (intro has_integral_sum finite_Basis ballI has_integral_scaleR_left has_integral_integral_lebesgue_real) auto
   21.69    also have eq_f: "(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f"
   21.70      by (simp add: fun_eq_iff euclidean_representation)
   21.71    also have "(\<Sum>b\<in>Basis. integral\<^sup>L lebesgue (\<lambda>x. f x \<bullet> b) *\<^sub>R b) = integral\<^sup>L lebesgue f"
   21.72 @@ -1245,10 +1245,10 @@
   21.73        using \<open>0 < B\<close> \<open>\<D>' \<subseteq> \<D>\<close> that vu_pos by fastforce
   21.74      have "{} \<notin> \<D>'"
   21.75        using cbox \<open>\<D>' \<subseteq> \<D>\<close> interior_empty by blast
   21.76 -    have "(\<Sum>k\<in>fbx`\<D>'. measure lebesgue k) \<le> setsum (measure lebesgue o fbx) \<D>'"
   21.77 -      by (rule setsum_image_le [OF \<open>finite \<D>'\<close>]) (force simp: fbx_def)
   21.78 +    have "(\<Sum>k\<in>fbx`\<D>'. measure lebesgue k) \<le> sum (measure lebesgue o fbx) \<D>'"
   21.79 +      by (rule sum_image_le [OF \<open>finite \<D>'\<close>]) (force simp: fbx_def)
   21.80      also have "\<dots> \<le> (\<Sum>X\<in>\<D>'. (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X)"
   21.81 -    proof (rule setsum_mono)
   21.82 +    proof (rule sum_mono)
   21.83        fix X assume "X \<in> \<D>'"
   21.84        then have "X \<in> \<D>" using \<open>\<D>' \<subseteq> \<D>\<close> by blast
   21.85        then have ufvf: "cbox (uf X) (vf X) = X"
   21.86 @@ -1281,8 +1281,8 @@
   21.87          by (subst (3) ufvf[symmetric]) simp
   21.88        finally show "(measure lebesgue \<circ> fbx) X \<le> (2 * B * DIM('M)) ^ DIM('N) * measure lebesgue X" .
   21.89      qed
   21.90 -    also have "\<dots> = (2 * B * DIM('M)) ^ DIM('N) * setsum (measure lebesgue) \<D>'"
   21.91 -      by (simp add: setsum_distrib_left)
   21.92 +    also have "\<dots> = (2 * B * DIM('M)) ^ DIM('N) * sum (measure lebesgue) \<D>'"
   21.93 +      by (simp add: sum_distrib_left)
   21.94      also have "\<dots> \<le> e / 2"
   21.95      proof -
   21.96        have div: "\<D>' division_of \<Union>\<D>'"
   21.97 @@ -1306,9 +1306,9 @@
   21.98          qed
   21.99          finally show "\<Union>\<D>' \<subseteq> T" .
  21.100        qed
  21.101 -      have "setsum (measure lebesgue) \<D>' = setsum content \<D>'"
  21.102 -        using  \<open>\<D>' \<subseteq> \<D>\<close> cbox by (force intro: setsum.cong)
  21.103 -      then have "(2 * B * DIM('M)) ^ DIM('N) * setsum (measure lebesgue) \<D>' =
  21.104 +      have "sum (measure lebesgue) \<D>' = sum content \<D>'"
  21.105 +        using  \<open>\<D>' \<subseteq> \<D>\<close> cbox by (force intro: sum.cong)
  21.106 +      then have "(2 * B * DIM('M)) ^ DIM('N) * sum (measure lebesgue) \<D>' =
  21.107                   (2 * B * real DIM('M)) ^ DIM('N) * measure lebesgue (\<Union>\<D>')"
  21.108          using content_division [OF div] by auto
  21.109        also have "\<dots> \<le> (2 * B * real DIM('M)) ^ DIM('N) * measure lebesgue T"
  21.110 @@ -1322,7 +1322,7 @@
  21.111      qed
  21.112      finally show ?thesis .
  21.113    qed
  21.114 -  then have e2: "setsum (measure lebesgue) \<G> \<le> e / 2" if "\<G> \<subseteq> fbx ` \<D>" "finite \<G>" for \<G>
  21.115 +  then have e2: "sum (measure lebesgue) \<G> \<le> e / 2" if "\<G> \<subseteq> fbx ` \<D>" "finite \<G>" for \<G>
  21.116      by (metis finite_subset_image that)
  21.117    show "\<exists>W\<in>lmeasurable. f ` S \<subseteq> W \<and> measure lebesgue W < e"
  21.118    proof (intro bexI conjI)
  21.119 @@ -1339,7 +1339,7 @@
  21.120        have "norm (y - zf X) \<le> (\<Sum>i\<in>Basis. \<bar>(y - zf X) \<bullet> i\<bar>)"
  21.121          by (rule norm_le_l1)
  21.122        also have "\<dots> \<le> real DIM('M) * prj1 (vf X - uf X)"
  21.123 -      proof (rule setsum_bounded_above)
  21.124 +      proof (rule sum_bounded_above)
  21.125          fix j::'M assume j: "j \<in> Basis"
  21.126          show "\<bar>(y - zf X) \<bullet> j\<bar> \<le> prj1 (vf X - uf X)"
  21.127            using yin zin j
  21.128 @@ -1533,7 +1533,7 @@
  21.129  lemma absolutely_integrable_bounded_variation:
  21.130    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  21.131    assumes f: "f absolutely_integrable_on UNIV"
  21.132 -  obtains B where "\<forall>d. d division_of (\<Union>d) \<longrightarrow> setsum (\<lambda>k. norm (integral k f)) d \<le> B"
  21.133 +  obtains B where "\<forall>d. d division_of (\<Union>d) \<longrightarrow> sum (\<lambda>k. norm (integral k f)) d \<le> B"
  21.134  proof (rule that[of "integral UNIV (\<lambda>x. norm (f x))"]; safe)
  21.135    fix d :: "'a set set" assume d: "d division_of \<Union>d"
  21.136    have *: "k \<in> d \<Longrightarrow> f absolutely_integrable_on k" for k
  21.137 @@ -1541,11 +1541,11 @@
  21.138    note d' = division_ofD[OF d]
  21.139  
  21.140    have "(\<Sum>k\<in>d. norm (integral k f)) = (\<Sum>k\<in>d. norm (LINT x:k|lebesgue. f x))"
  21.141 -    by (intro setsum.cong refl arg_cong[where f=norm] set_lebesgue_integral_eq_integral(2)[symmetric] *)
  21.142 +    by (intro sum.cong refl arg_cong[where f=norm] set_lebesgue_integral_eq_integral(2)[symmetric] *)
  21.143    also have "\<dots> \<le> (\<Sum>k\<in>d. LINT x:k|lebesgue. norm (f x))"
  21.144 -    by (intro setsum_mono set_integral_norm_bound *)
  21.145 +    by (intro sum_mono set_integral_norm_bound *)
  21.146    also have "\<dots> = (\<Sum>k\<in>d. integral k (\<lambda>x. norm (f x)))"
  21.147 -    by (intro setsum.cong refl set_lebesgue_integral_eq_integral(2) set_integrable_norm *)
  21.148 +    by (intro sum.cong refl set_lebesgue_integral_eq_integral(2) set_integrable_norm *)
  21.149    also have "\<dots> \<le> integral (\<Union>d) (\<lambda>x. norm (f x))"
  21.150      using integrable_on_subdivision[OF d] assms f unfolding absolutely_integrable_on_def
  21.151      by (subst integral_combine_division_topdown[OF _ d]) auto
  21.152 @@ -1556,20 +1556,20 @@
  21.153  qed
  21.154  
  21.155  lemma helplemma:
  21.156 -  assumes "setsum (\<lambda>x. norm (f x - g x)) s < e"
  21.157 +  assumes "sum (\<lambda>x. norm (f x - g x)) s < e"
  21.158      and "finite s"
  21.159 -  shows "\<bar>setsum (\<lambda>x. norm(f x)) s - setsum (\<lambda>x. norm(g x)) s\<bar> < e"
  21.160 -  unfolding setsum_subtractf[symmetric]
  21.161 -  apply (rule le_less_trans[OF setsum_abs])
  21.162 +  shows "\<bar>sum (\<lambda>x. norm(f x)) s - sum (\<lambda>x. norm(g x)) s\<bar> < e"
  21.163 +  unfolding sum_subtractf[symmetric]
  21.164 +  apply (rule le_less_trans[OF sum_abs])
  21.165    apply (rule le_less_trans[OF _ assms(1)])
  21.166 -  apply (rule setsum_mono)
  21.167 +  apply (rule sum_mono)
  21.168    apply (rule norm_triangle_ineq3)
  21.169    done
  21.170  
  21.171  lemma bounded_variation_absolutely_integrable_interval:
  21.172    fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  21.173    assumes f: "f integrable_on cbox a b"
  21.174 -    and *: "\<forall>d. d division_of (cbox a b) \<longrightarrow> setsum (\<lambda>k. norm(integral k f)) d \<le> B"
  21.175 +    and *: "\<forall>d. d division_of (cbox a b) \<longrightarrow> sum (\<lambda>k. norm(integral k f)) d \<le> B"
  21.176    shows "f absolutely_integrable_on cbox a b"
  21.177  proof -
  21.178    let ?f = "\<lambda>d. \<Sum>k\<in>d. norm (integral k f)" and ?D = "{d. d division_of (cbox a b)}"
  21.179 @@ -1749,7 +1749,7 @@
  21.180            done
  21.181        qed
  21.182        have sum_p': "(\<Sum>(x, k)\<in>p'. norm (integral k f)) = (\<Sum>k\<in>snd ` p'. norm (integral k f))"
  21.183 -        apply (subst setsum.over_tagged_division_lemma[OF p'',of "\<lambda>k. norm (integral k f)"])
  21.184 +        apply (subst sum.over_tagged_division_lemma[OF p'',of "\<lambda>k. norm (integral k f)"])
  21.185          unfolding norm_eq_zero
  21.186           apply (rule integral_null)
  21.187          apply (simp add: content_eq_0_interior)
  21.188 @@ -1775,7 +1775,7 @@
  21.189            (\<lambda>(k,l). k \<inter> l) ` {(k,l)|k l. k \<in> d \<and> l \<in> snd ` p}"
  21.190            by auto
  21.191          have "(\<Sum>k\<in>d. norm (integral k f)) \<le> (\<Sum>i\<in>d. \<Sum>l\<in>snd ` p. norm (integral (i \<inter> l) f))"
  21.192 -        proof (rule setsum_mono, goal_cases)
  21.193 +        proof (rule sum_mono, goal_cases)
  21.194            case k: (1 k)
  21.195            from d'(4)[OF this] guess u v by (elim exE) note uv=this
  21.196            define d' where "d' = {cbox u v \<inter> l |l. l \<in> snd ` p \<and>  cbox u v \<inter> l \<noteq> {}}"
  21.197 @@ -1786,16 +1786,16 @@
  21.198              apply (rule division_of_tagged_division[OF p(1)])
  21.199              apply (rule uvab)
  21.200              done
  21.201 -          then have "norm (integral k f) \<le> setsum (\<lambda>k. norm (integral k f)) d'"
  21.202 +          then have "norm (integral k f) \<le> sum (\<lambda>k. norm (integral k f)) d'"
  21.203              unfolding uv
  21.204              apply (subst integral_combine_division_topdown[of _ _ d'])
  21.205              apply (rule integrable_on_subcbox[OF assms(1) uvab])
  21.206              apply assumption
  21.207 -            apply (rule setsum_norm_le)
  21.208 +            apply (rule sum_norm_le)
  21.209              apply auto
  21.210              done
  21.211            also have "\<dots> = (\<Sum>k\<in>{k \<inter> l |l. l \<in> snd ` p}. norm (integral k f))"
  21.212 -            apply (rule setsum.mono_neutral_left)
  21.213 +            apply (rule sum.mono_neutral_left)
  21.214              apply (subst Setcompr_eq_image)
  21.215              apply (rule finite_imageI)+
  21.216              apply fact
  21.217 @@ -1813,7 +1813,7 @@
  21.218            qed
  21.219            also have "\<dots> = (\<Sum>l\<in>snd ` p. norm (integral (k \<inter> l) f))"
  21.220              unfolding Setcompr_eq_image
  21.221 -            apply (rule setsum.reindex_nontrivial [unfolded o_def])
  21.222 +            apply (rule sum.reindex_nontrivial [unfolded o_def])
  21.223              apply (rule finite_imageI)
  21.224              apply (rule p')
  21.225            proof goal_cases
  21.226 @@ -1845,7 +1845,7 @@
  21.227            unfolding split_def ..
  21.228          also have "\<dots> = (\<Sum>k\<in>{i \<inter> l |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral k f))"
  21.229            unfolding *
  21.230 -          apply (rule setsum.reindex_nontrivial [symmetric, unfolded o_def])
  21.231 +          apply (rule sum.reindex_nontrivial [symmetric, unfolded o_def])
  21.232            apply (rule finite_product_dependent)
  21.233            apply fact
  21.234            apply (rule finite_imageI)
  21.235 @@ -1886,7 +1886,7 @@
  21.236          qed
  21.237          also have "\<dots> = (\<Sum>(x, k)\<in>p'. norm (integral k f))"
  21.238            unfolding sum_p'
  21.239 -          apply (rule setsum.mono_neutral_right)
  21.240 +          apply (rule sum.mono_neutral_right)
  21.241            apply (subst *)
  21.242            apply (rule finite_imageI[OF finite_product_dependent])
  21.243            apply fact
  21.244 @@ -1929,7 +1929,7 @@
  21.245          note pdfin = finite_cartesian_product[OF p'(1) d'(1)]
  21.246          have "(\<Sum>(x, k)\<in>p'. norm (content k *\<^sub>R f x)) = (\<Sum>(x, k)\<in>?S. \<bar>content k\<bar> * norm (f x))"
  21.247            unfolding norm_scaleR
  21.248 -          apply (rule setsum.mono_neutral_left)
  21.249 +          apply (rule sum.mono_neutral_left)
  21.250            apply (subst *)
  21.251            apply (rule finite_imageI)
  21.252            apply fact
  21.253 @@ -1943,7 +1943,7 @@
  21.254            done
  21.255          also have "\<dots> = (\<Sum>((x,l),i)\<in>p \<times> d. \<bar>content (l \<inter> i)\<bar> * norm (f x))"
  21.256            unfolding *
  21.257 -          apply (subst setsum.reindex_nontrivial)
  21.258 +          apply (subst sum.reindex_nontrivial)
  21.259            apply fact
  21.260            unfolding split_paired_all
  21.261            unfolding o_def split_def snd_conv fst_conv mem_Sigma_iff prod.inject
  21.262 @@ -1981,7 +1981,7 @@
  21.263            apply (rule p')
  21.264            apply rule
  21.265            apply (rule d')
  21.266 -          apply (rule setsum.cong)
  21.267 +          apply (rule sum.cong)
  21.268            apply (rule refl)
  21.269            unfolding split_paired_all split_conv
  21.270          proof -
  21.271 @@ -1990,7 +1990,7 @@
  21.272            note xl = p'(2-4)[OF this]
  21.273            from this(3) guess u v by (elim exE) note uv=this
  21.274            have "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar>) = (\<Sum>k\<in>d. content (k \<inter> cbox u v))"
  21.275 -            apply (rule setsum.cong)
  21.276 +            apply (rule sum.cong)
  21.277              apply (rule refl)
  21.278              apply (drule d'(4))
  21.279              apply safe
  21.280 @@ -1999,9 +1999,9 @@
  21.281              apply (subst abs_of_nonneg)
  21.282              apply auto
  21.283              done
  21.284 -          also have "\<dots> = setsum content {k \<inter> cbox u v| k. k \<in> d}"
  21.285 +          also have "\<dots> = sum content {k \<inter> cbox u v| k. k \<in> d}"
  21.286              unfolding Setcompr_eq_image
  21.287 -            apply (rule setsum.reindex_nontrivial [unfolded o_def, symmetric])
  21.288 +            apply (rule sum.reindex_nontrivial [unfolded o_def, symmetric])
  21.289              apply (rule d')
  21.290            proof goal_cases
  21.291              case prems: (1 k y)
  21.292 @@ -2019,8 +2019,8 @@
  21.293              finally show ?case
  21.294                unfolding uv Int_interval content_eq_0_interior ..
  21.295            qed
  21.296 -          also have "\<dots> = setsum content {cbox u v \<inter> k |k. k \<in> d \<and> cbox u v \<inter> k \<noteq> {}}"
  21.297 -            apply (rule setsum.mono_neutral_right)
  21.298 +          also have "\<dots> = sum content {cbox u v \<inter> k |k. k \<in> d \<and> cbox u v \<inter> k \<noteq> {}}"
  21.299 +            apply (rule sum.mono_neutral_right)
  21.300              unfolding Setcompr_eq_image
  21.301              apply (rule finite_imageI)
  21.302              apply (rule d')
  21.303 @@ -2040,7 +2040,7 @@
  21.304                by auto
  21.305            qed
  21.306            finally show "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar> * norm (f x)) = content l *\<^sub>R norm (f x)"
  21.307 -            unfolding setsum_distrib_right[symmetric] real_scaleR_def
  21.308 +            unfolding sum_distrib_right[symmetric] real_scaleR_def
  21.309              apply (subst(asm) additive_content_division[OF division_inter_1[OF d(1)]])
  21.310              using xl(2)[unfolded uv]
  21.311              unfolding uv
  21.312 @@ -2056,7 +2056,7 @@
  21.313  lemma bounded_variation_absolutely_integrable:
  21.314    fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  21.315    assumes "f integrable_on UNIV"
  21.316 -    and "\<forall>d. d division_of (\<Union>d) \<longrightarrow> setsum (\<lambda>k. norm (integral k f)) d \<le> B"
  21.317 +    and "\<forall>d. d division_of (\<Union>d) \<longrightarrow> sum (\<lambda>k. norm (integral k f)) d \<le> B"
  21.318    shows "f absolutely_integrable_on UNIV"
  21.319  proof (rule absolutely_integrable_onI, fact, rule)
  21.320    let ?f = "\<lambda>d. \<Sum>k\<in>d. norm (integral k f)" and ?D = "{d. d division_of  (\<Union>d)}"
  21.321 @@ -2083,7 +2083,7 @@
  21.322        using f_int[of a b] unfolding absolutely_integrable_on_def by auto
  21.323    next
  21.324      case prems: (2 e)
  21.325 -    have "\<exists>y\<in>setsum (\<lambda>k. norm (integral k f)) ` {d. d division_of \<Union>d}. \<not> y \<le> ?S - e"
  21.326 +    have "\<exists>y\<in>sum (\<lambda>k. norm (integral k f)) ` {d. d division_of \<Union>d}. \<not> y \<le> ?S - e"
  21.327      proof (rule ccontr)
  21.328        assume "\<not> ?thesis"
  21.329        then have "?S \<le> ?S - e"
  21.330 @@ -2092,7 +2092,7 @@
  21.331          using prems by auto
  21.332      qed
  21.333      then obtain K where *: "\<exists>x\<in>{d. d division_of \<Union>d}. K = (\<Sum>k\<in>x. norm (integral k f))"
  21.334 -      "SUPREMUM {d. d division_of \<Union>d} (setsum (\<lambda>k. norm (integral k f))) - e < K"
  21.335 +      "SUPREMUM {d. d division_of \<Union>d} (sum (\<lambda>k. norm (integral k f))) - e < K"
  21.336        by (auto simp add: image_iff not_le)
  21.337      from this(1) obtain d where "d division_of \<Union>d"
  21.338        and "K = (\<Sum>k\<in>d. norm (integral k f))"
  21.339 @@ -2118,8 +2118,8 @@
  21.340          apply (rule d(2))
  21.341        proof goal_cases
  21.342          case 1
  21.343 -        have "(\<Sum>k\<in>d. norm (integral k f)) \<le> setsum (\<lambda>k. integral k (\<lambda>x. norm (f x))) d"
  21.344 -          apply (intro setsum_mono)
  21.345 +        have "(\<Sum>k\<in>d. norm (integral k f)) \<le> sum (\<lambda>k. integral k (\<lambda>x. norm (f x))) d"
  21.346 +          apply (intro sum_mono)
  21.347            subgoal for k
  21.348              using d'(4)[of k] f_int
  21.349              by (auto simp: absolutely_integrable_on_def integral_norm_bound_integral)
  21.350 @@ -2188,7 +2188,7 @@
  21.351              using d1(2)[rule_format,OF conjI[OF p(1,2)]]
  21.352              by (simp only: real_norm_def)
  21.353            show "(\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) = (\<Sum>(x, k)\<in>p. norm (content k *\<^sub>R f x))"
  21.354 -            apply (rule setsum.cong)
  21.355 +            apply (rule sum.cong)
  21.356              apply (rule refl)
  21.357              unfolding split_paired_all split_conv
  21.358              apply (drule tagged_division_ofD(4)[OF p(1)])
  21.359 @@ -2198,7 +2198,7 @@
  21.360              done
  21.361            show "(\<Sum>(x, k)\<in>p. norm (integral k f)) \<le> ?S"
  21.362              using partial_division_of_tagged_division[of p "cbox a b"] p(1)
  21.363 -            apply (subst setsum.over_tagged_division_lemma[OF p(1)])
  21.364 +            apply (subst sum.over_tagged_division_lemma[OF p(1)])
  21.365              apply (simp add: content_eq_0_interior)
  21.366              apply (intro cSUP_upper2[OF D(2), of "snd ` p"])
  21.367              apply (auto simp: tagged_partial_division_of_def)
  21.368 @@ -2230,10 +2230,10 @@
  21.369    using integrable_bounded_linear[of h lebesgue "\<lambda>x. indicator s x *\<^sub>R f x"]
  21.370    by (simp add: linear_simps[of h])
  21.371  
  21.372 -lemma absolutely_integrable_setsum:
  21.373 +lemma absolutely_integrable_sum:
  21.374    fixes f :: "'a \<Rightarrow> 'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  21.375    assumes "finite t" and "\<And>a. a \<in> t \<Longrightarrow> (f a) absolutely_integrable_on s"
  21.376 -  shows "(\<lambda>x. setsum (\<lambda>a. f a x) t) absolutely_integrable_on s"
  21.377 +  shows "(\<lambda>x. sum (\<lambda>a. f a x) t) absolutely_integrable_on s"
  21.378    using assms(1,2) by induct auto
  21.379  
  21.380  lemma absolutely_integrable_integrable_bound:
    22.1 --- a/src/HOL/Analysis/Euclidean_Space.thy	Sun Oct 16 22:43:51 2016 +0200
    22.2 +++ b/src/HOL/Analysis/Euclidean_Space.thy	Mon Oct 17 11:46:22 2016 +0200
    22.3 @@ -53,9 +53,9 @@
    22.4  lemma (in euclidean_space) SOME_Basis: "(SOME i. i \<in> Basis) \<in> Basis"
    22.5    by (metis ex_in_conv nonempty_Basis someI_ex)
    22.6  
    22.7 -lemma (in euclidean_space) inner_setsum_left_Basis[simp]:
    22.8 +lemma (in euclidean_space) inner_sum_left_Basis[simp]:
    22.9      "b \<in> Basis \<Longrightarrow> inner (\<Sum>i\<in>Basis. f i *\<^sub>R i) b = f b"
   22.10 -  by (simp add: inner_setsum_left inner_Basis if_distrib comm_monoid_add_class.setsum.If_cases)
   22.11 +  by (simp add: inner_sum_left inner_Basis if_distrib comm_monoid_add_class.sum.If_cases)
   22.12  
   22.13  lemma (in euclidean_space) euclidean_eqI:
   22.14    assumes b: "\<And>b. b \<in> Basis \<Longrightarrow> inner x b = inner y b" shows "x = y"
   22.15 @@ -70,16 +70,16 @@
   22.16    "x = y \<longleftrightarrow> (\<forall>b\<in>Basis. inner x b = inner y b)"
   22.17    by (auto intro: euclidean_eqI)
   22.18  
   22.19 -lemma (in euclidean_space) euclidean_representation_setsum:
   22.20 +lemma (in euclidean_space) euclidean_representation_sum:
   22.21    "(\<Sum>i\<in>Basis. f i *\<^sub>R i) = b \<longleftrightarrow> (\<forall>i\<in>Basis. f i = inner b i)"
   22.22    by (subst euclidean_eq_iff) simp
   22.23  
   22.24 -lemma (in euclidean_space) euclidean_representation_setsum':
   22.25 +lemma (in euclidean_space) euclidean_representation_sum':
   22.26    "b = (\<Sum>i\<in>Basis. f i *\<^sub>R i) \<longleftrightarrow> (\<forall>i\<in>Basis. f i = inner b i)"
   22.27 -  by (auto simp add: euclidean_representation_setsum[symmetric])
   22.28 +  by (auto simp add: euclidean_representation_sum[symmetric])
   22.29  
   22.30  lemma (in euclidean_space) euclidean_representation: "(\<Sum>b\<in>Basis. inner x b *\<^sub>R b) = x"
   22.31 -  unfolding euclidean_representation_setsum by simp
   22.32 +  unfolding euclidean_representation_sum by simp
   22.33  
   22.34  lemma (in euclidean_space) choice_Basis_iff:
   22.35    fixes P :: "'a \<Rightarrow> real \<Rightarrow> bool"
   22.36 @@ -96,15 +96,15 @@
   22.37    shows "(\<forall>i\<in>Basis. \<exists>x\<in>A. P i x) \<longleftrightarrow> (\<exists>x. \<forall>i\<in>Basis. inner x i \<in> A \<and> P i (inner x i))"
   22.38  by (simp add: choice_Basis_iff Bex_def)
   22.39  
   22.40 -lemma (in euclidean_space) euclidean_representation_setsum_fun:
   22.41 +lemma (in euclidean_space) euclidean_representation_sum_fun:
   22.42      "(\<lambda>x. \<Sum>b\<in>Basis. inner (f x) b *\<^sub>R b) = f"
   22.43 -  by (rule ext) (simp add: euclidean_representation_setsum)
   22.44 +  by (rule ext) (simp add: euclidean_representation_sum)
   22.45  
   22.46  lemma euclidean_isCont:
   22.47    assumes "\<And>b. b \<in> Basis \<Longrightarrow> isCont (\<lambda>x. (inner (f x) b) *\<^sub>R b) x"
   22.48      shows "isCont f x"
   22.49 -  apply (subst euclidean_representation_setsum_fun [symmetric])
   22.50 -  apply (rule isCont_setsum)
   22.51 +  apply (subst euclidean_representation_sum_fun [symmetric])
   22.52 +  apply (rule isCont_sum)
   22.53    apply (blast intro: assms)
   22.54    done
   22.55  
   22.56 @@ -115,16 +115,16 @@
   22.57    by (meson DIM_positive Suc_leI)
   22.58  
   22.59  
   22.60 -lemma setsum_inner_Basis_scaleR [simp]:
   22.61 +lemma sum_inner_Basis_scaleR [simp]:
   22.62    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_vector"
   22.63    assumes "b \<in> Basis" shows "(\<Sum>i\<in>Basis. (inner i b) *\<^sub>R f i) = f b"
   22.64 -  by (simp add: comm_monoid_add_class.setsum.remove [OF finite_Basis assms]
   22.65 -         assms inner_not_same_Basis comm_monoid_add_class.setsum.neutral)
   22.66 +  by (simp add: comm_monoid_add_class.sum.remove [OF finite_Basis assms]
   22.67 +         assms inner_not_same_Basis comm_monoid_add_class.sum.neutral)
   22.68  
   22.69 -lemma setsum_inner_Basis_eq [simp]:
   22.70 +lemma sum_inner_Basis_eq [simp]:
   22.71    assumes "b \<in> Basis" shows "(\<Sum>i\<in>Basis. (inner i b) * f i) = f b"
   22.72 -  by (simp add: comm_monoid_add_class.setsum.remove [OF finite_Basis assms]
   22.73 -         assms inner_not_same_Basis comm_monoid_add_class.setsum.neutral)
   22.74 +  by (simp add: comm_monoid_add_class.sum.remove [OF finite_Basis assms]
   22.75 +         assms inner_not_same_Basis comm_monoid_add_class.sum.neutral)
   22.76  
   22.77  subsection \<open>Subclass relationships\<close>
   22.78  
   22.79 @@ -188,15 +188,15 @@
   22.80  definition
   22.81    "Basis = (\<lambda>u. (u, 0)) ` Basis \<union> (\<lambda>v. (0, v)) ` Basis"
   22.82  
   22.83 -lemma setsum_Basis_prod_eq:
   22.84 +lemma sum_Basis_prod_eq:
   22.85    fixes f::"('a*'b)\<Rightarrow>('a*'b)"
   22.86 -  shows "setsum f Basis = setsum (\<lambda>i. f (i, 0)) Basis + setsum (\<lambda>i. f (0, i)) Basis"
   22.87 +  shows "sum f Basis = sum (\<lambda>i. f (i, 0)) Basis + sum (\<lambda>i. f (0, i)) Basis"
   22.88  proof -
   22.89    have "inj_on (\<lambda>u. (u::'a, 0::'b)) Basis" "inj_on (\<lambda>u. (0::'a, u::'b)) Basis"
   22.90      by (auto intro!: inj_onI Pair_inject)
   22.91    thus ?thesis
   22.92      unfolding Basis_prod_def
   22.93 -    by (subst setsum.union_disjoint) (auto simp: Basis_prod_def setsum.reindex)
   22.94 +    by (subst sum.union_disjoint) (auto simp: Basis_prod_def sum.reindex)
   22.95  qed
   22.96  
   22.97  instance proof
    23.1 --- a/src/HOL/Analysis/Fashoda_Theorem.thy	Sun Oct 16 22:43:51 2016 +0200
    23.2 +++ b/src/HOL/Analysis/Fashoda_Theorem.thy	Mon Oct 17 11:46:22 2016 +0200
    23.3 @@ -17,13 +17,13 @@
    23.4  lemma interval_bij_affine:
    23.5    "interval_bij (a,b) (u,v) = (\<lambda>x. (\<Sum>i\<in>Basis. ((v\<bullet>i - u\<bullet>i) / (b\<bullet>i - a\<bullet>i) * (x\<bullet>i)) *\<^sub>R i) +
    23.6      (\<Sum>i\<in>Basis. (u\<bullet>i - (v\<bullet>i - u\<bullet>i) / (b\<bullet>i - a\<bullet>i) * (a\<bullet>i)) *\<^sub>R i))"
    23.7 -  by (auto simp: setsum.distrib[symmetric] scaleR_add_left[symmetric] interval_bij_def fun_eq_iff
    23.8 -    field_simps inner_simps add_divide_distrib[symmetric] intro!: setsum.cong)
    23.9 +  by (auto simp: sum.distrib[symmetric] scaleR_add_left[symmetric] interval_bij_def fun_eq_iff
   23.10 +    field_simps inner_simps add_divide_distrib[symmetric] intro!: sum.cong)
   23.11  
   23.12  lemma continuous_interval_bij:
   23.13    fixes a b :: "'a::euclidean_space"
   23.14    shows "continuous (at x) (interval_bij (a, b) (u, v))"
   23.15 -  by (auto simp add: divide_inverse interval_bij_def intro!: continuous_setsum continuous_intros)
   23.16 +  by (auto simp add: divide_inverse interval_bij_def intro!: continuous_sum continuous_intros)
   23.17  
   23.18  lemma continuous_on_interval_bij: "continuous_on s (interval_bij (a, b) (u, v))"
   23.19    apply(rule continuous_at_imp_continuous_on)
   23.20 @@ -35,7 +35,7 @@
   23.21    assumes "x \<in> cbox a b"
   23.22      and "cbox u v \<noteq> {}"
   23.23    shows "interval_bij (a, b) (u, v) x \<in> cbox u v"
   23.24 -  apply (simp only: interval_bij_def split_conv mem_box inner_setsum_left_Basis cong: ball_cong)
   23.25 +  apply (simp only: interval_bij_def split_conv mem_box inner_sum_left_Basis cong: ball_cong)
   23.26    apply safe
   23.27  proof -
   23.28    fix i :: 'a
    24.1 --- a/src/HOL/Analysis/Finite_Cartesian_Product.thy	Sun Oct 16 22:43:51 2016 +0200
    24.2 +++ b/src/HOL/Analysis/Finite_Cartesian_Product.thy	Mon Oct 17 11:46:22 2016 +0200
    24.3 @@ -373,10 +373,10 @@
    24.4      assume "M \<le> m" "M \<le> n"
    24.5      have "dist (X m) (X n) = setL2 (\<lambda>i. dist (X m $ i) (X n $ i)) UNIV"
    24.6        unfolding dist_vec_def ..
    24.7 -    also have "\<dots> \<le> setsum (\<lambda>i. dist (X m $ i) (X n $ i)) UNIV"
    24.8 -      by (rule setL2_le_setsum [OF zero_le_dist])
    24.9 -    also have "\<dots> < setsum (\<lambda>i::'n. ?s) UNIV"
   24.10 -      by (rule setsum_strict_mono, simp_all add: M \<open>M \<le> m\<close> \<open>M \<le> n\<close>)
   24.11 +    also have "\<dots> \<le> sum (\<lambda>i. dist (X m $ i) (X n $ i)) UNIV"
   24.12 +      by (rule setL2_le_sum [OF zero_le_dist])
   24.13 +    also have "\<dots> < sum (\<lambda>i::'n. ?s) UNIV"
   24.14 +      by (rule sum_strict_mono, simp_all add: M \<open>M \<le> m\<close> \<open>M \<le> n\<close>)
   24.15      also have "\<dots> = r"
   24.16        by simp
   24.17      finally have "dist (X m) (X n) < r" .
   24.18 @@ -449,7 +449,7 @@
   24.19  instantiation vec :: (real_inner, finite) real_inner
   24.20  begin
   24.21  
   24.22 -definition "inner x y = setsum (\<lambda>i. inner (x$i) (y$i)) UNIV"
   24.23 +definition "inner x y = sum (\<lambda>i. inner (x$i) (y$i)) UNIV"
   24.24  
   24.25  instance proof
   24.26    fix r :: real and x y z :: "'a ^ 'b"
   24.27 @@ -458,16 +458,16 @@
   24.28      by (simp add: inner_commute)
   24.29    show "inner (x + y) z = inner x z + inner y z"
   24.30      unfolding inner_vec_def
   24.31 -    by (simp add: inner_add_left setsum.distrib)
   24.32 +    by (simp add: inner_add_left sum.distrib)
   24.33    show "inner (scaleR r x) y = r * inner x y"
   24.34      unfolding inner_vec_def
   24.35 -    by (simp add: setsum_distrib_left)
   24.36 +    by (simp add: sum_distrib_left)
   24.37    show "0 \<le> inner x x"
   24.38      unfolding inner_vec_def
   24.39 -    by (simp add: setsum_nonneg)
   24.40 +    by (simp add: sum_nonneg)
   24.41    show "inner x x = 0 \<longleftrightarrow> x = 0"
   24.42      unfolding inner_vec_def
   24.43 -    by (simp add: vec_eq_iff setsum_nonneg_eq_0_iff)
   24.44 +    by (simp add: vec_eq_iff sum_nonneg_eq_0_iff)
   24.45    show "norm x = sqrt (inner x x)"
   24.46      unfolding inner_vec_def norm_vec_def setL2_def
   24.47      by (simp add: power2_norm_eq_inner)
   24.48 @@ -493,22 +493,22 @@
   24.49    unfolding inner_vec_def
   24.50    apply (cases "i = j")
   24.51    apply clarsimp
   24.52 -  apply (subst setsum.remove [of _ j], simp_all)
   24.53 -  apply (rule setsum.neutral, simp add: axis_def)
   24.54 -  apply (rule setsum.neutral, simp add: axis_def)
   24.55 +  apply (subst sum.remove [of _ j], simp_all)
   24.56 +  apply (rule sum.neutral, simp add: axis_def)
   24.57 +  apply (rule sum.neutral, simp add: axis_def)
   24.58    done
   24.59  
   24.60 -lemma setsum_single:
   24.61 +lemma sum_single:
   24.62    assumes "finite A" and "k \<in> A" and "f k = y"
   24.63    assumes "\<And>i. i \<in> A \<Longrightarrow> i \<noteq> k \<Longrightarrow> f i = 0"
   24.64    shows "(\<Sum>i\<in>A. f i) = y"
   24.65 -  apply (subst setsum.remove [OF assms(1,2)])
   24.66 -  apply (simp add: setsum.neutral assms(3,4))
   24.67 +  apply (subst sum.remove [OF assms(1,2)])
   24.68 +  apply (simp add: sum.neutral assms(3,4))
   24.69    done
   24.70  
   24.71  lemma inner_axis: "inner x (axis i y) = inner (x $ i) y"
   24.72    unfolding inner_vec_def
   24.73 -  apply (rule_tac k=i in setsum_single)
   24.74 +  apply (rule_tac k=i in sum_single)
   24.75    apply simp_all
   24.76    apply (simp add: axis_def)
   24.77    done
    25.1 --- a/src/HOL/Analysis/Gamma_Function.thy	Sun Oct 16 22:43:51 2016 +0200
    25.2 +++ b/src/HOL/Analysis/Gamma_Function.thy	Mon Oct 17 11:46:22 2016 +0200
    25.3 @@ -407,7 +407,7 @@
    25.4      moreover have "N \<ge> 2" "N \<ge> M" unfolding N_def by simp_all
    25.5      moreover have "(\<Sum>k=m..n. 1/(of_nat k)\<^sup>2) < e'" if "m \<ge> N" for m n
    25.6        using M[OF order.trans[OF \<open>N \<ge> M\<close> that]] unfolding real_norm_def
    25.7 -      by (subst (asm) abs_of_nonneg) (auto intro: setsum_nonneg simp: divide_simps)
    25.8 +      by (subst (asm) abs_of_nonneg) (auto intro: sum_nonneg simp: divide_simps)
    25.9      moreover note calculation
   25.10    } note N = this
   25.11  
   25.12 @@ -432,25 +432,25 @@
   25.13        by (simp add: ln_Gamma_series_def algebra_simps)
   25.14      also have "(\<Sum>k=1..n. Ln (t / of_nat k + 1)) - (\<Sum>k=1..m. Ln (t / of_nat k + 1)) =
   25.15                   (\<Sum>k\<in>{1..n}-{1..m}. Ln (t / of_nat k + 1))" using mn
   25.16 -      by (simp add: setsum_diff)
   25.17 +      by (simp add: sum_diff)
   25.18      also from mn have "{1..n}-{1..m} = {Suc m..n}" by fastforce
   25.19      also have "-(t * Ln (of_nat n)) - (-(t * Ln (of_nat m))) =
   25.20                     (\<Sum>k = Suc m..n. t * Ln (of_nat (k - 1)) - t * Ln (of_nat k))" using mn
   25.21 -      by (subst setsum_telescope'' [symmetric]) simp_all
   25.22 +      by (subst sum_telescope'' [symmetric]) simp_all
   25.23      also have "... = (\<Sum>k = Suc m..n. t * Ln (of_nat (k - 1) / of_nat k))" using mn N
   25.24 -      by (intro setsum_cong_Suc)
   25.25 +      by (intro sum_cong_Suc)
   25.26           (simp_all del: of_nat_Suc add: field_simps Ln_of_nat Ln_of_nat_over_of_nat)
   25.27      also have "of_nat (k - 1) / of_nat k = 1 - 1 / (of_nat k :: complex)" if "k \<in> {Suc m..n}" for k
   25.28        using that of_nat_eq_0_iff[of "Suc i" for i] by (cases k) (simp_all add: divide_simps)
   25.29      hence "(\<Sum>k = Suc m..n. t * Ln (of_nat (k - 1) / of_nat k)) =
   25.30               (\<Sum>k = Suc m..n. t * Ln (1 - 1 / of_nat k))" using mn N
   25.31 -      by (intro setsum.cong) simp_all
   25.32 -    also note setsum.distrib [symmetric]
   25.33 +      by (intro sum.cong) simp_all
   25.34 +    also note sum.distrib [symmetric]
   25.35      also have "norm (\<Sum>k=Suc m..n. t * Ln (1 - 1/of_nat k) + Ln (t/of_nat k + 1)) \<le>
   25.36        (\<Sum>k=Suc m..n. 2 * (norm t + (norm t)\<^sup>2) / (real_of_nat k)\<^sup>2)" using t_nz N(2) mn norm_t
   25.37 -      by (intro order.trans[OF norm_setsum setsum_mono[OF ln_Gamma_series_complex_converges_aux]]) simp_all
   25.38 +      by (intro order.trans[OF norm_sum sum_mono[OF ln_Gamma_series_complex_converges_aux]]) simp_all
   25.39      also have "... \<le> 2 * (norm t + norm t^2) * (\<Sum>k=Suc m..n. 1 / (of_nat k)\<^sup>2)"
   25.40 -      by (simp add: setsum_distrib_left)
   25.41 +      by (simp add: sum_distrib_left)
   25.42      also have "... < 2 * (norm t + norm t^2) * e'" using mn z t_nz
   25.43        by (intro mult_strict_left_mono N mult_pos_pos add_pos_pos) simp_all
   25.44      also from e''_pos have "... = e * ((cmod t + (cmod t)\<^sup>2) / e'')"
   25.45 @@ -508,7 +508,7 @@
   25.46    from assms have "z \<noteq> 0" by (intro notI) auto
   25.47    with assms have "exp (ln_Gamma_series z n) =
   25.48            (of_nat n) powr z / (z * (\<Prod>k=1..n. exp (Ln (z / of_nat k + 1))))"
   25.49 -    unfolding ln_Gamma_series_def powr_def by (simp add: exp_diff exp_setsum)
   25.50 +    unfolding ln_Gamma_series_def powr_def by (simp add: exp_diff exp_sum)
   25.51    also from assms have "(\<Prod>k=1..n. exp (Ln (z / of_nat k + 1))) = (\<Prod>k=1..n. z / of_nat k + 1)"
   25.52      by (intro setprod.cong[OF refl], subst exp_Ln) (auto simp: field_simps plus_of_nat_eq_0_imp)
   25.53    also have "... = (\<Prod>k=1..n. z + k) / fact n"
   25.54 @@ -540,12 +540,12 @@
   25.55    proof eventually_elim
   25.56      fix n :: nat assume n: "n > 0"
   25.57      have "(\<Sum>k<n. ?f k) = (\<Sum>k=1..n. z / of_nat k - ln (1 + z / of_nat k))"
   25.58 -      by (subst atLeast0LessThan [symmetric], subst setsum_shift_bounds_Suc_ivl [symmetric],
   25.59 +      by (subst atLeast0LessThan [symmetric], subst sum_shift_bounds_Suc_ivl [symmetric],
   25.60            subst atLeastLessThanSuc_atLeastAtMost) simp_all
   25.61      also have "\<dots> = z * of_real (harm n) - (\<Sum>k=1..n. ln (1 + z / of_nat k))"
   25.62 -      by (simp add: harm_def setsum_subtractf setsum_distrib_left divide_inverse)
   25.63 +      by (simp add: harm_def sum_subtractf sum_distrib_left divide_inverse)
   25.64      also from n have "\<dots> - ?g n = 0"
   25.65 -      by (simp add: ln_Gamma_series_def setsum_subtractf algebra_simps Ln_of_nat)
   25.66 +      by (simp add: ln_Gamma_series_def sum_subtractf algebra_simps Ln_of_nat)
   25.67      finally show "(\<Sum>k<n. ?f k) - ?g n = 0" .
   25.68    qed
   25.69    show "(\<lambda>n. (\<Sum>k<n. ?f k) - ?g n) \<longlonglongrightarrow> 0" by (subst tendsto_cong[OF A]) simp_all
   25.70 @@ -654,13 +654,13 @@
   25.71      fix m :: nat
   25.72      have "{..<m+k} = {..<k} \<union> {k..<m+k}" by auto
   25.73      also have "(\<Sum>n\<in>\<dots>. f n) = (\<Sum>n<k. f n) + (\<Sum>n=k..<m+k. f n)"
   25.74 -      by (rule setsum.union_disjoint) auto
   25.75 +      by (rule sum.union_disjoint) auto
   25.76      also have "(\<Sum>n=k..<m+k. f n) = (\<Sum>n=0..<m+k-k. f (n + k))"
   25.77 -      by (intro setsum.reindex_cong[of "\<lambda>n. n + k"])
   25.78 +      by (intro sum.reindex_cong[of "\<lambda>n. n + k"])
   25.79           (simp, subst image_add_atLeastLessThan, auto)
   25.80      finally show "(\<Sum>n<k. f n) + (\<Sum>n<m. f (n + k)) = (\<Sum>n<m+k. f n)" by (simp add: atLeast0LessThan)
   25.81    qed
   25.82 -  finally have "(\<lambda>a. setsum f {..<a}) \<longlonglongrightarrow> lim (\<lambda>m. setsum f {..<m + k})"
   25.83 +  finally have "(\<lambda>a. sum f {..<a}) \<longlonglongrightarrow> lim (\<lambda>m. sum f {..<m + k})"
   25.84      by (auto simp: convergent_LIMSEQ_iff dest: LIMSEQ_offset)
   25.85    thus ?thesis by (auto simp: summable_iff_convergent convergent_def)
   25.86  qed
   25.87 @@ -733,10 +733,10 @@
   25.88              sums Digamma z" by (simp add: add_ac)
   25.89    hence "(\<lambda>m. (\<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1))) - 
   25.90                (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z"
   25.91 -    by (simp add: sums_def setsum_subtractf)
   25.92 +    by (simp add: sums_def sum_subtractf)
   25.93    also have "(\<lambda>m. (\<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1)))) = 
   25.94                   (\<lambda>m. of_real (ln (m + 1)) :: 'a)"
   25.95 -    by (subst setsum_lessThan_telescope) simp_all
   25.96 +    by (subst sum_lessThan_telescope) simp_all
   25.97    finally show ?thesis by (rule Lim_transform) (insert lim, simp)
   25.98  qed
   25.99  
  25.100 @@ -944,7 +944,7 @@
  25.101        using z' n by (intro uniformly_convergent_mult Polygamma_converges) (simp_all add: n'_def)
  25.102      thus "uniformly_convergent_on (ball z d)
  25.103                (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i :: 'a) ^ (n'+1)))"
  25.104 -      by (subst (asm) setsum_distrib_left) simp
  25.105 +      by (subst (asm) sum_distrib_left) simp
  25.106    qed (insert Polygamma_converges'[OF z' n'] d, simp_all)
  25.107    also have "(\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1))) =
  25.108                 (- of_nat n') * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))"
  25.109 @@ -2573,7 +2573,7 @@
  25.110  proof -
  25.111    have "(\<Prod>k=1..n. exp (z * of_real (ln (1 + 1 / of_nat k)))) =
  25.112            exp (z * of_real (\<Sum>k = 1..n. ln (1 + 1 / real_of_nat k)))"
  25.113 -    by (subst exp_setsum [symmetric]) (simp_all add: setsum_distrib_left)
  25.114 +    by (subst exp_sum [symmetric]) (simp_all add: sum_distrib_left)
  25.115    also have "(\<Sum>k=1..n. ln (1 + 1 / of_nat k) :: real) = ln (\<Prod>k=1..n. 1 + 1 / real_of_nat k)"
  25.116      by (subst ln_setprod [symmetric]) (auto intro!: add_pos_nonneg)
  25.117    also have "(\<Prod>k=1..n. 1 + 1 / of_nat k :: real) = (\<Prod>k=1..n. (of_nat k + 1) / of_nat k)"
  25.118 @@ -2654,9 +2654,9 @@
  25.119    have "(\<lambda>n. \<Sum>k=1..n. z / of_nat k - ln (1 + z / of_nat k)) \<longlonglongrightarrow> ln_Gamma z + euler_mascheroni * z + ln z"
  25.120      using ln_Gamma_series'_aux[OF False]
  25.121      by (simp only: atLeastLessThanSuc_atLeastAtMost [symmetric] One_nat_def
  25.122 -                   setsum_shift_bounds_Suc_ivl sums_def atLeast0LessThan)
  25.123 +                   sum_shift_bounds_Suc_ivl sums_def atLeast0LessThan)
  25.124    from tendsto_exp[OF this] False z have "?f \<longlonglongrightarrow> z * exp (euler_mascheroni * z) * Gamma z"
  25.125 -    by (simp add: exp_add exp_setsum exp_diff mult_ac Gamma_complex_altdef A)
  25.126 +    by (simp add: exp_add exp_sum exp_diff mult_ac Gamma_complex_altdef A)
  25.127    from tendsto_mult[OF tendsto_const[of "exp (-euler_mascheroni * z) / z"] this] z
  25.128      show "Gamma_series_weierstrass z \<longlonglongrightarrow> Gamma z"
  25.129      by (simp add: exp_minus divide_simps Gamma_series_weierstrass_def [abs_def])
    26.1 --- a/src/HOL/Analysis/Harmonic_Numbers.thy	Sun Oct 16 22:43:51 2016 +0200
    26.2 +++ b/src/HOL/Analysis/Harmonic_Numbers.thy	Mon Oct 17 11:46:22 2016 +0200
    26.3 @@ -25,7 +25,7 @@
    26.4    thus "ln 2 < (1::real)" by (subst (asm) exp_less_cancel_iff) simp
    26.5  qed
    26.6  
    26.7 -lemma setsum_Suc_diff':
    26.8 +lemma sum_Suc_diff':
    26.9    fixes f :: "nat \<Rightarrow> 'a::ab_group_add"
   26.10    assumes "m \<le> n"
   26.11    shows "(\<Sum>i = m..<n. f (Suc i) - f i) = f n - f m"
   26.12 @@ -44,10 +44,10 @@
   26.13    by (simp add: harm_def)
   26.14  
   26.15  lemma harm_nonneg: "harm n \<ge> (0 :: 'a :: {real_normed_field,linordered_field})"
   26.16 -  unfolding harm_def by (intro setsum_nonneg) simp_all
   26.17 +  unfolding harm_def by (intro sum_nonneg) simp_all
   26.18  
   26.19  lemma harm_pos: "n > 0 \<Longrightarrow> harm n > (0 :: 'a :: {real_normed_field,linordered_field})"
   26.20 -  unfolding harm_def by (intro setsum_pos) simp_all
   26.21 +  unfolding harm_def by (intro sum_pos) simp_all
   26.22  
   26.23  lemma of_real_harm: "of_real (harm n) = harm n"
   26.24    unfolding harm_def by simp
   26.25 @@ -73,7 +73,7 @@
   26.26    also have "\<dots> \<longleftrightarrow> convergent (\<lambda>n. \<Sum>k=Suc 0..Suc n. inverse (of_nat k) :: real)"
   26.27      unfolding harm_def[abs_def] by (subst convergent_Suc_iff) simp_all
   26.28    also have "... \<longleftrightarrow> convergent (\<lambda>n. \<Sum>k\<le>n. inverse (of_nat (Suc k)) :: real)"
   26.29 -    by (subst setsum_shift_bounds_cl_Suc_ivl) (simp add: atLeast0AtMost)
   26.30 +    by (subst sum_shift_bounds_cl_Suc_ivl) (simp add: atLeast0AtMost)
   26.31    also have "... \<longleftrightarrow> summable (\<lambda>n. inverse (of_nat n) :: real)"
   26.32      by (subst summable_Suc_iff [symmetric]) (simp add: summable_iff_convergent')
   26.33    also have "\<not>..." by (rule not_summable_harmonic)
   26.34 @@ -126,7 +126,7 @@
   26.35    "euler_mascheroni.sum_integral_diff_series n = harm (Suc n) - ln (of_nat (Suc n))"
   26.36  proof -
   26.37    have "harm (Suc n) = (\<Sum>k=0..n. inverse (of_nat k + 1) :: real)" unfolding harm_def
   26.38 -    unfolding One_nat_def by (subst setsum_shift_bounds_cl_Suc_ivl) (simp add: add_ac)
   26.39 +    unfolding One_nat_def by (subst sum_shift_bounds_cl_Suc_ivl) (simp add: add_ac)
   26.40    moreover have "((\<lambda>x. inverse (x + 1) :: real) has_integral ln (of_nat n + 1) - ln (0 + 1))
   26.41                     {0..of_nat n}"
   26.42      by (intro fundamental_theorem_of_calculus)
   26.43 @@ -201,16 +201,16 @@
   26.44      fix n :: nat assume n: "n > 0"
   26.45      have "(\<Sum>k<2*n. (-1)^k / real_of_nat (Suc k)) =
   26.46                (\<Sum>k<2*n. ((-1)^k + ?g k) / of_nat (Suc k)) - (\<Sum>k<2*n. ?g k / of_nat (Suc k))"
   26.47 -      by (simp add: setsum.distrib algebra_simps divide_inverse)
   26.48 +      by (simp add: sum.distrib algebra_simps divide_inverse)
   26.49      also have "(\<Sum>k<2*n. ((-1)^k + ?g k) / real_of_nat (Suc k)) = harm (2*n)"
   26.50 -      unfolding harm_altdef by (intro setsum.cong) (auto simp: field_simps)
   26.51 +      unfolding harm_altdef by (intro sum.cong) (auto simp: field_simps)
   26.52      also have "(\<Sum>k<2*n. ?g k / real_of_nat (Suc k)) = (\<Sum>k|k<2*n \<and> odd k. ?g k / of_nat (Suc k))"
   26.53 -      by (intro setsum.mono_neutral_right) auto
   26.54 +      by (intro sum.mono_neutral_right) auto
   26.55      also have "\<dots> = (\<Sum>k|k<2*n \<and> odd k. 2 / (real_of_nat (Suc k)))"
   26.56 -      by (intro setsum.cong) auto
   26.57 +      by (intro sum.cong) auto
   26.58      also have "(\<Sum>k|k<2*n \<and> odd k. 2 / (real_of_nat (Suc k))) = harm n"
   26.59        unfolding harm_altdef
   26.60 -      by (intro setsum.reindex_cong[of "\<lambda>n. 2*n+1"]) (auto simp: inj_on_def field_simps elim!: oddE)
   26.61 +      by (intro sum.reindex_cong[of "\<lambda>n. 2*n+1"]) (auto simp: inj_on_def field_simps elim!: oddE)
   26.62      also have "harm (2*n) - harm n = ?em (2*n) - ?em n + ln 2" using n
   26.63        by (simp_all add: algebra_simps ln_mult)
   26.64      finally show "?em (2*n) - ?em n + ln 2 = (\<Sum>k<2*n. (-1)^k / real_of_nat (Suc k))" ..
   26.65 @@ -388,9 +388,9 @@
   26.66    finally have "euler_mascheroni \<ge> (\<Sum>k\<le>n. D k) + 1 / (of_nat (2 * (n+2)))"
   26.67      by (simp add: inv_def field_simps)
   26.68    also have "(\<Sum>k\<le>n. D k) = harm (Suc n) - (\<Sum>k\<le>n. ln (real_of_nat (Suc k+1)) - ln (of_nat (k+1)))"
   26.69 -    unfolding harm_altdef D_def by (subst lessThan_Suc_atMost) (simp add:  setsum.distrib setsum_subtractf)
   26.70 +    unfolding harm_altdef D_def by (subst lessThan_Suc_atMost) (simp add:  sum.distrib sum_subtractf)
   26.71    also have "(\<Sum>k\<le>n. ln (real_of_nat (Suc k+1)) - ln (of_nat (k+1))) = ln (of_nat (n+2))"
   26.72 -    by (subst atLeast0AtMost [symmetric], subst setsum_Suc_diff) simp_all
   26.73 +    by (subst atLeast0AtMost [symmetric], subst sum_Suc_diff) simp_all
   26.74    finally show "euler_mascheroni \<ge> harm (Suc n) - ln (real_of_nat (n + 2)) + 1/real_of_nat (2 * (n + 2))"
   26.75      by simp
   26.76  
   26.77 @@ -422,9 +422,9 @@
   26.78    finally have "euler_mascheroni \<le> (\<Sum>k\<le>n. D k) + 1 / of_nat (2 * (n+1))"
   26.79      by (simp add: inv_def field_simps)
   26.80    also have "(\<Sum>k\<le>n. D k) = harm (Suc n) - (\<Sum>k\<le>n. ln (real_of_nat (Suc k+1)) - ln (of_nat (k+1)))"
   26.81 -    unfolding harm_altdef D_def by (subst lessThan_Suc_atMost) (simp add:  setsum.distrib setsum_subtractf)
   26.82 +    unfolding harm_altdef D_def by (subst lessThan_Suc_atMost) (simp add:  sum.distrib sum_subtractf)
   26.83    also have "(\<Sum>k\<le>n. ln (real_of_nat (Suc k+1)) - ln (of_nat (k+1))) = ln (of_nat (n+2))"
   26.84 -    by (subst atLeast0AtMost [symmetric], subst setsum_Suc_diff) simp_all
   26.85 +    by (subst atLeast0AtMost [symmetric], subst sum_Suc_diff) simp_all
   26.86    finally show "euler_mascheroni \<le> harm (Suc n) - ln (real_of_nat (n + 2)) + 1/real_of_nat (2 * (n + 1))"
   26.87      by simp
   26.88  qed
    27.1 --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy	Sun Oct 16 22:43:51 2016 +0200
    27.2 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy	Mon Oct 17 11:46:22 2016 +0200
    27.3 @@ -176,11 +176,11 @@
    27.4    unfolding forall_in_division[OF assms(2)]
    27.5    by (metis antisym_conv assms content_pos_le content_subset division_ofD(2))
    27.6  
    27.7 -lemma setsum_content_null:
    27.8 +lemma sum_content_null:
    27.9    assumes "content (cbox a b) = 0"
   27.10      and "p tagged_division_of (cbox a b)"
   27.11 -  shows "setsum (\<lambda>(x,k). content k *\<^sub>R f x) p = (0::'a::real_normed_vector)"
   27.12 -proof (rule setsum.neutral, rule)
   27.13 +  shows "sum (\<lambda>(x,k). content k *\<^sub>R f x) p = (0::'a::real_normed_vector)"
   27.14 +proof (rule sum.neutral, rule)
   27.15    fix y
   27.16    assume y: "y \<in> p"
   27.17    obtain x k where xk: "y = (x, k)"
   27.18 @@ -199,12 +199,12 @@
   27.19  lemma operative_content[intro]: "add.operative content"
   27.20    by (force simp add: add.operative_def content_split[symmetric] content_eq_0_interior)
   27.21  
   27.22 -lemma additive_content_division: "d division_of (cbox a b) \<Longrightarrow> setsum content d = content (cbox a b)"
   27.23 -  by (metis operative_content setsum.operative_division)
   27.24 +lemma additive_content_division: "d division_of (cbox a b) \<Longrightarrow> sum content d = content (cbox a b)"
   27.25 +  by (metis operative_content sum.operative_division)
   27.26  
   27.27  lemma additive_content_tagged_division:
   27.28 -  "d tagged_division_of (cbox a b) \<Longrightarrow> setsum (\<lambda>(x,l). content l) d = content (cbox a b)"
   27.29 -  unfolding setsum.operative_tagged_division[OF operative_content, symmetric] by blast
   27.30 +  "d tagged_division_of (cbox a b) \<Longrightarrow> sum (\<lambda>(x,l). content l) d = content (cbox a b)"
   27.31 +  unfolding sum.operative_tagged_division[OF operative_content, symmetric] by blast
   27.32  
   27.33  lemma content_real_eq_0: "content {a .. b::real} = 0 \<longleftrightarrow> a \<ge> b"
   27.34    by (metis atLeastatMost_empty_iff2 content_empty content_real diff_self eq_iff le_cases le_iff_diff_le_0)
   27.35 @@ -234,14 +234,14 @@
   27.36    "(f has_integral y) (cbox a b) \<longleftrightarrow>
   27.37      (\<forall>e>0. \<exists>d. gauge d \<and>
   27.38        (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
   27.39 -        norm (setsum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
   27.40 +        norm (sum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
   27.41    by (auto simp: dist_norm eventually_division_filter has_integral_def tendsto_iff)
   27.42  
   27.43  lemma has_integral_real:
   27.44    "(f has_integral y) {a .. b::real} \<longleftrightarrow>
   27.45      (\<forall>e>0. \<exists>d. gauge d \<and>
   27.46        (\<forall>p. p tagged_division_of {a .. b} \<and> d fine p \<longrightarrow>
   27.47 -        norm (setsum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
   27.48 +        norm (sum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
   27.49    unfolding box_real[symmetric]
   27.50    by (rule has_integral)
   27.51  
   27.52 @@ -364,7 +364,7 @@
   27.53    shows "((\<lambda>x. c) has_integral (content (cbox a b) *\<^sub>R c)) (cbox a b)"
   27.54    using eventually_division_filter_tagged_division[of "cbox a b"]
   27.55       additive_content_tagged_division[of _ a b]
   27.56 -  by (auto simp: has_integral_cbox split_beta' scaleR_setsum_left[symmetric]
   27.57 +  by (auto simp: has_integral_cbox split_beta' scaleR_sum_left[symmetric]
   27.58             elim!: eventually_mono intro!: tendsto_cong[THEN iffD1, OF _ tendsto_const])
   27.59  
   27.60  lemma has_integral_const_real [intro]:
   27.61 @@ -391,7 +391,7 @@
   27.62      unfolding has_integral_cbox
   27.63      using eventually_division_filter_tagged_division[of "cbox a b"]
   27.64      by (subst tendsto_cong[where g="\<lambda>_. 0"])
   27.65 -       (auto elim!: eventually_mono intro!: setsum.neutral simp: tag_in_interval)
   27.66 +       (auto elim!: eventually_mono intro!: sum.neutral simp: tag_in_interval)
   27.67    {
   27.68      presume "\<not> (\<exists>a b. s = cbox a b) \<Longrightarrow> ?thesis"
   27.69      with assms lem show ?thesis
   27.70 @@ -425,7 +425,7 @@
   27.71    from pos_bounded obtain B where B: "0 < B" "\<And>x. norm (h x) \<le> norm x * B"
   27.72      by blast
   27.73    have lem: "\<And>a b y f::'n\<Rightarrow>'a. (f has_integral y) (cbox a b) \<Longrightarrow> ((h \<circ> f) has_integral h y) (cbox a b)"
   27.74 -    unfolding has_integral_cbox by (drule tendsto) (simp add: setsum scaleR split_beta')
   27.75 +    unfolding has_integral_cbox by (drule tendsto) (simp add: sum scaleR split_beta')
   27.76    {
   27.77      presume "\<not> (\<exists>a b. s = cbox a b) \<Longrightarrow> ?thesis"
   27.78      then show ?thesis
   27.79 @@ -531,7 +531,7 @@
   27.80      ((\<lambda>x. f x + g x) has_integral (k + l)) (cbox a b)"
   27.81      for f :: "'n \<Rightarrow> 'a" and g a b k l
   27.82      unfolding has_integral_cbox
   27.83 -    by (simp add: split_beta' scaleR_add_right setsum.distrib[abs_def] tendsto_add)
   27.84 +    by (simp add: split_beta' scaleR_add_right sum.distrib[abs_def] tendsto_add)
   27.85    {
   27.86      presume "\<not> (\<exists>a b. s = cbox a b) \<Longrightarrow> ?thesis"
   27.87      then show ?thesis
   27.88 @@ -666,10 +666,10 @@
   27.89    shows "integral s (\<lambda>x. f x \<bullet> k) = integral s f \<bullet> k"
   27.90    unfolding integral_linear[OF assms(1) bounded_linear_inner_left,unfolded o_def] ..
   27.91  
   27.92 -lemma has_integral_setsum:
   27.93 +lemma has_integral_sum:
   27.94    assumes "finite t"
   27.95      and "\<forall>a\<in>t. ((f a) has_integral (i a)) s"
   27.96 -  shows "((\<lambda>x. setsum (\<lambda>a. f a x) t) has_integral (setsum i t)) s"
   27.97 +  shows "((\<lambda>x. sum (\<lambda>a. f a x) t) has_integral (sum i t)) s"
   27.98    using assms(1) subset_refl[of t]
   27.99  proof (induct rule: finite_subset_induct)
  27.100    case empty
  27.101 @@ -680,16 +680,16 @@
  27.102      by (simp add: has_integral_add)
  27.103  qed
  27.104  
  27.105 -lemma integral_setsum:
  27.106 +lemma integral_sum:
  27.107    "\<lbrakk>finite t;  \<forall>a\<in>t. (f a) integrable_on s\<rbrakk> \<Longrightarrow>
  27.108 -   integral s (\<lambda>x. setsum (\<lambda>a. f a x) t) = setsum (\<lambda>a. integral s (f a)) t"
  27.109 -  by (auto intro: has_integral_setsum integrable_integral)
  27.110 -
  27.111 -lemma integrable_setsum:
  27.112 -  "\<lbrakk>finite t;  \<forall>a\<in>t. (f a) integrable_on s\<rbrakk> \<Longrightarrow> (\<lambda>x. setsum (\<lambda>a. f a x) t) integrable_on s"
  27.113 +   integral s (\<lambda>x. sum (\<lambda>a. f a x) t) = sum (\<lambda>a. integral s (f a)) t"
  27.114 +  by (auto intro: has_integral_sum integrable_integral)
  27.115 +
  27.116 +lemma integrable_sum:
  27.117 +  "\<lbrakk>finite t;  \<forall>a\<in>t. (f a) integrable_on s\<rbrakk> \<Longrightarrow> (\<lambda>x. sum (\<lambda>a. f a x) t) integrable_on s"
  27.118    unfolding integrable_on_def
  27.119    apply (drule bchoice)
  27.120 -  using has_integral_setsum[of t]
  27.121 +  using has_integral_sum[of t]
  27.122    apply auto
  27.123    done
  27.124  
  27.125 @@ -760,7 +760,7 @@
  27.126  lemma has_integral_null [intro]: "content(cbox a b) = 0 \<Longrightarrow> (f has_integral 0) (cbox a b)"
  27.127    unfolding has_integral_cbox
  27.128    using eventually_division_filter_tagged_division[of "cbox a b"]
  27.129 -  by (subst tendsto_cong[where g="\<lambda>_. 0"]) (auto elim: eventually_mono intro: setsum_content_null)
  27.130 +  by (subst tendsto_cong[where g="\<lambda>_. 0"]) (auto elim: eventually_mono intro: sum_content_null)
  27.131  
  27.132  lemma has_integral_null_real [intro]: "content {a .. b::real} = 0 \<Longrightarrow> (f has_integral 0) {a .. b}"
  27.133    by (metis box_real(2) has_integral_null)
  27.134 @@ -840,7 +840,7 @@
  27.135    hence "\<forall>b\<in>Basis. (((\<lambda>x. x *\<^sub>R b) \<circ> (\<lambda>x. f x \<bullet> b)) has_integral ((y \<bullet> b) *\<^sub>R b)) A"
  27.136      by (intro ballI has_integral_linear) (simp_all add: bounded_linear_scaleR_left)
  27.137    hence "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. (y \<bullet> b) *\<^sub>R b)) A"
  27.138 -    by (intro has_integral_setsum) (simp_all add: o_def)
  27.139 +    by (intro has_integral_sum) (simp_all add: o_def)
  27.140    thus "(f has_integral y) A" by (simp add: euclidean_representation)
  27.141  qed
  27.142  
  27.143 @@ -865,7 +865,7 @@
  27.144    hence "\<forall>b\<in>Basis. (((\<lambda>x. x *\<^sub>R b) \<circ> (\<lambda>x. f x \<bullet> b)) has_integral (y b *\<^sub>R b)) A"
  27.145      by (intro ballI has_integral_linear) (simp_all add: bounded_linear_scaleR_left)
  27.146    hence "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. y b *\<^sub>R b)) A"
  27.147 -    by (intro has_integral_setsum) (simp_all add: o_def)
  27.148 +    by (intro has_integral_sum) (simp_all add: o_def)
  27.149    thus "f integrable_on A" by (auto simp: integrable_on_def o_def euclidean_representation)
  27.150  qed
  27.151  
  27.152 @@ -885,7 +885,7 @@
  27.153    have "integral A f = integral A (\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b)"
  27.154      by (simp add: euclidean_representation)
  27.155    also from integrable have "\<dots> = (\<Sum>a\<in>Basis. integral A (\<lambda>x. (f x \<bullet> a) *\<^sub>R a))"
  27.156 -    by (subst integral_setsum) (simp_all add: o_def)
  27.157 +    by (subst integral_sum) (simp_all add: o_def)
  27.158    finally show ?thesis .
  27.159  qed
  27.160  
  27.161 @@ -944,7 +944,7 @@
  27.162    from choice[OF this] guess p .. note p = conjunctD2[OF this[rule_format]]
  27.163    have dp: "\<And>i n. i\<le>n \<Longrightarrow> d i fine p n"
  27.164      using p(2) unfolding fine_inters by auto
  27.165 -  have "Cauchy (\<lambda>n. setsum (\<lambda>(x,k). content k *\<^sub>R (f x)) (p n))"
  27.166 +  have "Cauchy (\<lambda>n. sum (\<lambda>(x,k). content k *\<^sub>R (f x)) (p n))"
  27.167    proof (rule CauchyI, goal_cases)
  27.168      case (1 e)
  27.169      then guess N unfolding real_arch_inverse[of e] .. note N=this
  27.170 @@ -1124,9 +1124,9 @@
  27.171          unfolding xk split_conv by auto
  27.172      } note [simp] = this
  27.173      have lem3: "\<And>g :: 'a set \<Rightarrow> 'a set. finite p \<Longrightarrow>
  27.174 -                  setsum (\<lambda>(x, k). content k *\<^sub>R f x) {(x,g k) |x k. (x,k) \<in> p \<and> g k \<noteq> {}} =
  27.175 -                  setsum (\<lambda>(x, k). content k *\<^sub>R f x) ((\<lambda>(x, k). (x, g k)) ` p)"
  27.176 -      by (rule setsum.mono_neutral_left) auto
  27.177 +                  sum (\<lambda>(x, k). content k *\<^sub>R f x) {(x,g k) |x k. (x,k) \<in> p \<and> g k \<noteq> {}} =
  27.178 +                  sum (\<lambda>(x, k). content k *\<^sub>R f x) ((\<lambda>(x, k). (x, g k)) ` p)"
  27.179 +      by (rule sum.mono_neutral_left) auto
  27.180      let ?M1 = "{(x, kk \<inter> {x. x\<bullet>k \<le> c}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}}"
  27.181      have d1_fine: "d1 fine ?M1"
  27.182        by (force intro: fineI dest: fineD[OF p(2)] simp add: split: if_split_asm)
  27.183 @@ -1218,10 +1218,10 @@
  27.184        also have "\<dots> = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f x) +
  27.185          (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f x) - (i + j)"
  27.186          unfolding lem3[OF p(3)]
  27.187 -        by (subst (1 2) setsum.reindex_nontrivial[OF p(3)])
  27.188 +        by (subst (1 2) sum.reindex_nontrivial[OF p(3)])
  27.189             (auto intro!: k eq0 tagged_division_split_left_inj_content[OF p(1)] tagged_division_split_right_inj_content[OF p(1)]
  27.190                   simp: cont_eq)+
  27.191 -      also note setsum.distrib[symmetric]
  27.192 +      also note sum.distrib[symmetric]
  27.193        also have "\<And>x. x \<in> p \<Longrightarrow>
  27.194                      (\<lambda>(x,ka). content (ka \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f x) x +
  27.195                      (\<lambda>(x,ka). content (ka \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f x) x =
  27.196 @@ -1236,7 +1236,7 @@
  27.197            unfolding uv content_split[OF k,of u v c]
  27.198            by auto
  27.199        qed
  27.200 -      note setsum.cong [OF _ this]
  27.201 +      note sum.cong [OF _ this]
  27.202        finally have "(\<Sum>(x, k)\<in>{(x, kk \<inter> {x. x \<bullet> k \<le> c}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. x \<bullet> k \<le> c} \<noteq> {}}. content k *\<^sub>R f x) - i +
  27.203          ((\<Sum>(x, k)\<in>{(x, kk \<inter> {x. c \<le> x \<bullet> k}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. c \<le> x \<bullet> k} \<noteq> {}}. content k *\<^sub>R f x) - j) =
  27.204          (\<Sum>(x, ka)\<in>p. content ka *\<^sub>R f x) - (i + j)"
  27.205 @@ -1258,7 +1258,7 @@
  27.206    obtains d where "gauge d"
  27.207      "\<forall>p1 p2. p1 tagged_division_of (cbox a b \<inter> {x. x\<bullet>k \<le> c}) \<and> d fine p1 \<and>
  27.208          p2 tagged_division_of (cbox a b \<inter> {x. x\<bullet>k \<ge> c}) \<and> d fine p2 \<longrightarrow>
  27.209 -        norm ((setsum (\<lambda>(x,k). content k *\<^sub>R f x) p1 + setsum (\<lambda>(x,k). content k *\<^sub>R f x) p2) - i) < e"
  27.210 +        norm ((sum (\<lambda>(x,k). content k *\<^sub>R f x) p1 + sum (\<lambda>(x,k). content k *\<^sub>R f x) p2) - i) < e"
  27.211  proof -
  27.212    guess d using has_integralD[OF assms(1-2)] . note d=this
  27.213    { fix p1 p2
  27.214 @@ -1287,9 +1287,9 @@
  27.215            using e k by (auto simp: inner_simps inner_not_same_Basis)
  27.216          have "(\<Sum>i\<in>Basis. \<bar>(x - (x + (e / 2 ) *\<^sub>R k)) \<bullet> i\<bar>) =
  27.217                (\<Sum>i\<in>Basis. (if i = k then e / 2 else 0))"
  27.218 -          using "*" by (blast intro: setsum.cong)
  27.219 +          using "*" by (blast intro: sum.cong)
  27.220          also have "\<dots> < e"
  27.221 -          apply (subst setsum.delta)
  27.222 +          apply (subst sum.delta)
  27.223            using e
  27.224            apply auto
  27.225            done
  27.226 @@ -1308,7 +1308,7 @@
  27.227      }
  27.228      then have "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - i) =
  27.229                 norm ((\<Sum>(x, k)\<in>p1 \<union> p2. content k *\<^sub>R f x) - i)"
  27.230 -      by (subst setsum.union_inter_neutral) (auto simp: p1 p2)
  27.231 +      by (subst sum.union_inter_neutral) (auto simp: p1 p2)
  27.232      also have "\<dots> < e"
  27.233        by (rule k d(2) p12 fine_union p1 p2)+
  27.234      finally have "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - i) < e" .
  27.235 @@ -1426,20 +1426,20 @@
  27.236  lemma dsum_bound:
  27.237    assumes "p division_of (cbox a b)"
  27.238      and "norm c \<le> e"
  27.239 -  shows "norm (setsum (\<lambda>l. content l *\<^sub>R c) p) \<le> e * content(cbox a b)"
  27.240 +  shows "norm (sum (\<lambda>l. content l *\<^sub>R c) p) \<le> e * content(cbox a b)"
  27.241  proof -
  27.242 -  have sumeq: "(\<Sum>i\<in>p. \<bar>content i\<bar>) = setsum content p"
  27.243 -    apply (rule setsum.cong)
  27.244 +  have sumeq: "(\<Sum>i\<in>p. \<bar>content i\<bar>) = sum content p"
  27.245 +    apply (rule sum.cong)
  27.246      using assms
  27.247      apply simp
  27.248      apply (metis abs_of_nonneg assms(1) content_pos_le division_ofD(4))
  27.249      done
  27.250    have e: "0 \<le> e"
  27.251      using assms(2) norm_ge_zero order_trans by blast
  27.252 -  have "norm (setsum (\<lambda>l. content l *\<^sub>R c) p) \<le> (\<Sum>i\<in>p. norm (content i *\<^sub>R c))"
  27.253 -    using norm_setsum by blast
  27.254 +  have "norm (sum (\<lambda>l. content l *\<^sub>R c) p) \<le> (\<Sum>i\<in>p. norm (content i *\<^sub>R c))"
  27.255 +    using norm_sum by blast
  27.256    also have "...  \<le> e * (\<Sum>i\<in>p. \<bar>content i\<bar>)"
  27.257 -    by (simp add: setsum_distrib_left[symmetric] mult.commute assms(2) mult_right_mono setsum_nonneg)
  27.258 +    by (simp add: sum_distrib_left[symmetric] mult.commute assms(2) mult_right_mono sum_nonneg)
  27.259    also have "... \<le> e * content (cbox a b)"
  27.260      apply (rule mult_left_mono [OF _ e])
  27.261      apply (simp add: sumeq)
  27.262 @@ -1451,7 +1451,7 @@
  27.263  lemma rsum_bound:
  27.264    assumes p: "p tagged_division_of (cbox a b)"
  27.265        and "\<forall>x\<in>cbox a b. norm (f x) \<le> e"
  27.266 -    shows "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p) \<le> e * content (cbox a b)"
  27.267 +    shows "norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p) \<le> e * content (cbox a b)"
  27.268  proof (cases "cbox a b = {}")
  27.269    case True show ?thesis
  27.270      using p unfolding True tagged_division_of_trivial by auto
  27.271 @@ -1459,7 +1459,7 @@
  27.272    case False
  27.273    then have e: "e \<ge> 0"
  27.274      by (meson ex_in_conv assms(2) norm_ge_zero order_trans)
  27.275 -  have setsum_le: "setsum (content \<circ> snd) p \<le> content (cbox a b)"
  27.276 +  have sum_le: "sum (content \<circ> snd) p \<le> content (cbox a b)"
  27.277      unfolding additive_content_tagged_division[OF p, symmetric] split_def
  27.278      by (auto intro: eq_refl)
  27.279    have con: "\<And>xk. xk \<in> p \<Longrightarrow> 0 \<le> content (snd xk)"
  27.280 @@ -1468,15 +1468,15 @@
  27.281    have norm: "\<And>xk. xk \<in> p \<Longrightarrow> norm (f (fst xk)) \<le> e"
  27.282      unfolding fst_conv using tagged_division_ofD(2,3)[OF p] assms
  27.283      by (metis prod.collapse subset_eq)
  27.284 -  have "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p) \<le> (\<Sum>i\<in>p. norm (case i of (x, k) \<Rightarrow> content k *\<^sub>R f x))"
  27.285 -    by (rule norm_setsum)
  27.286 +  have "norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p) \<le> (\<Sum>i\<in>p. norm (case i of (x, k) \<Rightarrow> content k *\<^sub>R f x))"
  27.287 +    by (rule norm_sum)
  27.288    also have "...  \<le> e * content (cbox a b)"
  27.289      unfolding split_def norm_scaleR
  27.290 -    apply (rule order_trans[OF setsum_mono])
  27.291 +    apply (rule order_trans[OF sum_mono])
  27.292      apply (rule mult_left_mono[OF _ abs_ge_zero, of _ e])
  27.293      apply (metis norm)
  27.294 -    unfolding setsum_distrib_right[symmetric]
  27.295 -    using con setsum_le
  27.296 +    unfolding sum_distrib_right[symmetric]
  27.297 +    using con sum_le
  27.298      apply (auto simp: mult.commute intro: mult_left_mono [OF _ e])
  27.299      done
  27.300    finally show ?thesis .
  27.301 @@ -1485,10 +1485,10 @@
  27.302  lemma rsum_diff_bound:
  27.303    assumes "p tagged_division_of (cbox a b)"
  27.304      and "\<forall>x\<in>cbox a b. norm (f x - g x) \<le> e"
  27.305 -  shows "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - setsum (\<lambda>(x,k). content k *\<^sub>R g x) p) \<le>
  27.306 +  shows "norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p - sum (\<lambda>(x,k). content k *\<^sub>R g x) p) \<le>
  27.307           e * content (cbox a b)"
  27.308    apply (rule order_trans[OF _ rsum_bound[OF assms]])
  27.309 -  apply (simp add: split_def scaleR_diff_right setsum_subtractf eq_refl)
  27.310 +  apply (simp add: split_def scaleR_diff_right sum_subtractf eq_refl)
  27.311    done
  27.312  
  27.313  lemma has_integral_bound:
  27.314 @@ -1534,9 +1534,9 @@
  27.315    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  27.316    assumes "p tagged_division_of (cbox a b)"
  27.317        and "\<forall>x\<in>cbox a b. (f x)\<bullet>i \<le> (g x)\<bullet>i"
  27.318 -    shows "(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p)\<bullet>i \<le> (setsum (\<lambda>(x,k). content k *\<^sub>R g x) p)\<bullet>i"
  27.319 -unfolding inner_setsum_left
  27.320 -proof (rule setsum_mono, clarify)
  27.321 +    shows "(sum (\<lambda>(x,k). content k *\<^sub>R f x) p)\<bullet>i \<le> (sum (\<lambda>(x,k). content k *\<^sub>R g x) p)\<bullet>i"
  27.322 +unfolding inner_sum_left
  27.323 +proof (rule sum_mono, clarify)
  27.324    fix a b
  27.325    assume ab: "(a, b) \<in> p"
  27.326    note tagged = tagged_division_ofD(2-4)[OF assms(1) ab]
  27.327 @@ -1877,7 +1877,7 @@
  27.328    also have "(\<Prod>j\<in>Basis. (b' 0 - a' 0) \<bullet> j) = 0"
  27.329      using k *
  27.330      by (intro setprod_zero bexI[OF _ k])
  27.331 -       (auto simp: b'_def a'_def inner_diff inner_setsum_left inner_not_same_Basis intro!: setsum.cong)
  27.332 +       (auto simp: b'_def a'_def inner_diff inner_sum_left inner_not_same_Basis intro!: sum.cong)
  27.333    also have "((\<lambda>d. \<Prod>j\<in>Basis. (b' d - a' d) \<bullet> j) \<longlongrightarrow> 0) (at_right 0) =
  27.334      ((\<lambda>d. content (cbox a b \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> d})) \<longlongrightarrow> 0) (at_right 0)"
  27.335    proof (intro tendsto_cong eventually_at_rightI)
  27.336 @@ -1952,7 +1952,7 @@
  27.337      assume p: "p tagged_division_of (cbox a b) \<and> (\<lambda>x. ball x d) fine p"
  27.338      have *: "(\<Sum>(x, ka)\<in>p. content ka *\<^sub>R ?i x) =
  27.339        (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x\<bullet>k - c\<bar> \<le> d}) *\<^sub>R ?i x)"
  27.340 -      apply (rule setsum.cong)
  27.341 +      apply (rule sum.cong)
  27.342        apply (rule refl)
  27.343        unfolding split_paired_all real_scaleR_def mult_cancel_right split_conv
  27.344        apply cases
  27.345 @@ -1989,7 +1989,7 @@
  27.346        unfolding diff_0_right *
  27.347        unfolding real_scaleR_def real_norm_def
  27.348        apply (subst abs_of_nonneg)
  27.349 -      apply (rule setsum_nonneg)
  27.350 +      apply (rule sum_nonneg)
  27.351        apply rule
  27.352        unfolding split_paired_all split_conv
  27.353        apply (rule mult_nonneg_nonneg)
  27.354 @@ -2005,14 +2005,14 @@
  27.355      proof -
  27.356        have "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) * ?i x) \<le>
  27.357          (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}))"
  27.358 -        apply (rule setsum_mono)
  27.359 +        apply (rule sum_mono)
  27.360          unfolding split_paired_all split_conv
  27.361          apply (rule mult_right_le_one_le)
  27.362          apply (drule p'(4))
  27.363          apply (auto simp add:interval_doublesplit[OF k])
  27.364          done
  27.365        also have "\<dots> < e"
  27.366 -      proof (subst setsum.over_tagged_division_lemma[OF p[THEN conjunct1]], goal_cases)
  27.367 +      proof (subst sum.over_tagged_division_lemma[OF p[THEN conjunct1]], goal_cases)
  27.368          case prems: (1 u v)
  27.369          then have *: "content (cbox u v) = 0"
  27.370            unfolding content_eq_0_interior by simp
  27.371 @@ -2027,8 +2027,8 @@
  27.372            by (blast intro: antisym)
  27.373        next
  27.374          have "(\<Sum>l\<in>snd ` p. content (l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})) =
  27.375 -          setsum content ((\<lambda>l. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})`{l\<in>snd ` p. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}})"
  27.376 -        proof (subst (2) setsum.reindex_nontrivial)
  27.377 +          sum content ((\<lambda>l. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})`{l\<in>snd ` p. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}})"
  27.378 +        proof (subst (2) sum.reindex_nontrivial)
  27.379            fix x y assume "x \<in> {l \<in> snd ` p. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}}" "y \<in> {l \<in> snd ` p. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}}"
  27.380              "x \<noteq> y" and eq: "x \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} = y \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}"
  27.381            then obtain x' y' where "(x', x) \<in> p" "x \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}" "(y', y) \<in> p" "y \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}"
  27.382 @@ -2041,7 +2041,7 @@
  27.383              by (auto simp: eq)
  27.384            then show "content (x \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = 0"
  27.385              using p'(4)[OF \<open>(x', x) \<in> p\<close>] by (auto simp: interval_doublesplit[OF k] content_eq_0_interior simp del: interior_Int)
  27.386 -        qed (insert p'(1), auto intro!: setsum.mono_neutral_right)
  27.387 +        qed (insert p'(1), auto intro!: sum.mono_neutral_right)
  27.388          also have "\<dots> \<le> norm (\<Sum>l\<in>(\<lambda>l. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})`{l\<in>snd ` p. l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}}. content l *\<^sub>R 1::real)"
  27.389            by simp
  27.390          also have "\<dots> \<le> 1 * content (cbox a b \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})"
  27.391 @@ -2144,15 +2144,15 @@
  27.392          by (auto intro: tagged_division_finer[OF as(1) d(1)])
  27.393        from choice[OF this] guess q .. note q=conjunctD3[OF this[rule_format]]
  27.394        have *: "\<And>i. (\<Sum>(x, k)\<in>q i. content k *\<^sub>R indicator s x) \<ge> (0::real)"
  27.395 -        apply (rule setsum_nonneg)
  27.396 +        apply (rule sum_nonneg)
  27.397          apply safe
  27.398          unfolding real_scaleR_def
  27.399          apply (drule tagged_division_ofD(4)[OF q(1)])
  27.400          apply (auto intro: mult_nonneg_nonneg)
  27.401          done
  27.402        have **: "finite s \<Longrightarrow> finite t \<Longrightarrow> (\<forall>(x,y) \<in> t. (0::real) \<le> g(x,y)) \<Longrightarrow>
  27.403 -        (\<forall>y\<in>s. \<exists>x. (x,y) \<in> t \<and> f(y) \<le> g(x,y)) \<Longrightarrow> setsum f s \<le> setsum g t" for f g s t
  27.404 -        apply (rule setsum_le_included[of s t g snd f])
  27.405 +        (\<forall>y\<in>s. \<exists>x. (x,y) \<in> t \<and> f(y) \<le> g(x,y)) \<Longrightarrow> sum f s \<le> sum g t" for f g s t
  27.406 +        apply (rule sum_le_included[of s t g snd f])
  27.407          prefer 4
  27.408          apply safe
  27.409          apply (erule_tac x=x in ballE)
  27.410 @@ -2160,11 +2160,11 @@
  27.411          apply (rule_tac x="(xa,x)" in bexI)
  27.412          apply auto
  27.413          done
  27.414 -      have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) \<le> setsum (\<lambda>i. (real i + 1) *
  27.415 -        norm (setsum (\<lambda>(x,k). content k *\<^sub>R indicator s x :: real) (q i))) {..N+1}"
  27.416 -        unfolding real_norm_def setsum_distrib_left abs_of_nonneg[OF *] diff_0_right
  27.417 +      have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) \<le> sum (\<lambda>i. (real i + 1) *
  27.418 +        norm (sum (\<lambda>(x,k). content k *\<^sub>R indicator s x :: real) (q i))) {..N+1}"
  27.419 +        unfolding real_norm_def sum_distrib_left abs_of_nonneg[OF *] diff_0_right
  27.420          apply (rule order_trans)
  27.421 -        apply (rule norm_setsum)
  27.422 +        apply (rule norm_sum)
  27.423          apply (subst sum_sum_product)
  27.424          prefer 3
  27.425        proof (rule **, safe)
  27.426 @@ -2229,8 +2229,8 @@
  27.427            apply auto
  27.428            done
  27.429        qed (insert as, auto)
  27.430 -      also have "\<dots> \<le> setsum (\<lambda>i. e / 2 / 2 ^ i) {..N+1}"
  27.431 -      proof (rule setsum_mono, goal_cases)
  27.432 +      also have "\<dots> \<le> sum (\<lambda>i. e / 2 / 2 ^ i) {..N+1}"
  27.433 +      proof (rule sum_mono, goal_cases)
  27.434          case (1 i)
  27.435          then show ?case
  27.436            apply (subst mult.commute, subst pos_le_divide_eq[symmetric])
  27.437 @@ -2240,7 +2240,7 @@
  27.438            done
  27.439        qed
  27.440        also have "\<dots> < e * inverse 2 * 2"
  27.441 -        unfolding divide_inverse setsum_distrib_left[symmetric]
  27.442 +        unfolding divide_inverse sum_distrib_left[symmetric]
  27.443          apply (rule mult_strict_left_mono)
  27.444          unfolding power_inverse [symmetric] lessThan_Suc_atMost[symmetric]
  27.445          apply (subst geometric_sum)
  27.446 @@ -2640,14 +2640,14 @@
  27.447  lemma has_integral_factor_content:
  27.448    "(f has_integral i) (cbox a b) \<longleftrightarrow>
  27.449      (\<forall>e>0. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  27.450 -      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content (cbox a b)))"
  27.451 +      norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content (cbox a b)))"
  27.452  proof (cases "content (cbox a b) = 0")
  27.453    case True
  27.454    show ?thesis
  27.455      unfolding has_integral_null_eq[OF True]
  27.456      apply safe
  27.457      apply (rule, rule, rule gauge_trivial, safe)
  27.458 -    unfolding setsum_content_null[OF True] True
  27.459 +    unfolding sum_content_null[OF True] True
  27.460      defer
  27.461      apply (erule_tac x=1 in allE)
  27.462      apply safe
  27.463 @@ -2655,7 +2655,7 @@
  27.464      apply (rule fine_division_exists[of _ a b])
  27.465      apply assumption
  27.466      apply (erule_tac x=p in allE)
  27.467 -    unfolding setsum_content_null[OF True]
  27.468 +    unfolding sum_content_null[OF True]
  27.469      apply auto
  27.470      done
  27.471  next
  27.472 @@ -2696,7 +2696,7 @@
  27.473  lemma has_integral_factor_content_real:
  27.474    "(f has_integral i) {a .. b::real} \<longleftrightarrow>
  27.475      (\<forall>e>0. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a .. b}  \<and> d fine p \<longrightarrow>
  27.476 -      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content {a .. b} ))"
  27.477 +      norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content {a .. b} ))"
  27.478    unfolding box_real[symmetric]
  27.479    by (rule has_integral_factor_content)
  27.480  
  27.481 @@ -2738,10 +2738,10 @@
  27.482      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content (cbox a b)"
  27.483        unfolding content_real[OF assms(1), simplified box_real[symmetric]] additive_tagged_division_1[OF assms(1) as(1)[simplified box_real],of f,symmetric]
  27.484        unfolding additive_tagged_division_1[OF assms(1) as(1)[simplified box_real],of "\<lambda>x. x",symmetric]
  27.485 -      unfolding setsum_distrib_left
  27.486 +      unfolding sum_distrib_left
  27.487        defer
  27.488 -      unfolding setsum_subtractf[symmetric]
  27.489 -    proof (rule setsum_norm_le,safe)
  27.490 +      unfolding sum_subtractf[symmetric]
  27.491 +    proof (rule sum_norm_le,safe)
  27.492        fix x k
  27.493        assume "(x, k) \<in> p"
  27.494        note xk = tagged_division_ofD(2-4)[OF as(1) this]
  27.495 @@ -2809,7 +2809,7 @@
  27.496  
  27.497  subsection \<open>Taylor series expansion\<close>
  27.498  
  27.499 -lemma (in bounded_bilinear) setsum_prod_derivatives_has_vector_derivative:
  27.500 +lemma (in bounded_bilinear) sum_prod_derivatives_has_vector_derivative:
  27.501    assumes "p>0"
  27.502    and f0: "Df 0 = f"
  27.503    and Df: "\<And>m t. m < p \<Longrightarrow> a \<le> t \<Longrightarrow> t \<le> b \<Longrightarrow>
  27.504 @@ -2835,7 +2835,7 @@
  27.505      prod (Df (Suc i) t) (Dg (p - Suc i) t))) =
  27.506      (\<Sum>i\<le>(Suc p'). ?f i - ?f (Suc i))"
  27.507      by (auto simp: algebra_simps p'(2) numeral_2_eq_2 * lessThan_Suc_atMost)
  27.508 -  also note setsum_telescope
  27.509 +  also note sum_telescope
  27.510    finally
  27.511    have "(\<Sum>i<p. (-1) ^ i *\<^sub>R (prod (Df i t) (Dg (Suc (p - Suc i)) t) +
  27.512      prod (Df (Suc i) t) (Dg (p - Suc i) t)))
  27.513 @@ -2884,7 +2884,7 @@
  27.514      unfolding Dg_def
  27.515      by (auto intro!: derivative_eq_intros simp: has_vector_derivative_def fact_eq divide_simps)
  27.516    let ?sum = "\<lambda>t. \<Sum>i<p. (- 1) ^ i *\<^sub>R Dg i t *\<^sub>R Df (p - Suc i) t"
  27.517 -  from setsum_prod_derivatives_has_vector_derivative[of _ Dg _ _ _ Df,
  27.518 +  from sum_prod_derivatives_has_vector_derivative[of _ Dg _ _ _ Df,
  27.519        OF \<open>p > 0\<close> g0 Dg f0 Df]
  27.520    have deriv: "\<And>t. a \<le> t \<Longrightarrow> t \<le> b \<Longrightarrow>
  27.521      (?sum has_vector_derivative
  27.522 @@ -2903,7 +2903,7 @@
  27.523    then have "?sum b = f b"
  27.524      using Suc_pred'[OF \<open>p > 0\<close>]
  27.525      by (simp add: diff_eq_eq Dg_def power_0_left le_Suc_eq if_distrib
  27.526 -        cond_application_beta setsum.If_cases f0)
  27.527 +        cond_application_beta sum.If_cases f0)
  27.528    also
  27.529    have "{..<p} = (\<lambda>x. p - x - 1) ` {..<p}"
  27.530    proof safe
  27.531 @@ -2914,7 +2914,7 @@
  27.532    qed simp
  27.533    from _ this
  27.534    have "?sum a = (\<Sum>i<p. ((b - a) ^ i / fact i) *\<^sub>R Df i a)"
  27.535 -    by (rule setsum.reindex_cong) (auto simp add: inj_on_def Dg_def one)
  27.536 +    by (rule sum.reindex_cong) (auto simp add: inj_on_def Dg_def one)
  27.537    finally show c: ?case .
  27.538    case 2 show ?case using c integral_unique by force
  27.539    case 3 show ?case using c by force
  27.540 @@ -3003,10 +3003,10 @@
  27.541          unfolding euclidean_eq_iff[where 'a='a] using i by auto
  27.542        have *: "Basis = insert i (Basis - {i})"
  27.543          using i by auto
  27.544 -      have "norm (y - x) < e + setsum (\<lambda>i. 0) Basis"
  27.545 +      have "norm (y - x) < e + sum (\<lambda>i. 0) Basis"
  27.546          apply (rule le_less_trans[OF norm_le_l1])
  27.547          apply (subst *)
  27.548 -        apply (subst setsum.insert)
  27.549 +        apply (subst sum.insert)
  27.550          prefer 3
  27.551          apply (rule add_less_le_mono)
  27.552        proof -
  27.553 @@ -3436,9 +3436,9 @@
  27.554            using inj(1) unfolding inj_on_def by fastforce
  27.555          have "(\<Sum>(x, k)\<in>(\<lambda>(x, k). (g x, g ` k)) ` p. content k *\<^sub>R f x) - i = r *\<^sub>R (\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - i" (is "?l = _")
  27.556            using assms(7)
  27.557 -          apply (simp only: algebra_simps add_left_cancel scaleR_right.setsum)
  27.558 -          apply (subst setsum.reindex_bij_betw[symmetric, where h="\<lambda>(x, k). (g x, g ` k)" and S=p])
  27.559 -          apply (auto intro!: * setsum.cong simp: bij_betw_def dest!: p(4))
  27.560 +          apply (simp only: algebra_simps add_left_cancel scaleR_right.sum)
  27.561 +          apply (subst sum.reindex_bij_betw[symmetric, where h="\<lambda>(x, k). (g x, g ` k)" and S=p])
  27.562 +          apply (auto intro!: * sum.cong simp: bij_betw_def dest!: p(4))
  27.563            done
  27.564        also have "\<dots> = r *\<^sub>R ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - (1 / r) *\<^sub>R i)" (is "_ = ?r")
  27.565          unfolding scaleR_diff_right scaleR_scaleR
  27.566 @@ -3865,18 +3865,18 @@
  27.567      have **: "\<And>n1 s1 n2 s2::real. n2 \<le> s2 / 2 \<Longrightarrow> n1 - s1 \<le> s2 / 2 \<Longrightarrow> n1 + n2 \<le> s1 + s2"
  27.568        by arith
  27.569      show ?case
  27.570 -      unfolding content_real[OF assms(1)] and *[of "\<lambda>x. x"] *[of f] setsum_subtractf[symmetric] split_minus
  27.571 -      unfolding setsum_distrib_left
  27.572 +      unfolding content_real[OF assms(1)] and *[of "\<lambda>x. x"] *[of f] sum_subtractf[symmetric] split_minus
  27.573 +      unfolding sum_distrib_left
  27.574        apply (subst(2) pA)
  27.575        apply (subst pA)
  27.576 -      unfolding setsum.union_disjoint[OF pA(2-)]
  27.577 +      unfolding sum.union_disjoint[OF pA(2-)]
  27.578      proof (rule norm_triangle_le, rule **, goal_cases)
  27.579        case 1
  27.580        show ?case
  27.581          apply (rule order_trans)
  27.582 -        apply (rule setsum_norm_le)
  27.583 +        apply (rule sum_norm_le)
  27.584          defer
  27.585 -        apply (subst setsum_divide_distrib)
  27.586 +        apply (subst sum_divide_distrib)
  27.587          apply (rule order_refl)
  27.588          apply safe
  27.589          apply (unfold not_le o_def split_conv fst_conv)
  27.590 @@ -3930,12 +3930,12 @@
  27.591        case 2
  27.592        show ?case
  27.593          apply (rule *)
  27.594 -        apply (rule setsum_nonneg)
  27.595 +        apply (rule sum_nonneg)
  27.596          apply rule
  27.597          apply (unfold split_paired_all split_conv)
  27.598          defer
  27.599 -        unfolding setsum.union_disjoint[OF pA(2-),symmetric] pA(1)[symmetric]
  27.600 -        unfolding setsum_distrib_left[symmetric]
  27.601 +        unfolding sum.union_disjoint[OF pA(2-),symmetric] pA(1)[symmetric]
  27.602 +        unfolding sum_distrib_left[symmetric]
  27.603          apply (subst additive_tagged_division_1[OF _ as(1)])
  27.604          apply (rule assms)
  27.605        proof -
  27.606 @@ -3948,12 +3948,12 @@
  27.607          then show "0 \<le> e * ((Sup k) - (Inf k))"
  27.608            unfolding uv using e by (auto simp add: field_simps)
  27.609        next
  27.610 -        have *: "\<And>s f t e. setsum f s = setsum f t \<Longrightarrow> norm (setsum f t) \<le> e \<Longrightarrow> norm (setsum f s) \<le> e"
  27.611 +        have *: "\<And>s f t e. sum f s = sum f t \<Longrightarrow> norm (sum f t) \<le> e \<Longrightarrow> norm (sum f s) \<le> e"
  27.612            by auto
  27.613          show "norm (\<Sum>(x, k)\<in>p \<inter> ?A. content k *\<^sub>R f' x -
  27.614            (f ((Sup k)) - f ((Inf k)))) \<le> e * (b - a) / 2"
  27.615            apply (rule *[where t1="p \<inter> {t. fst t \<in> {a, b} \<and> content(snd t) \<noteq> 0}"])
  27.616 -          apply (rule setsum.mono_neutral_right[OF pA(2)])
  27.617 +          apply (rule sum.mono_neutral_right[OF pA(2)])
  27.618            defer
  27.619            apply rule
  27.620            unfolding split_paired_all split_conv o_def
  27.621 @@ -3975,7 +3975,7 @@
  27.622            have *: "p \<inter> {t. fst t \<in> {a, b} \<and> content(snd t) \<noteq> 0} =
  27.623              {t. t\<in>p \<and> fst t = a \<and> content(snd t) \<noteq> 0} \<union> {t. t\<in>p \<and> fst t = b \<and> content(snd t) \<noteq> 0}"
  27.624              by blast
  27.625 -          have **: "norm (setsum f s) \<le> e"
  27.626 +          have **: "norm (sum f s) \<le> e"
  27.627              if "\<forall>x y. x \<in> s \<and> y \<in> s \<longrightarrow> x = y"
  27.628              and "\<forall>x. x \<in> s \<longrightarrow> norm (f x) \<le> e"
  27.629              and "e > 0"
  27.630 @@ -3995,7 +3995,7 @@
  27.631            case 2
  27.632            show ?case
  27.633              apply (subst *)
  27.634 -            apply (subst setsum.union_disjoint)
  27.635 +            apply (subst sum.union_disjoint)
  27.636              prefer 4
  27.637              apply (rule order_trans[of _ "e * (b - a)/4 + e * (b - a)/4"])
  27.638              apply (rule norm_triangle_le,rule add_mono)
  27.639 @@ -4425,7 +4425,7 @@
  27.640        then show ?thesis
  27.641          unfolding ** box_real
  27.642          apply -
  27.643 -        apply (subst setsum.insert)
  27.644 +        apply (subst sum.insert)
  27.645          apply (rule p')
  27.646          unfolding split_conv
  27.647          defer
  27.648 @@ -5003,7 +5003,7 @@
  27.649        show "c \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> d \<bullet> i" if "norm x \<le> B" and "i \<in> Basis"
  27.650          using that and Basis_le_norm[OF \<open>i\<in>Basis\<close>, of x]
  27.651          unfolding c_def d_def
  27.652 -        by (auto simp add: field_simps setsum_negf)
  27.653 +        by (auto simp add: field_simps sum_negf)
  27.654      qed
  27.655      have "ball 0 C \<subseteq> cbox c d"
  27.656        apply (rule subsetI)
  27.657 @@ -5014,7 +5014,7 @@
  27.658        show "c \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> d \<bullet> i"
  27.659          using Basis_le_norm[OF i, of x] and x i
  27.660          unfolding c_def d_def
  27.661 -        by (auto simp: setsum_negf)
  27.662 +        by (auto simp: sum_negf)
  27.663      qed
  27.664      from C(2)[OF this] have "\<exists>y. (f has_integral y) (cbox a b)"
  27.665        unfolding has_integral_restrict_closed_subintervals_eq[OF c_d,symmetric]
  27.666 @@ -5040,7 +5040,7 @@
  27.667          then show "c \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> d \<bullet> i"
  27.668            using Basis_le_norm[of i x]
  27.669            unfolding c_def d_def
  27.670 -          by (auto simp add: field_simps setsum_negf)
  27.671 +          by (auto simp add: field_simps sum_negf)
  27.672        qed
  27.673        have "ball 0 C \<subseteq> cbox c d"
  27.674          apply (rule subsetI)
  27.675 @@ -5051,7 +5051,7 @@
  27.676          then show "c \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> d \<bullet> i"
  27.677            using Basis_le_norm[of i x]
  27.678            unfolding c_def d_def
  27.679 -          by (auto simp: setsum_negf)
  27.680 +          by (auto simp: sum_negf)
  27.681        qed
  27.682        note C(2)[OF this] then guess z .. note z = conjunctD2[OF this, unfolded s]
  27.683        note this[unfolded has_integral_restrict_closed_subintervals_eq[OF c_d]]
  27.684 @@ -5425,7 +5425,7 @@
  27.685          then show ?case
  27.686            using Basis_le_norm[of i x] \<open>i\<in>Basis\<close>
  27.687            using n N
  27.688 -          by (auto simp add: field_simps setsum_negf)
  27.689 +          by (auto simp add: field_simps sum_negf)
  27.690        qed
  27.691      }
  27.692      then show ?case
  27.693 @@ -5482,7 +5482,7 @@
  27.694            then show ?case
  27.695              using Basis_le_norm[of i x] \<open>i \<in> Basis\<close>
  27.696              using n
  27.697 -            by (auto simp add: field_simps setsum_negf)
  27.698 +            by (auto simp add: field_simps sum_negf)
  27.699          qed
  27.700        qed
  27.701      qed
  27.702 @@ -5541,9 +5541,9 @@
  27.703        and "0 \<le> (\<Sum>(x, k)\<in>p2. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)"
  27.704        and "(\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R g x) \<ge> 0"
  27.705        and "0 \<le> (\<Sum>(x, k)\<in>p1. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x)"
  27.706 -      unfolding setsum_subtractf[symmetric]
  27.707 +      unfolding sum_subtractf[symmetric]
  27.708        apply -
  27.709 -      apply (rule_tac[!] setsum_nonneg)
  27.710 +      apply (rule_tac[!] sum_nonneg)
  27.711        apply safe
  27.712        unfolding real_scaleR_def right_diff_distrib[symmetric]
  27.713        apply (rule_tac[!] mult_nonneg_nonneg)
  27.714 @@ -5774,7 +5774,7 @@
  27.715    assumes "finite t"
  27.716      and "\<forall>s\<in>t. (f has_integral (i s)) s"
  27.717      and "\<forall>s\<in>t. \<forall>s'\<in>t. s \<noteq> s' \<longrightarrow> negligible (s \<inter> s')"
  27.718 -  shows "(f has_integral (setsum i t)) (\<Union>t)"
  27.719 +  shows "(f has_integral (sum i t)) (\<Union>t)"
  27.720  proof -
  27.721    note * = has_integral_restrict_univ[symmetric, of f]
  27.722    have **: "negligible (\<Union>((\<lambda>(a,b). a \<inter> b) ` {(a,b). a \<in> t \<and> b \<in> {y. y \<in> t \<and> a \<noteq> y}}))"
  27.723 @@ -5787,7 +5787,7 @@
  27.724      apply auto
  27.725      done
  27.726    note assms(2)[unfolded *]
  27.727 -  note has_integral_setsum[OF assms(1) this]
  27.728 +  note has_integral_sum[OF assms(1) this]
  27.729    then show ?thesis
  27.730      unfolding *
  27.731      apply -
  27.732 @@ -5807,12 +5807,12 @@
  27.733          unfolding if_P[OF True]
  27.734          apply (rule trans)
  27.735          defer
  27.736 -        apply (rule setsum.cong)
  27.737 +        apply (rule sum.cong)
  27.738          apply (rule refl)
  27.739          apply (subst *)
  27.740          apply assumption
  27.741          apply (rule refl)
  27.742 -        unfolding setsum.delta[OF assms(1)]
  27.743 +        unfolding sum.delta[OF assms(1)]
  27.744          using s
  27.745          apply auto
  27.746          done
  27.747 @@ -5827,7 +5827,7 @@
  27.748    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  27.749    assumes "d division_of s"
  27.750      and "\<forall>k\<in>d. (f has_integral (i k)) k"
  27.751 -  shows "(f has_integral (setsum i d)) s"
  27.752 +  shows "(f has_integral (sum i d)) s"
  27.753  proof -
  27.754    note d = division_ofD[OF assms(1)]
  27.755    show ?thesis
  27.756 @@ -5854,7 +5854,7 @@
  27.757    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  27.758    assumes "d division_of s"
  27.759      and "\<forall>k\<in>d. f integrable_on k"
  27.760 -  shows "integral s f = setsum (\<lambda>i. integral i f) d"
  27.761 +  shows "integral s f = sum (\<lambda>i. integral i f) d"
  27.762    apply (rule integral_unique)
  27.763    apply (rule has_integral_combine_division[OF assms(1)])
  27.764    using assms(2)
  27.765 @@ -5867,7 +5867,7 @@
  27.766    assumes "f integrable_on s"
  27.767      and "d division_of k"
  27.768      and "k \<subseteq> s"
  27.769 -  shows "(f has_integral (setsum (\<lambda>i. integral i f) d)) k"
  27.770 +  shows "(f has_integral (sum (\<lambda>i. integral i f) d)) k"
  27.771    apply (rule has_integral_combine_division[OF assms(2)])
  27.772    apply safe
  27.773    unfolding has_integral_integral[symmetric]
  27.774 @@ -5887,7 +5887,7 @@
  27.775    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  27.776    assumes "f integrable_on s"
  27.777      and "d division_of s"
  27.778 -  shows "integral s f = setsum (\<lambda>i. integral i f) d"
  27.779 +  shows "integral s f = sum (\<lambda>i. integral i f) d"
  27.780    apply (rule integral_unique)
  27.781    apply (rule has_integral_combine_division_topdown)
  27.782    using assms
  27.783 @@ -5941,17 +5941,17 @@
  27.784      apply auto
  27.785      done
  27.786    also have "(\<Sum>k\<in>snd`p. integral k f) = (\<Sum>(x, k)\<in>p. integral k f)"
  27.787 -    by (intro setsum.over_tagged_division_lemma[OF assms(1), symmetric] integral_null)
  27.788 +    by (intro sum.over_tagged_division_lemma[OF assms(1), symmetric] integral_null)
  27.789         (simp add: content_eq_0_interior)
  27.790    finally show ?thesis
  27.791 -    using assms by (auto simp add: has_integral_iff intro!: setsum.cong)
  27.792 +    using assms by (auto simp add: has_integral_iff intro!: sum.cong)
  27.793  qed
  27.794  
  27.795  lemma integral_combine_tagged_division_bottomup:
  27.796    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  27.797    assumes "p tagged_division_of (cbox a b)"
  27.798      and "\<forall>(x,k)\<in>p. f integrable_on k"
  27.799 -  shows "integral (cbox a b) f = setsum (\<lambda>(x,k). integral k f) p"
  27.800 +  shows "integral (cbox a b) f = sum (\<lambda>(x,k). integral k f) p"
  27.801    apply (rule integral_unique)
  27.802    apply (rule has_integral_combine_tagged_division[OF assms(1)])
  27.803    using assms(2)
  27.804 @@ -5962,7 +5962,7 @@
  27.805    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  27.806    assumes "f integrable_on cbox a b"
  27.807      and "p tagged_division_of (cbox a b)"
  27.808 -  shows "(f has_integral (setsum (\<lambda>(x,k). integral k f) p)) (cbox a b)"
  27.809 +  shows "(f has_integral (sum (\<lambda>(x,k). integral k f) p)) (cbox a b)"
  27.810    apply (rule has_integral_combine_tagged_division[OF assms(2)])
  27.811    apply safe
  27.812  proof goal_cases
  27.813 @@ -5976,7 +5976,7 @@
  27.814    fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  27.815    assumes "f integrable_on cbox a b"
  27.816      and "p tagged_division_of (cbox a b)"
  27.817 -  shows "integral (cbox a b) f = setsum (\<lambda>(x,k). integral k f) p"
  27.818 +  shows "integral (cbox a b) f = sum (\<lambda>(x,k). integral k f) p"
  27.819    apply (rule integral_unique)
  27.820    apply (rule has_integral_combine_tagged_division_topdown)
  27.821    using assms
  27.822 @@ -5992,9 +5992,9 @@
  27.823      and "e > 0"
  27.824      and "gauge d"
  27.825      and "(\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  27.826 -      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral(cbox a b) f) < e)"
  27.827 +      norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral(cbox a b) f) < e)"
  27.828      and p: "p tagged_partial_division_of (cbox a b)" "d fine p"
  27.829 -  shows "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x - integral k f) p) \<le> e"
  27.830 +  shows "norm (sum (\<lambda>(x,k). content k *\<^sub>R f x - integral k f) p) \<le> e"
  27.831    (is "?x \<le> e")
  27.832  proof -
  27.833    { presume "\<And>k. 0<k \<Longrightarrow> ?x \<le> e + k" then show ?thesis by (blast intro: field_le_epsilon) }
  27.834 @@ -6012,7 +6012,7 @@
  27.835      using q' unfolding r_def by auto
  27.836  
  27.837    have "\<forall>i\<in>r. \<exists>p. p tagged_division_of i \<and> d fine p \<and>
  27.838 -    norm (setsum (\<lambda>(x,j). content j *\<^sub>R f x) p - integral i f) < k / (real (card r) + 1)"
  27.839 +    norm (sum (\<lambda>(x,j). content j *\<^sub>R f x) p - integral i f) < k / (real (card r) + 1)"
  27.840      apply safe
  27.841    proof goal_cases
  27.842      case (1 i)
  27.843 @@ -6100,7 +6100,7 @@
  27.844  
  27.845    then have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>\<Union>(qq ` r). content k *\<^sub>R f x) -
  27.846      integral (cbox a b) f) < e"
  27.847 -    apply (subst setsum.union_inter_neutral[symmetric])
  27.848 +    apply (subst sum.union_inter_neutral[symmetric])
  27.849      apply (rule p')
  27.850      prefer 3
  27.851      apply assumption
  27.852 @@ -6124,9 +6124,9 @@
  27.853        unfolding uv content_eq_0_interior[symmetric] by auto
  27.854    qed auto
  27.855  
  27.856 -  then have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + setsum (setsum (\<lambda>(x, k). content k *\<^sub>R f x))
  27.857 +  then have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + sum (sum (\<lambda>(x, k). content k *\<^sub>R f x))
  27.858      (qq ` r) - integral (cbox a b) f) < e"
  27.859 -    apply (subst (asm) setsum.Union_comp)
  27.860 +    apply (subst (asm) sum.Union_comp)
  27.861      prefer 2
  27.862      unfolding split_paired_all split_conv image_iff
  27.863      apply (erule bexE)+
  27.864 @@ -6150,11 +6150,11 @@
  27.865        by auto
  27.866    qed (insert qq, auto)
  27.867  
  27.868 -  then have **: "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + setsum (setsum (\<lambda>(x, k). content k *\<^sub>R f x) \<circ> qq) r -
  27.869 +  then have **: "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + sum (sum (\<lambda>(x, k). content k *\<^sub>R f x) \<circ> qq) r -
  27.870      integral (cbox a b) f) < e"
  27.871 -    apply (subst (asm) setsum.reindex_nontrivial)
  27.872 +    apply (subst (asm) sum.reindex_nontrivial)
  27.873      apply fact
  27.874 -    apply (rule setsum.neutral)
  27.875 +    apply (rule sum.neutral)
  27.876      apply rule
  27.877      unfolding split_paired_all split_conv
  27.878      defer
  27.879 @@ -6180,28 +6180,28 @@
  27.880    qed
  27.881  
  27.882    have "?x =  norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p. integral k f))"
  27.883 -    unfolding split_def setsum_subtractf ..
  27.884 +    unfolding split_def sum_subtractf ..
  27.885    also have "\<dots> \<le> e + k"
  27.886 -    apply (rule *[OF **, where ir1="setsum (\<lambda>k. integral k f) r"])
  27.887 +    apply (rule *[OF **, where ir1="sum (\<lambda>k. integral k f) r"])
  27.888    proof goal_cases
  27.889      case 1
  27.890      have *: "k * real (card r) / (1 + real (card r)) < k"
  27.891        using k by (auto simp add: field_simps)
  27.892      show ?case
  27.893 -      apply (rule le_less_trans[of _ "setsum (\<lambda>x. k / (real (card r) + 1)) r"])
  27.894 -      unfolding setsum_subtractf[symmetric]
  27.895 -      apply (rule setsum_norm_le)
  27.896 +      apply (rule le_less_trans[of _ "sum (\<lambda>x. k / (real (card r) + 1)) r"])
  27.897 +      unfolding sum_subtractf[symmetric]
  27.898 +      apply (rule sum_norm_le)
  27.899        apply rule
  27.900        apply (drule qq)
  27.901        defer
  27.902 -      unfolding divide_inverse setsum_distrib_right[symmetric]
  27.903 +      unfolding divide_inverse sum_distrib_right[symmetric]
  27.904        unfolding divide_inverse[symmetric]
  27.905        using * apply (auto simp add: field_simps)
  27.906        done
  27.907    next
  27.908      case 2
  27.909      have *: "(\<Sum>(x, k)\<in>p. integral k f) = (\<Sum>k\<in>snd ` p. integral k f)"
  27.910 -      apply (subst setsum.reindex_nontrivial)
  27.911 +      apply (subst sum.reindex_nontrivial)
  27.912        apply fact
  27.913        unfolding split_paired_all snd_conv split_def o_def
  27.914      proof -
  27.915 @@ -6221,7 +6221,7 @@
  27.916      from q(1) have **: "snd ` p \<union> q = q" by auto
  27.917      show ?case
  27.918        unfolding integral_combine_division_topdown[OF assms(1) q(2)] * r_def
  27.919 -      using ** q'(1) p'(1) setsum.union_disjoint [of "snd ` p" "q - snd ` p" "\<lambda>k. integral k f", symmetric]
  27.920 +      using ** q'(1) p'(1) sum.union_disjoint [of "snd ` p" "q - snd ` p" "\<lambda>k. integral k f", symmetric]
  27.921          by simp
  27.922    qed
  27.923    finally show "?x \<le> e + k" .
  27.924 @@ -6233,12 +6233,12 @@
  27.925      and "e > 0"
  27.926      and "gauge d"
  27.927      and "\<forall>p. p tagged_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  27.928 -      norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral (cbox a b) f) < e"
  27.929 +      norm (sum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral (cbox a b) f) < e"
  27.930      and "p tagged_partial_division_of (cbox a b)"
  27.931      and "d fine p"
  27.932 -  shows "setsum (\<lambda>(x,k). norm (content k *\<^sub>R f x - integral k f)) p \<le> 2 * real (DIM('n)) * e"
  27.933 +  shows "sum (\<lambda>(x,k). norm (content k *\<^sub>R f x - integral k f)) p \<le> 2 * real (DIM('n)) * e"
  27.934    unfolding split_def
  27.935 -  apply (rule setsum_norm_allsubsets_bound)
  27.936 +  apply (rule sum_norm_allsubsets_bound)
  27.937    defer
  27.938    apply (rule henstock_lemma_part1[unfolded split_def,OF assms(1-3)])
  27.939    apply safe
  27.940 @@ -6260,7 +6260,7 @@
  27.941      and "e > 0"
  27.942    obtains d where "gauge d"
  27.943      and "\<forall>p. p tagged_partial_division_of (cbox a b) \<and> d fine p \<longrightarrow>
  27.944 -      setsum (\<lambda>(x,k). norm(content k *\<^sub>R f x - integral k f)) p < e"
  27.945 +      sum (\<lambda>(x,k). norm(content k *\<^sub>R f x - integral k f)) p < e"
  27.946  proof -
  27.947    have *: "e / (2 * (real DIM('n) + 1)) > 0" using assms(2) by simp
  27.948    from integrable_integral[OF assms(1),unfolded has_integral[of f],rule_format,OF this]
  27.949 @@ -6287,7 +6287,7 @@
  27.950  
  27.951  lemma sum_gp_basic:
  27.952    fixes x :: "'a::ring_1"
  27.953 -  shows "(1 - x) * setsum (\<lambda>i. x^i) {0 .. n} = (1 - x^(Suc n))"
  27.954 +  shows "(1 - x) * sum (\<lambda>i. x^i) {0 .. n} = (1 - x^(Suc n))"
  27.955  proof -
  27.956    define y where "y = 1 - x"
  27.957    have "y * (\<Sum>i=0..n. (1 - y) ^ i) = 1 - (1 - y) ^ Suc n"
  27.958 @@ -6298,7 +6298,7 @@
  27.959  
  27.960  lemma sum_gp_multiplied:
  27.961    assumes mn: "m \<le> n"
  27.962 -  shows "((1::'a::{field}) - x) * setsum (op ^ x) {m..n} = x^m - x^ Suc n"
  27.963 +  shows "((1::'a::{field}) - x) * sum (op ^ x) {m..n} = x^m - x^ Suc n"
  27.964    (is "?lhs = ?rhs")
  27.965  proof -
  27.966    let ?S = "{0..(n - m)}"
  27.967 @@ -6314,8 +6314,8 @@
  27.968      done
  27.969    have th: "op ^ x \<circ> op + m = (\<lambda>i. x^m * x^i)"
  27.970      by (rule ext) (simp add: power_add power_mult)
  27.971 -  from setsum.reindex[OF i, of "op ^ x", unfolded f th setsum_distrib_left[symmetric]]
  27.972 -  have "?lhs = x^m * ((1 - x) * setsum (op ^ x) {0..n - m})"
  27.973 +  from sum.reindex[OF i, of "op ^ x", unfolded f th sum_distrib_left[symmetric]]
  27.974 +  have "?lhs = x^m * ((1 - x) * sum (op ^ x) {0..n - m})"
  27.975      by simp
  27.976    then show ?thesis
  27.977      unfolding sum_gp_basic
  27.978 @@ -6324,7 +6324,7 @@
  27.979  qed
  27.980  
  27.981  lemma sum_gp:
  27.982 -  "setsum (op ^ (x::'a::{field})) {m .. n} =
  27.983 +  "sum (op ^ (x::'a::{field})) {m .. n} =
  27.984      (if n < m then 0
  27.985       else if x = 1 then of_nat ((n + 1) - m)
  27.986       else (x^ m - x^ (Suc n)) / (1 - x))"
  27.987 @@ -6357,7 +6357,7 @@
  27.988  qed
  27.989  
  27.990  lemma sum_gp_offset:
  27.991 -  "setsum (op ^ (x::'a::{field})) {m .. m+n} =
  27.992 +  "sum (op ^ (x::'a::{field})) {m .. m+n} =
  27.993      (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))"
  27.994    unfolding sum_gp[of x m "m + n"] power_Suc
  27.995    by (simp add: field_simps power_add)
  27.996 @@ -6497,12 +6497,12 @@
  27.997          case 1
  27.998          show ?case
  27.999            apply (rule order_trans[of _ "\<Sum>(x, k)\<in>p. content k * (e / (4 * content (cbox a b)))"])
 27.1000 -          unfolding setsum_subtractf[symmetric]
 27.1001 +          unfolding sum_subtractf[symmetric]
 27.1002            apply (rule order_trans)
 27.1003 -          apply (rule norm_setsum)
 27.1004 -          apply (rule setsum_mono)
 27.1005 +          apply (rule norm_sum)
 27.1006 +          apply (rule sum_mono)
 27.1007            unfolding split_paired_all split_conv
 27.1008 -          unfolding split_def setsum_distrib_right[symmetric] scaleR_diff_right[symmetric]
 27.1009 +          unfolding split_def sum_distrib_right[symmetric] scaleR_diff_right[symmetric]
 27.1010            unfolding additive_content_tagged_division[OF p(1), unfolded split_def]
 27.1011          proof -
 27.1012            fix x k
 27.1013 @@ -6524,22 +6524,22 @@
 27.1014          show ?case
 27.1015            apply (rule le_less_trans[of _ "norm (\<Sum>j = 0..s.
 27.1016              \<Sum>(x, k)\<in>{xk\<in>p. m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x)))"])
 27.1017 -          apply (subst setsum_group)
 27.1018 +          apply (subst sum_group)
 27.1019            apply fact
 27.1020            apply (rule finite_atLeastAtMost)
 27.1021            defer
 27.1022            apply (subst split_def)+
 27.1023 -          unfolding setsum_subtractf
 27.1024 +          unfolding sum_subtractf
 27.1025            apply rule
 27.1026          proof -
 27.1027            show "norm (\<Sum>j = 0..s. \<Sum>(x, k)\<in>{xk \<in> p.
 27.1028              m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x))) < e / 2"
 27.1029 -            apply (rule le_less_trans[of _ "setsum (\<lambda>i. e / 2^(i+2)) {0..s}"])
 27.1030 -            apply (rule setsum_norm_le)
 27.1031 +            apply (rule le_less_trans[of _ "sum (\<lambda>i. e / 2^(i+2)) {0..s}"])
 27.1032 +            apply (rule sum_norm_le)
 27.1033            proof
 27.1034              show "(\<Sum>i = 0..s. e / 2 ^ (i + 2)) < e / 2"
 27.1035                unfolding power_add divide_inverse inverse_mult_distrib
 27.1036 -              unfolding setsum_distrib_left[symmetric] setsum_distrib_right[symmetric]
 27.1037 +              unfolding sum_distrib_left[symmetric] sum_distrib_right[symmetric]
 27.1038                unfolding power_inverse [symmetric] sum_gp
 27.1039                apply(rule mult_strict_left_mono[OF _ e])
 27.1040                unfolding power2_eq_square
 27.1041 @@ -6550,10 +6550,10 @@
 27.1042              show "norm (\<Sum>(x, k)\<in>{xk \<in> p. m (fst xk) = t}. content k *\<^sub>R f (m x) x -
 27.1043                integral k (f (m x))) \<le> e / 2 ^ (t + 2)"
 27.1044                apply (rule order_trans
 27.1045 -                [of _ "norm (setsum (\<lambda>(x,k). content k *\<^sub>R f t x - integral k (f t)) {xk \<in> p. m (fst xk) = t})"])
 27.1046 +                [of _ "norm (sum (\<lambda>(x,k). content k *\<^sub>R f t x - integral k (f t)) {xk \<in> p. m (fst xk) = t})"])
 27.1047                apply (rule eq_refl)
 27.1048                apply (rule arg_cong[where f=norm])
 27.1049 -              apply (rule setsum.cong)
 27.1050 +              apply (rule sum.cong)
 27.1051                apply (rule refl)
 27.1052                defer
 27.1053                apply (rule henstock_lemma_part1)
 27.1054 @@ -6587,7 +6587,7 @@
 27.1055            apply (rule comb[of r])
 27.1056            apply (rule comb[of s])
 27.1057            apply (rule i'[unfolded real_inner_1_right])
 27.1058 -          apply (rule_tac[1-2] setsum_mono)
 27.1059 +          apply (rule_tac[1-2] sum_mono)
 27.1060            unfolding split_paired_all split_conv
 27.1061            apply (rule_tac[1-2] integral_le[OF ])
 27.1062          proof safe
 27.1063 @@ -7013,7 +7013,7 @@
 27.1064        defer
 27.1065        apply (rule d1(2)[OF conjI[OF p(1)]])
 27.1066        defer
 27.1067 -      apply (rule setsum_norm_le)
 27.1068 +      apply (rule sum_norm_le)
 27.1069      proof safe
 27.1070        fix x k
 27.1071        assume "(x, k) \<in> p"
    28.1 --- a/src/HOL/Analysis/Homeomorphism.thy	Sun Oct 16 22:43:51 2016 +0200
    28.2 +++ b/src/HOL/Analysis/Homeomorphism.thy	Mon Oct 17 11:46:22 2016 +0200
    28.3 @@ -999,22 +999,22 @@
    28.4    proof
    28.5      show "linear f"
    28.6        unfolding f_def
    28.7 -      by (intro linear_compose_setsum linearI ballI) (auto simp: algebra_simps)
    28.8 +      by (intro linear_compose_sum linearI ballI) (auto simp: algebra_simps)
    28.9      show "linear g"
   28.10        unfolding g_def
   28.11 -      by (intro linear_compose_setsum linearI ballI) (auto simp: algebra_simps)
   28.12 +      by (intro linear_compose_sum linearI ballI) (auto simp: algebra_simps)
   28.13      have *: "(\<Sum>a \<in> Basis. a \<bullet> basf b * (x \<bullet> basg a)) = x \<bullet> b" if "b \<in> Basis" for x b
   28.14        using sbf that by auto
   28.15      show gf: "g (f x) = x" for x
   28.16        apply (rule euclidean_eqI)
   28.17 -      apply (simp add: f_def g_def inner_setsum_left scaleR_setsum_left algebra_simps)
   28.18 -      apply (simp add: Groups_Big.setsum_distrib_left [symmetric] *)
   28.19 +      apply (simp add: f_def g_def inner_sum_left scaleR_sum_left algebra_simps)
   28.20 +      apply (simp add: Groups_Big.sum_distrib_left [symmetric] *)
   28.21        done
   28.22      show "basf(0,1) \<in> Basis"
   28.23        using b01 sbf by auto
   28.24      then show "f(x,0) \<bullet> basf(0,1) = 0" for x
   28.25 -      apply (simp add: f_def inner_setsum_left)
   28.26 -      apply (rule comm_monoid_add_class.setsum.neutral)
   28.27 +      apply (simp add: f_def inner_sum_left)
   28.28 +      apply (rule comm_monoid_add_class.sum.neutral)
   28.29        using b01 inner_not_same_Basis by fastforce
   28.30    qed
   28.31  qed
    29.1 --- a/src/HOL/Analysis/Inner_Product.thy	Sun Oct 16 22:43:51 2016 +0200
    29.2 +++ b/src/HOL/Analysis/Inner_Product.thy	Mon Oct 17 11:46:22 2016 +0200
    29.3 @@ -46,7 +46,7 @@
    29.4  lemma inner_diff_left: "inner (x - y) z = inner x z - inner y z"
    29.5    using inner_add_left [of x "- y" z] by simp
    29.6  
    29.7 -lemma inner_setsum_left: "inner (\<Sum>x\<in>A. f x) y = (\<Sum>x\<in>A. inner (f x) y)"
    29.8 +lemma inner_sum_left: "inner (\<Sum>x\<in>A. f x) y = (\<Sum>x\<in>A. inner (f x) y)"
    29.9    by (cases "finite A", induct set: finite, simp_all add: inner_add_left)
   29.10  
   29.11  text \<open>Transfer distributivity rules to right argument.\<close>
   29.12 @@ -66,8 +66,8 @@
   29.13  lemma inner_diff_right: "inner x (y - z) = inner x y - inner x z"
   29.14    using inner_diff_left [of y z x] by (simp only: inner_commute)
   29.15  
   29.16 -lemma inner_setsum_right: "inner x (\<Sum>y\<in>A. f y) = (\<Sum>y\<in>A. inner x (f y))"
   29.17 -  using inner_setsum_left [of f A x] by (simp only: inner_commute)
   29.18 +lemma inner_sum_right: "inner x (\<Sum>y\<in>A. f y) = (\<Sum>y\<in>A. inner x (f y))"
   29.19 +  using inner_sum_left [of f A x] by (simp only: inner_commute)
   29.20  
   29.21  lemmas inner_add [algebra_simps] = inner_add_left inner_add_right
   29.22  lemmas inner_diff [algebra_simps]  = inner_diff_left inner_diff_right
    30.1 --- a/src/HOL/Analysis/Integral_Test.thy	Sun Oct 16 22:43:51 2016 +0200
    30.2 +++ b/src/HOL/Analysis/Integral_Test.thy	Mon Oct 17 11:46:22 2016 +0200
    30.3 @@ -43,11 +43,11 @@
    30.4      with Suc show ?case by simp
    30.5    qed simp_all
    30.6    also have "... \<le> (\<Sum>k<n. integral {of_nat k..of_nat (Suc k)} (\<lambda>_::real. f (of_nat k)))"
    30.7 -    by (intro setsum_mono integral_le int) (auto intro: dec)
    30.8 +    by (intro sum_mono integral_le int) (auto intro: dec)
    30.9    also have "... = (\<Sum>k<n. f (of_nat k))" by simp
   30.10    also have "\<dots> - (\<Sum>k\<le>n. f (of_nat k)) = -(\<Sum>k\<in>{..n} - {..<n}. f (of_nat k))"
   30.11 -    by (subst setsum_diff) auto
   30.12 -  also have "\<dots> \<le> 0" by (auto intro!: setsum_nonneg nonneg)
   30.13 +    by (subst sum_diff) auto
   30.14 +  also have "\<dots> \<le> 0" by (auto intro!: sum_nonneg nonneg)
   30.15    finally show "sum_integral_diff_series n \<ge> 0" by simp
   30.16  qed
   30.17  
    31.1 --- a/src/HOL/Analysis/L2_Norm.thy	Sun Oct 16 22:43:51 2016 +0200
    31.2 +++ b/src/HOL/Analysis/L2_Norm.thy	Mon Oct 17 11:46:22 2016 +0200
    31.3 @@ -28,10 +28,10 @@
    31.4  lemma setL2_insert [simp]:
    31.5    "\<lbrakk>finite F; a \<notin> F\<rbrakk> \<Longrightarrow>
    31.6      setL2 f (insert a F) = sqrt ((f a)\<^sup>2 + (setL2 f F)\<^sup>2)"
    31.7 -  unfolding setL2_def by (simp add: setsum_nonneg)
    31.8 +  unfolding setL2_def by (simp add: sum_nonneg)
    31.9  
   31.10  lemma setL2_nonneg [simp]: "0 \<le> setL2 f A"
   31.11 -  unfolding setL2_def by (simp add: setsum_nonneg)
   31.12 +  unfolding setL2_def by (simp add: sum_nonneg)
   31.13  
   31.14  lemma setL2_0': "\<forall>a\<in>A. f a = 0 \<Longrightarrow> setL2 f A = 0"
   31.15    unfolding setL2_def by simp
   31.16 @@ -44,7 +44,7 @@
   31.17    assumes "\<And>i. i \<in> K \<Longrightarrow> 0 \<le> f i"
   31.18    shows "setL2 f K \<le> setL2 g K"
   31.19    unfolding setL2_def
   31.20 -  by (simp add: setsum_nonneg setsum_mono power_mono assms)
   31.21 +  by (simp add: sum_nonneg sum_mono power_mono assms)
   31.22  
   31.23  lemma setL2_strict_mono:
   31.24    assumes "finite K" and "K \<noteq> {}"
   31.25 @@ -52,27 +52,27 @@
   31.26    assumes "\<And>i. i \<in> K \<Longrightarrow> 0 \<le> f i"
   31.27    shows "setL2 f K < setL2 g K"
   31.28    unfolding setL2_def
   31.29 -  by (simp add: setsum_strict_mono power_strict_mono assms)
   31.30 +  by (simp add: sum_strict_mono power_strict_mono assms)
   31.31  
   31.32  lemma setL2_right_distrib:
   31.33    "0 \<le> r \<Longrightarrow> r * setL2 f A = setL2 (\<lambda>x. r * f x) A"
   31.34    unfolding setL2_def
   31.35    apply (simp add: power_mult_distrib)
   31.36 -  apply (simp add: setsum_distrib_left [symmetric])
   31.37 -  apply (simp add: real_sqrt_mult setsum_nonneg)
   31.38 +  apply (simp add: sum_distrib_left [symmetric])
   31.39 +  apply (simp add: real_sqrt_mult sum_nonneg)
   31.40    done
   31.41  
   31.42  lemma setL2_left_distrib:
   31.43    "0 \<le> r \<Longrightarrow> setL2 f A * r = setL2 (\<lambda>x. f x * r) A"
   31.44    unfolding setL2_def
   31.45    apply (simp add: power_mult_distrib)
   31.46 -  apply (simp add: setsum_distrib_right [symmetric])
   31.47 -  apply (simp add: real_sqrt_mult setsum_nonneg)
   31.48 +  apply (simp add: sum_distrib_right [symmetric])
   31.49 +  apply (simp add: real_sqrt_mult sum_nonneg)
   31.50    done
   31.51  
   31.52  lemma setL2_eq_0_iff: "finite A \<Longrightarrow> setL2 f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)"
   31.53    unfolding setL2_def
   31.54 -  by (simp add: setsum_nonneg setsum_nonneg_eq_0_iff)
   31.55 +  by (simp add: sum_nonneg sum_nonneg_eq_0_iff)
   31.56  
   31.57  lemma setL2_triangle_ineq:
   31.58    shows "setL2 (\<lambda>i. f i + g i) A \<le> setL2 f A + setL2 g A"
   31.59 @@ -106,8 +106,8 @@
   31.60    apply simp
   31.61    done
   31.62  
   31.63 -lemma setL2_le_setsum [rule_format]:
   31.64 -  "(\<forall>i\<in>A. 0 \<le> f i) \<longrightarrow> setL2 f A \<le> setsum f A"
   31.65 +lemma setL2_le_sum [rule_format]:
   31.66 +  "(\<forall>i\<in>A. 0 \<le> f i) \<longrightarrow> setL2 f A \<le> sum f A"
   31.67    apply (cases "finite A")
   31.68    apply (induct set: finite)
   31.69    apply simp
   31.70 @@ -124,7 +124,7 @@
   31.71    apply simp
   31.72    done
   31.73  
   31.74 -lemma setL2_le_setsum_abs: "setL2 f A \<le> (\<Sum>i\<in>A. \<bar>f i\<bar>)"
   31.75 +lemma setL2_le_sum_abs: "setL2 f A \<le> (\<Sum>i\<in>A. \<bar>f i\<bar>)"
   31.76    apply (cases "finite A")
   31.77    apply (induct set: finite)
   31.78    apply simp
   31.79 @@ -155,7 +155,7 @@
   31.80    apply (rule order_trans)
   31.81    apply (rule power_mono)
   31.82    apply (erule add_left_mono)
   31.83 -  apply (simp add: setsum_nonneg)
   31.84 +  apply (simp add: sum_nonneg)
   31.85    apply (simp add: power2_sum)
   31.86    apply (simp add: power_mult_distrib)
   31.87    apply (simp add: distrib_left distrib_right)
   31.88 @@ -166,6 +166,6 @@
   31.89  
   31.90  lemma member_le_setL2: "\<lbrakk>finite A; i \<in> A\<rbrakk> \<Longrightarrow> f i \<le> setL2 f A"
   31.91    unfolding setL2_def
   31.92 -  by (auto intro!: member_le_setsum real_le_rsqrt)
   31.93 +  by (auto intro!: member_le_sum real_le_rsqrt)
   31.94  
   31.95  end
    32.1 --- a/src/HOL/Analysis/Lebesgue_Measure.thy	Sun Oct 16 22:43:51 2016 +0200
    32.2 +++ b/src/HOL/Analysis/Lebesgue_Measure.thy	Mon Oct 17 11:46:22 2016 +0200
    32.3 @@ -82,7 +82,7 @@
    32.4            by fastforce
    32.5  
    32.6          have "(\<Sum>i\<in>S. F (r i) - F (l i)) = (F (r m) - F (l m)) + (\<Sum>i\<in>S - {m}. F (r i) - F (l i))"
    32.7 -          using m psubset by (intro setsum.remove) auto
    32.8 +          using m psubset by (intro sum.remove) auto
    32.9          also have "(\<Sum>i\<in>S - {m}. F (r i) - F (l i)) \<le> F b - F (r m)"
   32.10          proof (intro psubset.IH)
   32.11            show "S - {m} \<subset> S"
   32.12 @@ -144,7 +144,7 @@
   32.13              by (intro psubset) auto
   32.14            also have "\<dots> \<le> (\<Sum>i\<in>S. F (r i) - F (l i))"
   32.15              using psubset.prems
   32.16 -            by (intro setsum_mono2 psubset) (auto intro: less_imp_le)
   32.17 +            by (intro sum_mono2 psubset) (auto intro: less_imp_le)
   32.18            finally show ?thesis .
   32.19          next
   32.20            assume "\<not> ?R"
   32.21 @@ -155,13 +155,13 @@
   32.22  
   32.23            have "(\<Sum>i\<in>S. F (r i) - F (l i)) \<ge> (\<Sum>i\<in>?S1 \<union> ?S2 \<union> {j}. F (r i) - F (l i))"
   32.24              using \<open>j \<in> S\<close> \<open>finite S\<close> psubset.prems j
   32.25 -            by (intro setsum_mono2) (auto intro: less_imp_le)
   32.26 +            by (intro sum_mono2) (auto intro: less_imp_le)
   32.27            also have "(\<Sum>i\<in>?S1 \<union> ?S2 \<union> {j}. F (r i) - F (l i)) =
   32.28              (\<Sum>i\<in>?S1. F (r i) - F (l i)) + (\<Sum>i\<in>?S2 . F (r i) - F (l i)) + (F (r j) - F (l j))"
   32.29              using psubset(1) psubset.prems(1) j
   32.30 -            apply (subst setsum.union_disjoint)
   32.31 +            apply (subst sum.union_disjoint)
   32.32              apply simp_all
   32.33 -            apply (subst setsum.union_disjoint)
   32.34 +            apply (subst sum.union_disjoint)
   32.35              apply auto
   32.36              apply (metis less_le_not_le)
   32.37              done
   32.38 @@ -245,7 +245,7 @@
   32.39        apply arith
   32.40        by (rule deltai_gt0)
   32.41      also have "... \<le> (\<Sum>i \<in> S. F(r i) - F(l i) + epsilon / 2^(i+2))"
   32.42 -      apply (rule setsum_mono)
   32.43 +      apply (rule sum_mono)
   32.44        apply simp
   32.45        apply (rule order_trans)
   32.46        apply (rule less_imp_le)
   32.47 @@ -253,11 +253,11 @@
   32.48        by auto
   32.49      also have "... = (\<Sum>i \<in> S. F(r i) - F(l i)) +
   32.50          (epsilon / 4) * (\<Sum>i \<in> S. (1 / 2)^i)" (is "_ = ?t + _")
   32.51 -      by (subst setsum.distrib) (simp add: field_simps setsum_distrib_left)
   32.52 +      by (subst sum.distrib) (simp add: field_simps sum_distrib_left)
   32.53      also have "... \<le> ?t + (epsilon / 4) * (\<Sum> i < Suc n. (1 / 2)^i)"
   32.54        apply (rule add_left_mono)
   32.55        apply (rule mult_left_mono)
   32.56 -      apply (rule setsum_mono2)
   32.57 +      apply (rule sum_mono2)
   32.58        using egt0 apply auto
   32.59        by (frule Sbound, auto)
   32.60      also have "... \<le> ?t + (epsilon / 2)"
   32.61 @@ -281,11 +281,11 @@
   32.62      also have "... = (\<Sum>i\<in>S. F (r i) - F (l i)) + epsilon"
   32.63        by auto
   32.64      also have "... \<le> (\<Sum>i\<le>n. F (r i) - F (l i)) + epsilon"
   32.65 -      using finS Sbound Sprop by (auto intro!: add_right_mono setsum_mono3)
   32.66 +      using finS Sbound Sprop by (auto intro!: add_right_mono sum_mono3)
   32.67      finally have "ennreal (F b - F a) \<le> (\<Sum>i\<le>n. ennreal (F (r i) - F (l i))) + epsilon"
   32.68 -      using egt0 by (simp add: ennreal_plus[symmetric] setsum_nonneg del: ennreal_plus)
   32.69 +      using egt0 by (simp add: ennreal_plus[symmetric] sum_nonneg del: ennreal_plus)
   32.70      then show "ennreal (F b - F a) \<le> (\<Sum>i. ennreal (F (r i) - F (l i))) + (epsilon :: real)"
   32.71 -      by (rule order_trans) (auto intro!: add_mono setsum_le_suminf simp del: setsum_ennreal)
   32.72 +      by (rule order_trans) (auto intro!: add_mono sum_le_suminf simp del: sum_ennreal)
   32.73    qed
   32.74    moreover have "(\<Sum>i. ennreal (F (r i) - F (l i))) \<le> ennreal (F b - F a)"
   32.75      using \<open>a \<le> b\<close> by (auto intro!: suminf_le_const ennreal_le_iff[THEN iffD2] claim1)
   32.76 @@ -637,7 +637,7 @@
   32.77    fixes t :: "'a::euclidean_space"
   32.78    shows "c \<noteq> 0 \<Longrightarrow> lborel = density (distr lborel borel (\<lambda>x. t + c *\<^sub>R x)) (\<lambda>_. \<bar>c\<bar>^DIM('a))"
   32.79    using lborel_affine_euclidean[where c="\<lambda>_::'a. c" and t=t]
   32.80 -  unfolding scaleR_scaleR[symmetric] scaleR_setsum_right[symmetric] euclidean_representation setprod_constant by simp
   32.81 +  unfolding scaleR_scaleR[symmetric] scaleR_sum_right[symmetric] euclidean_representation setprod_constant by simp
   32.82  
   32.83  lemma lborel_real_affine:
   32.84    "c \<noteq> 0 \<Longrightarrow> lborel = density (distr lborel borel (\<lambda>x. t + c * x)) (\<lambda>_. ennreal (abs c))"
   32.85 @@ -722,7 +722,7 @@
   32.86  next
   32.87    assume "x \<noteq> 0" then show ?thesis
   32.88      using lebesgue_affine_measurable[of "\<lambda>_. x" 0]
   32.89 -    unfolding scaleR_scaleR[symmetric] scaleR_setsum_right[symmetric] euclidean_representation
   32.90 +    unfolding scaleR_scaleR[symmetric] scaleR_sum_right[symmetric] euclidean_representation
   32.91      by (auto simp add: ac_simps)
   32.92  qed
   32.93  
   32.94 @@ -747,7 +747,7 @@
   32.95        using bij_vimage_eq_inv_image[OF \<open>bij ?T'\<close>, of S] by auto
   32.96  
   32.97      have trans_eq_T: "(\<lambda>x. \<delta> + (\<Sum>j\<in>Basis. (m * (x \<bullet> j)) *\<^sub>R j)) = T m \<delta>" for m \<delta>
   32.98 -      unfolding T_def[abs_def] scaleR_scaleR[symmetric] scaleR_setsum_right[symmetric]
   32.99 +      unfolding T_def[abs_def] scaleR_scaleR[symmetric] scaleR_sum_right[symmetric]
  32.100        by (auto simp add: euclidean_representation ac_simps)
  32.101  
  32.102      have T[measurable]: "T r d \<in> lebesgue \<rightarrow>\<^sub>M lebesgue" for r d
    33.1 --- a/src/HOL/Analysis/Linear_Algebra.thy	Sun Oct 16 22:43:51 2016 +0200
    33.2 +++ b/src/HOL/Analysis/Linear_Algebra.thy	Mon Oct 17 11:46:22 2016 +0200
    33.3 @@ -141,9 +141,9 @@
    33.4  lemma linear_uminus: "linear uminus"
    33.5  by (simp add: linear_iff)
    33.6  
    33.7 -lemma linear_compose_setsum:
    33.8 +lemma linear_compose_sum:
    33.9    assumes lS: "\<forall>a \<in> S. linear (f a)"
   33.10 -  shows "linear (\<lambda>x. setsum (\<lambda>a. f a x) S)"
   33.11 +  shows "linear (\<lambda>x. sum (\<lambda>a. f a