equal
deleted
inserted
replaced
311 assumes "length w = length v" |
311 assumes "length w = length v" |
312 shows "(\<Sum>x\<leftarrow>sparsify w. (\<lambda>(i, x). v ! i) x * snd x) = scalar_product v w" |
312 shows "(\<Sum>x\<leftarrow>sparsify w. (\<lambda>(i, x). v ! i) x * snd x) = scalar_product v w" |
313 (is "(\<Sum>x\<leftarrow>_. ?f x) = _") |
313 (is "(\<Sum>x\<leftarrow>_. ?f x) = _") |
314 unfolding sparsify_def scalar_product_def |
314 unfolding sparsify_def scalar_product_def |
315 using assms sum_list_map_filter[where f="?f" and P="\<lambda> i. snd i \<noteq> (0::'a)"] |
315 using assms sum_list_map_filter[where f="?f" and P="\<lambda> i. snd i \<noteq> (0::'a)"] |
316 by (simp add: sum_list_setsum) |
316 by (simp add: sum_list_sum) |
317 *) |
317 *) |
318 definition [simp]: "unzip w = (map fst w, map snd w)" |
318 definition [simp]: "unzip w = (map fst w, map snd w)" |
319 |
319 |
320 primrec insert :: "('a \<Rightarrow> 'b :: linorder) => 'a \<Rightarrow> 'a list => 'a list" where |
320 primrec insert :: "('a \<Rightarrow> 'b :: linorder) => 'a \<Rightarrow> 'a list => 'a list" where |
321 "insert f x [] = [x]" | |
321 "insert f x [] = [x]" | |