equal
deleted
inserted
replaced
50 next |
50 next |
51 case (Cons a al) |
51 case (Cons a al) |
52 note length_filter_le [of "\<lambda>p. fst p \<noteq> fst a" al] |
52 note length_filter_le [of "\<lambda>p. fst p \<noteq> fst a" al] |
53 also have "\<And>n. n \<le> Suc n" |
53 also have "\<And>n. n \<le> Suc n" |
54 by simp |
54 by simp |
55 finally have "length [p\<in>al . fst p \<noteq> fst a] \<le> Suc (length al)" . |
55 finally have "length [p\<leftarrow>al . fst p \<noteq> fst a] \<le> Suc (length al)" . |
56 with Cons show ?case |
56 with Cons show ?case |
57 by auto |
57 by auto |
58 qed |
58 qed |
59 |
59 |
60 lemma compose_hint [simp]: |
60 lemma compose_hint [simp]: |
187 |
187 |
188 lemma distinct_clearjunk [simp]: "distinct (map fst (clearjunk al))" |
188 lemma distinct_clearjunk [simp]: "distinct (map fst (clearjunk al))" |
189 by (induct al rule: clearjunk.induct) |
189 by (induct al rule: clearjunk.induct) |
190 (simp_all add: dom_clearjunk notin_filter_fst delete_def) |
190 (simp_all add: dom_clearjunk notin_filter_fst delete_def) |
191 |
191 |
192 lemma map_of_filter: "k \<noteq> a \<Longrightarrow> map_of [q\<in>ps . fst q \<noteq> a] k = map_of ps k" |
192 lemma map_of_filter: "k \<noteq> a \<Longrightarrow> map_of [q\<leftarrow>ps . fst q \<noteq> a] k = map_of ps k" |
193 by (induct ps) auto |
193 by (induct ps) auto |
194 |
194 |
195 lemma map_of_clearjunk: "map_of (clearjunk al) = map_of al" |
195 lemma map_of_clearjunk: "map_of (clearjunk al) = map_of al" |
196 apply (rule ext) |
196 apply (rule ext) |
197 apply (induct al rule: clearjunk.induct) |
197 apply (induct al rule: clearjunk.induct) |
202 lemma length_clearjunk: "length (clearjunk al) \<le> length al" |
202 lemma length_clearjunk: "length (clearjunk al) \<le> length al" |
203 proof (induct al rule: clearjunk.induct [case_names Nil Cons]) |
203 proof (induct al rule: clearjunk.induct [case_names Nil Cons]) |
204 case Nil thus ?case by simp |
204 case Nil thus ?case by simp |
205 next |
205 next |
206 case (Cons p ps) |
206 case (Cons p ps) |
207 from Cons have "length (clearjunk [q\<in>ps . fst q \<noteq> fst p]) \<le> length [q\<in>ps . fst q \<noteq> fst p]" |
207 from Cons have "length (clearjunk [q\<leftarrow>ps . fst q \<noteq> fst p]) \<le> length [q\<leftarrow>ps . fst q \<noteq> fst p]" |
208 by (simp add: delete_def) |
208 by (simp add: delete_def) |
209 also have "\<dots> \<le> length ps" |
209 also have "\<dots> \<le> length ps" |
210 by simp |
210 by simp |
211 finally show ?case |
211 finally show ?case |
212 by (simp add: delete_def) |
212 by (simp add: delete_def) |
213 qed |
213 qed |
214 |
214 |
215 lemma notin_fst_filter: "a \<notin> fst ` set ps \<Longrightarrow> [q\<in>ps . fst q \<noteq> a] = ps" |
215 lemma notin_fst_filter: "a \<notin> fst ` set ps \<Longrightarrow> [q\<leftarrow>ps . fst q \<noteq> a] = ps" |
216 by (induct ps) auto |
216 by (induct ps) auto |
217 |
217 |
218 lemma distinct_clearjunk_id [simp]: "distinct (map fst al) \<Longrightarrow> clearjunk al = al" |
218 lemma distinct_clearjunk_id [simp]: "distinct (map fst al) \<Longrightarrow> clearjunk al = al" |
219 by (induct al rule: clearjunk.induct) (auto simp add: notin_fst_filter) |
219 by (induct al rule: clearjunk.induct) (auto simp add: notin_fst_filter) |
220 |
220 |
332 with False a_notin_al show ?thesis by (simp add: dom_update) |
332 with False a_notin_al show ?thesis by (simp add: dom_update) |
333 qed |
333 qed |
334 qed |
334 qed |
335 |
335 |
336 lemma update_filter: |
336 lemma update_filter: |
337 "a\<noteq>k \<Longrightarrow> update k v [q\<in>ps . fst q \<noteq> a] = [q\<in>update k v ps . fst q \<noteq> a]" |
337 "a\<noteq>k \<Longrightarrow> update k v [q\<leftarrow>ps . fst q \<noteq> a] = [q\<leftarrow>update k v ps . fst q \<noteq> a]" |
338 by (induct ps) auto |
338 by (induct ps) auto |
339 |
339 |
340 lemma clearjunk_update: "clearjunk (update k v al) = update k v (clearjunk al)" |
340 lemma clearjunk_update: "clearjunk (update k v al) = update k v (clearjunk al)" |
341 by (induct al rule: clearjunk.induct) (auto simp add: update_filter delete_def) |
341 by (induct al rule: clearjunk.induct) (auto simp add: update_filter delete_def) |
342 |
342 |
458 by (induct al) auto |
458 by (induct al) auto |
459 |
459 |
460 lemma distinct_map_ran: "distinct (map fst al) \<Longrightarrow> distinct (map fst (map_ran f al))" |
460 lemma distinct_map_ran: "distinct (map fst al) \<Longrightarrow> distinct (map fst (map_ran f al))" |
461 by (induct al) (auto simp add: dom_map_ran) |
461 by (induct al) (auto simp add: dom_map_ran) |
462 |
462 |
463 lemma map_ran_filter: "map_ran f [p\<in>ps. fst p \<noteq> a] = [p\<in>map_ran f ps. fst p \<noteq> a]" |
463 lemma map_ran_filter: "map_ran f [p\<leftarrow>ps. fst p \<noteq> a] = [p\<leftarrow>map_ran f ps. fst p \<noteq> a]" |
464 by (induct ps) auto |
464 by (induct ps) auto |
465 |
465 |
466 lemma clearjunk_map_ran: "clearjunk (map_ran f al) = map_ran f (clearjunk al)" |
466 lemma clearjunk_map_ran: "clearjunk (map_ran f al) = map_ran f (clearjunk al)" |
467 by (induct al rule: clearjunk.induct) (auto simp add: delete_def map_ran_filter) |
467 by (induct al rule: clearjunk.induct) (auto simp add: delete_def map_ran_filter) |
468 |
468 |