equal
deleted
inserted
replaced
68 diff_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
68 diff_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
69 where |
69 where |
70 [simp]: "diff_list xs ys = [x \<leftarrow> xs. x \<notin> set ys]" |
70 [simp]: "diff_list xs ys = [x \<leftarrow> xs. x \<notin> set ys]" |
71 |
71 |
72 definition |
72 definition |
73 rsp_fold |
73 rsp_fold :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> bool" |
74 where |
74 where |
75 "rsp_fold f \<equiv> \<forall>u v w. (f u (f v w) = f v (f u w))" |
75 "rsp_fold f \<longleftrightarrow> (\<forall>u v. f u \<circ> f v = f v \<circ> f u)" |
76 |
76 |
77 primrec |
77 primrec |
78 fold_list :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b" |
78 fold_list :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b" |
79 where |
79 where |
80 "fold_list f z [] = z" |
80 "fold_list f z [] = z" |
225 |
225 |
226 lemma member_commute_fold_list: |
226 lemma member_commute_fold_list: |
227 assumes a: "rsp_fold f" |
227 assumes a: "rsp_fold f" |
228 and b: "x \<in> set xs" |
228 and b: "x \<in> set xs" |
229 shows "fold_list f y xs = f x (fold_list f y (removeAll x xs))" |
229 shows "fold_list f y xs = f x (fold_list f y (removeAll x xs))" |
230 using a b by (induct xs) (auto simp add: rsp_fold_def) |
230 using a b by (induct xs) (auto simp add: rsp_fold_def fun_eq_iff) |
231 |
231 |
232 lemma fold_list_rsp_pre: |
232 lemma fold_list_rsp_pre: |
233 assumes a: "set xs = set ys" |
233 assumes a: "set xs = set ys" |
234 shows "fold_list f z xs = fold_list f z ys" |
234 shows "fold_list f z xs = fold_list f z ys" |
235 using a |
235 using a |