2210 lemma uminus_listsum_map: |
2210 lemma uminus_listsum_map: |
2211 fixes f :: "'a \<Rightarrow> 'b\<Colon>ab_group_add" |
2211 fixes f :: "'a \<Rightarrow> 'b\<Colon>ab_group_add" |
2212 shows "- listsum (map f xs) = (listsum (map (uminus o f) xs))" |
2212 shows "- listsum (map f xs) = (listsum (map (uminus o f) xs))" |
2213 by (induct xs) simp_all |
2213 by (induct xs) simp_all |
2214 |
2214 |
|
2215 lemma listsum_addf: |
|
2216 fixes f g :: "'a \<Rightarrow> 'b::comm_monoid_add" |
|
2217 shows "(\<Sum>x\<leftarrow>xs. f x + g x) = listsum (map f xs) + listsum (map g xs)" |
|
2218 by (induct xs) (simp_all add: algebra_simps) |
|
2219 |
|
2220 lemma listsum_subtractf: |
|
2221 fixes f g :: "'a \<Rightarrow> 'b::ab_group_add" |
|
2222 shows "(\<Sum>x\<leftarrow>xs. f x - g x) = listsum (map f xs) - listsum (map g xs)" |
|
2223 by (induct xs) simp_all |
|
2224 |
|
2225 lemma listsum_const_mult: |
|
2226 fixes f :: "'a \<Rightarrow> 'b::semiring_0" |
|
2227 shows "(\<Sum>x\<leftarrow>xs. c * f x) = c * (\<Sum>x\<leftarrow>xs. f x)" |
|
2228 by (induct xs, simp_all add: algebra_simps) |
|
2229 |
|
2230 lemma listsum_mult_const: |
|
2231 fixes f :: "'a \<Rightarrow> 'b::semiring_0" |
|
2232 shows "(\<Sum>x\<leftarrow>xs. f x * c) = (\<Sum>x\<leftarrow>xs. f x) * c" |
|
2233 by (induct xs, simp_all add: algebra_simps) |
|
2234 |
|
2235 lemma listsum_abs: |
|
2236 fixes xs :: "'a::pordered_ab_group_add_abs list" |
|
2237 shows "\<bar>listsum xs\<bar> \<le> listsum (map abs xs)" |
|
2238 by (induct xs, simp, simp add: order_trans [OF abs_triangle_ineq]) |
|
2239 |
|
2240 lemma listsum_mono: |
|
2241 fixes f g :: "'a \<Rightarrow> 'b::{comm_monoid_add, pordered_ab_semigroup_add}" |
|
2242 shows "(\<And>x. x \<in> set xs \<Longrightarrow> f x \<le> g x) \<Longrightarrow> (\<Sum>x\<leftarrow>xs. f x) \<le> (\<Sum>x\<leftarrow>xs. g x)" |
|
2243 by (induct xs, simp, simp add: add_mono) |
|
2244 |
2215 |
2245 |
2216 subsubsection {* @{text upt} *} |
2246 subsubsection {* @{text upt} *} |
2217 |
2247 |
2218 lemma upt_rec[code]: "[i..<j] = (if i<j then i#[Suc i..<j] else [])" |
2248 lemma upt_rec[code]: "[i..<j] = (if i<j then i#[Suc i..<j] else [])" |
2219 -- {* simp does not terminate! *} |
2249 -- {* simp does not terminate! *} |