src/HOL/Predicate_Compile_Examples/Predicate_Compile_Quickcheck_Examples.thy
changeset 64267 b9a1486e79be
parent 63882 018998c00003
child 66453 cc19f7ca2ed6
equal deleted inserted replaced
64265:8eb6365f5916 64267:b9a1486e79be
   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]" |