48 where |
49 where |
49 "finter_raw [] l = []" |
50 "finter_raw [] l = []" |
50 | "finter_raw (h # t) l = |
51 | "finter_raw (h # t) l = |
51 (if memb h l then h # (finter_raw t l) else finter_raw t l)" |
52 (if memb h l then h # (finter_raw t l) else finter_raw t l)" |
52 |
53 |
53 fun |
54 primrec |
54 delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list" |
55 delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list" |
55 where |
56 where |
56 "delete_raw [] x = []" |
57 "delete_raw [] x = []" |
57 | "delete_raw (a # A) x = (if (a = x) then delete_raw A x else a # (delete_raw A x))" |
58 | "delete_raw (a # xs) x = (if (a = x) then delete_raw xs x else a # (delete_raw xs x))" |
|
59 |
|
60 primrec |
|
61 fminus_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
|
62 where |
|
63 "fminus_raw l [] = l" |
|
64 | "fminus_raw l (h # t) = fminus_raw (delete_raw l h) t" |
58 |
65 |
59 definition |
66 definition |
60 rsp_fold |
67 rsp_fold |
61 where |
68 where |
62 "rsp_fold f = (\<forall>u v w. (f u (f v w) = f v (f u w)))" |
69 "rsp_fold f = (\<forall>u v w. (f u (f v w) = f v (f u w)))" |
63 |
70 |
64 primrec |
71 primrec |
65 ffold_raw :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b" |
72 ffold_raw :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b" |
66 where |
73 where |
67 "ffold_raw f z [] = z" |
74 "ffold_raw f z [] = z" |
68 | "ffold_raw f z (a # A) = |
75 | "ffold_raw f z (a # xs) = |
69 (if (rsp_fold f) then |
76 (if (rsp_fold f) then |
70 if memb a A then ffold_raw f z A |
77 if memb a xs then ffold_raw f z xs |
71 else f a (ffold_raw f z A) |
78 else f a (ffold_raw f z xs) |
72 else z)" |
79 else z)" |
73 |
80 |
74 text {* Composition Quotient *} |
81 text {* Composition Quotient *} |
75 |
82 |
76 lemma list_rel_refl: |
83 lemma list_rel_refl: |
78 by (rule list_rel_refl) (metis equivp_def fset_equivp) |
85 by (rule list_rel_refl) (metis equivp_def fset_equivp) |
79 |
86 |
80 lemma compose_list_refl: |
87 lemma compose_list_refl: |
81 shows "(list_rel op \<approx> OOO op \<approx>) r r" |
88 shows "(list_rel op \<approx> OOO op \<approx>) r r" |
82 proof |
89 proof |
83 show c: "list_rel op \<approx> r r" by (rule list_rel_refl) |
90 have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp]) |
84 have d: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp]) |
91 show "list_rel op \<approx> r r" by (rule list_rel_refl) |
85 show b: "(op \<approx> OO list_rel op \<approx>) r r" by (rule pred_compI) (rule d, rule c) |
92 with * show "(op \<approx> OO list_rel op \<approx>) r r" .. |
86 qed |
93 qed |
87 |
94 |
88 lemma Quotient_fset_list: |
95 lemma Quotient_fset_list: |
89 shows "Quotient (list_rel op \<approx>) (map abs_fset) (map rep_fset)" |
96 shows "Quotient (list_rel op \<approx>) (map abs_fset) (map rep_fset)" |
90 by (fact list_quotient[OF Quotient_fset]) |
97 by (fact list_quotient[OF Quotient_fset]) |
91 |
98 |
92 lemma set_in_eq: "(\<forall>e. ((e \<in> A) \<longleftrightarrow> (e \<in> B))) \<equiv> A = B" |
99 lemma set_in_eq: "(\<forall>e. ((e \<in> xs) \<longleftrightarrow> (e \<in> ys))) \<equiv> xs = ys" |
93 by (rule eq_reflection) auto |
100 by (rule eq_reflection) auto |
94 |
101 |
95 lemma map_rel_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba" |
102 lemma map_rel_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba" |
96 unfolding list_eq.simps |
103 unfolding list_eq.simps |
97 by (simp only: set_map set_in_eq) |
104 by (simp only: set_map set_in_eq) |
115 proof (intro iffI conjI) |
122 proof (intro iffI conjI) |
116 show "(list_rel op \<approx> OOO op \<approx>) r r" by (rule compose_list_refl) |
123 show "(list_rel op \<approx> OOO op \<approx>) r r" by (rule compose_list_refl) |
117 show "(list_rel op \<approx> OOO op \<approx>) s s" by (rule compose_list_refl) |
124 show "(list_rel op \<approx> OOO op \<approx>) s s" by (rule compose_list_refl) |
118 next |
125 next |
119 assume a: "(list_rel op \<approx> OOO op \<approx>) r s" |
126 assume a: "(list_rel op \<approx> OOO op \<approx>) r s" |
120 then have b: "map abs_fset r \<approx> map abs_fset s" proof (elim pred_compE) |
127 then have b: "map abs_fset r \<approx> map abs_fset s" |
|
128 proof (elim pred_compE) |
121 fix b ba |
129 fix b ba |
122 assume c: "list_rel op \<approx> r b" |
130 assume c: "list_rel op \<approx> r b" |
123 assume d: "b \<approx> ba" |
131 assume d: "b \<approx> ba" |
124 assume e: "list_rel op \<approx> ba s" |
132 assume e: "list_rel op \<approx> ba s" |
125 have f: "map abs_fset r = map abs_fset b" |
133 have f: "map abs_fset r = map abs_fset b" |
206 |
214 |
207 lemma [quot_respect]: |
215 lemma [quot_respect]: |
208 "(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw" |
216 "(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw" |
209 by (simp add: memb_def[symmetric] memb_delete_raw) |
217 by (simp add: memb_def[symmetric] memb_delete_raw) |
210 |
218 |
|
219 lemma fminus_raw_memb: "memb x (fminus_raw xs ys) = (memb x xs \<and> \<not> memb x ys)" |
|
220 by (induct ys arbitrary: xs) |
|
221 (simp_all add: not_memb_nil memb_delete_raw memb_cons_iff) |
|
222 |
|
223 lemma [quot_respect]: |
|
224 "(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw" |
|
225 by (simp add: memb_def[symmetric] fminus_raw_memb) |
|
226 |
211 lemma fcard_raw_gt_0: |
227 lemma fcard_raw_gt_0: |
212 assumes a: "x \<in> set xs" |
228 assumes a: "x \<in> set xs" |
213 shows "0 < fcard_raw xs" |
229 shows "0 < fcard_raw xs" |
214 using a by (induct xs) (auto simp add: memb_def) |
230 using a by (induct xs) (auto simp add: memb_def) |
215 |
231 |
219 |
235 |
220 lemma fcard_raw_rsp_aux: |
236 lemma fcard_raw_rsp_aux: |
221 assumes a: "xs \<approx> ys" |
237 assumes a: "xs \<approx> ys" |
222 shows "fcard_raw xs = fcard_raw ys" |
238 shows "fcard_raw xs = fcard_raw ys" |
223 using a |
239 using a |
224 apply (induct xs arbitrary: ys) |
240 proof (induct xs arbitrary: ys) |
225 apply (auto simp add: memb_def) |
241 case Nil |
226 apply (subgoal_tac "\<forall>x. (x \<in> set xs) = (x \<in> set ys)") |
242 show ?case using Nil.prems by simp |
227 apply (auto) |
243 next |
228 apply (drule_tac x="x" in spec) |
244 case (Cons a xs) |
229 apply (blast) |
245 have a: "a # xs \<approx> ys" by fact |
230 apply (drule_tac x="[x \<leftarrow> ys. x \<noteq> a]" in meta_spec) |
246 have b: "\<And>ys. xs \<approx> ys \<Longrightarrow> fcard_raw xs = fcard_raw ys" by fact |
231 apply (simp add: fcard_raw_delete_one memb_def) |
247 show ?case proof (cases "a \<in> set xs") |
232 apply (case_tac "a \<in> set ys") |
248 assume c: "a \<in> set xs" |
233 apply (simp only: if_True) |
249 have "\<forall>x. (x \<in> set xs) = (x \<in> set ys)" |
234 apply (subgoal_tac "\<forall>x. (x \<in> set xs) = (x \<in> set ys \<and> x \<noteq> a)") |
250 proof (intro allI iffI) |
235 apply (drule Suc_pred'[OF fcard_raw_gt_0]) |
251 fix x |
236 apply (auto) |
252 assume "x \<in> set xs" |
237 done |
253 then show "x \<in> set ys" using a by auto |
|
254 next |
|
255 fix x |
|
256 assume d: "x \<in> set ys" |
|
257 have e: "(x \<in> set (a # xs)) = (x \<in> set ys)" using a by simp |
|
258 show "x \<in> set xs" using c d e unfolding list_eq.simps by simp blast |
|
259 qed |
|
260 then show ?thesis using b c by (simp add: memb_def) |
|
261 next |
|
262 assume c: "a \<notin> set xs" |
|
263 have d: "xs \<approx> [x\<leftarrow>ys . x \<noteq> a] \<Longrightarrow> fcard_raw xs = fcard_raw [x\<leftarrow>ys . x \<noteq> a]" using b by simp |
|
264 have "Suc (fcard_raw xs) = fcard_raw ys" |
|
265 proof (cases "a \<in> set ys") |
|
266 assume e: "a \<in> set ys" |
|
267 have f: "\<forall>x. (x \<in> set xs) = (x \<in> set ys \<and> x \<noteq> a)" using a c |
|
268 by (auto simp add: fcard_raw_delete_one) |
|
269 have "fcard_raw ys = Suc (fcard_raw ys - 1)" by (rule Suc_pred'[OF fcard_raw_gt_0]) (rule e) |
|
270 then show ?thesis using d e f by (simp_all add: fcard_raw_delete_one memb_def) |
|
271 next |
|
272 case False then show ?thesis using a c d by auto |
|
273 qed |
|
274 then show ?thesis using a c d by (simp add: memb_def) |
|
275 qed |
|
276 qed |
238 |
277 |
239 lemma fcard_raw_rsp[quot_respect]: |
278 lemma fcard_raw_rsp[quot_respect]: |
240 shows "(op \<approx> ===> op =) fcard_raw fcard_raw" |
279 shows "(op \<approx> ===> op =) fcard_raw fcard_raw" |
241 by (simp add: fcard_raw_rsp_aux) |
280 by (simp add: fcard_raw_rsp_aux) |
242 |
281 |
304 shows "\<exists>x\<in>set y. xa \<in> set x" |
343 shows "\<exists>x\<in>set y. xa \<in> set x" |
305 proof - |
344 proof - |
306 obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto |
345 obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto |
307 have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_rel_find_element[OF e a]) |
346 have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_rel_find_element[OF e a]) |
308 then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto |
347 then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto |
309 have j: "ya \<in> set y'" using b h by simp |
348 have "ya \<in> set y'" using b h by simp |
310 have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" by (rule list_rel_find_element[OF j c]) |
349 then have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" using c by (rule list_rel_find_element) |
311 then show ?thesis using f i by auto |
350 then show ?thesis using f i by auto |
312 qed |
351 qed |
313 |
352 |
314 lemma [quot_respect]: |
353 lemma [quot_respect]: |
315 shows "(list_rel op \<approx> OOO op \<approx> ===> op \<approx>) concat concat" |
354 shows "(list_rel op \<approx> OOO op \<approx> ===> op \<approx>) concat concat" |
421 "sup \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)" |
465 "sup \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)" |
422 is |
466 is |
423 "(op @) \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)" |
467 "(op @) \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)" |
424 |
468 |
425 abbreviation |
469 abbreviation |
426 funion (infixl "|\<union>|" 65) |
470 funion (infixl "|\<union>|" 65) |
427 where |
471 where |
428 "xs |\<union>| ys \<equiv> sup (xs :: 'a fset) ys" |
472 "xs |\<union>| ys \<equiv> sup (xs :: 'a fset) ys" |
429 |
473 |
430 quotient_definition |
474 quotient_definition |
431 "inf \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)" |
475 "inf \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)" |
432 is |
476 is |
433 "finter_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)" |
477 "finter_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)" |
434 |
478 |
435 abbreviation |
479 abbreviation |
436 finter (infixl "|\<inter>|" 65) |
480 finter (infixl "|\<inter>|" 65) |
437 where |
481 where |
438 "xs |\<inter>| ys \<equiv> inf (xs :: 'a fset) ys" |
482 "xs |\<inter>| ys \<equiv> inf (xs :: 'a fset) ys" |
|
483 |
|
484 quotient_definition |
|
485 "minus \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)" |
|
486 is |
|
487 "fminus_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)" |
439 |
488 |
440 instance |
489 instance |
441 proof |
490 proof |
442 fix x y z :: "'a fset" |
491 fix x y z :: "'a fset" |
443 show "(x |\<subset>| y) = (x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x)" |
492 show "(x |\<subset>| y) = (x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x)" |
494 abbreviation |
543 abbreviation |
495 fnotin :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50) |
544 fnotin :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50) |
496 where |
545 where |
497 "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)" |
546 "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)" |
498 |
547 |
499 section {* Other constants on the Quotient Type *} |
548 section {* Other constants on the Quotient Type *} |
500 |
549 |
501 quotient_definition |
550 quotient_definition |
502 "fcard :: 'a fset \<Rightarrow> nat" |
551 "fcard :: 'a fset \<Rightarrow> nat" |
503 is |
552 is |
504 "fcard_raw" |
553 "fcard_raw" |
505 |
554 |
506 quotient_definition |
555 quotient_definition |
507 "fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset" |
556 "fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset" |
508 is |
557 is |
509 "map" |
558 "map" |
510 |
559 |
511 quotient_definition |
560 quotient_definition |
512 "fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset" |
561 "fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset" |
513 is "delete_raw" |
562 is "delete_raw" |
514 |
563 |
515 quotient_definition |
564 quotient_definition |
516 "fset_to_set :: 'a fset \<Rightarrow> 'a set" |
565 "fset_to_set :: 'a fset \<Rightarrow> 'a set" |
517 is "set" |
566 is "set" |
518 |
567 |
519 quotient_definition |
568 quotient_definition |
520 "ffold :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b" |
569 "ffold :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b" |
521 is "ffold_raw" |
570 is "ffold_raw" |
522 |
571 |
523 quotient_definition |
572 quotient_definition |
524 "fconcat :: ('a fset) fset \<Rightarrow> 'a fset" |
573 "fconcat :: ('a fset) fset \<Rightarrow> 'a fset" |
525 is |
574 is |
526 "concat" |
575 "concat" |
|
576 |
|
577 quotient_definition |
|
578 "ffilter :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset" |
|
579 is |
|
580 "filter" |
527 |
581 |
528 text {* Compositional Respectfullness and Preservation *} |
582 text {* Compositional Respectfullness and Preservation *} |
529 |
583 |
530 lemma [quot_respect]: "(list_rel op \<approx> OOO op \<approx>) [] []" |
584 lemma [quot_respect]: "(list_rel op \<approx> OOO op \<approx>) [] []" |
531 by (fact compose_list_refl) |
585 by (fact compose_list_refl) |
699 lemma cons_left_idem: |
757 lemma cons_left_idem: |
700 "x # x # xs \<approx> x # xs" |
758 "x # x # xs \<approx> x # xs" |
701 by auto |
759 by auto |
702 |
760 |
703 lemma fset_raw_strong_cases: |
761 lemma fset_raw_strong_cases: |
704 "(xs = []) \<or> (\<exists>x ys. ((\<not> memb x ys) \<and> (xs \<approx> x # ys)))" |
762 obtains "xs = []" |
705 apply (induct xs) |
763 | x ys where "\<not> memb x ys" and "xs \<approx> x # ys" |
706 apply (simp) |
764 proof (induct xs arbitrary: x ys) |
707 apply (rule disjI2) |
765 case Nil |
708 apply (erule disjE) |
766 then show thesis by simp |
709 apply (rule_tac x="a" in exI) |
767 next |
710 apply (rule_tac x="[]" in exI) |
768 case (Cons a xs) |
711 apply (simp add: memb_def) |
769 have a: "\<lbrakk>xs = [] \<Longrightarrow> thesis; \<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis" by fact |
712 apply (erule exE)+ |
770 have b: "\<And>x' ys'. \<lbrakk>\<not> memb x' ys'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact |
713 apply (case_tac "x = a") |
771 have c: "xs = [] \<Longrightarrow> thesis" by (metis no_memb_nil singleton_list_eq b) |
714 apply (rule_tac x="a" in exI) |
772 have "\<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis" |
715 apply (rule_tac x="ys" in exI) |
773 proof - |
716 apply (simp) |
774 fix x :: 'a |
717 apply (rule_tac x="x" in exI) |
775 fix ys :: "'a list" |
718 apply (rule_tac x="a # ys" in exI) |
776 assume d:"\<not> memb x ys" |
719 apply (auto simp add: memb_def) |
777 assume e:"xs \<approx> x # ys" |
720 done |
778 show thesis |
|
779 proof (cases "x = a") |
|
780 assume h: "x = a" |
|
781 then have f: "\<not> memb a ys" using d by simp |
|
782 have g: "a # xs \<approx> a # ys" using e h by auto |
|
783 show thesis using b f g by simp |
|
784 next |
|
785 assume h: "x \<noteq> a" |
|
786 then have f: "\<not> memb x (a # ys)" using d unfolding memb_def by auto |
|
787 have g: "a # xs \<approx> x # (a # ys)" using e h by auto |
|
788 show thesis using b f g by simp |
|
789 qed |
|
790 qed |
|
791 then show thesis using a c by blast |
|
792 qed |
721 |
793 |
722 section {* deletion *} |
794 section {* deletion *} |
723 |
795 |
724 lemma memb_delete_raw_ident: |
796 lemma memb_delete_raw_ident: |
725 shows "\<not> memb x (delete_raw xs x)" |
797 shows "\<not> memb x (delete_raw xs x)" |
810 then show ?case using z list_eq2_refl by simp |
882 then show ?case using z list_eq2_refl by simp |
811 next |
883 next |
812 case (Suc m) |
884 case (Suc m) |
813 have b: "l \<approx> r" by fact |
885 have b: "l \<approx> r" by fact |
814 have d: "fcard_raw l = Suc m" by fact |
886 have d: "fcard_raw l = Suc m" by fact |
815 have "\<exists>a. memb a l" by (rule fcard_raw_suc_memb[OF d]) |
887 then have "\<exists>a. memb a l" by (rule fcard_raw_suc_memb) |
816 then obtain a where e: "memb a l" by auto |
888 then obtain a where e: "memb a l" by auto |
817 then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b by auto |
889 then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b by auto |
818 have f: "fcard_raw (delete_raw l a) = m" using fcard_raw_delete[of l a] e d by simp |
890 have f: "fcard_raw (delete_raw l a) = m" using fcard_raw_delete[of l a] e d by simp |
819 have g: "delete_raw l a \<approx> delete_raw r a" using delete_raw_rsp[OF b] by simp |
891 have g: "delete_raw l a \<approx> delete_raw r a" using delete_raw_rsp[OF b] by simp |
820 have g': "list_eq2 (delete_raw l a) (delete_raw r a)" by (rule Suc.hyps[OF f g]) |
892 have "list_eq2 (delete_raw l a) (delete_raw r a)" by (rule Suc.hyps[OF f g]) |
821 have h: "list_eq2 (a # delete_raw l a) (a # delete_raw r a)" by (rule list_eq2.intros(5)[OF g']) |
893 then have h: "list_eq2 (a # delete_raw l a) (a # delete_raw r a)" by (rule list_eq2.intros(5)) |
822 have i: "list_eq2 l (a # delete_raw l a)" |
894 have i: "list_eq2 l (a # delete_raw l a)" |
823 by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]]) |
895 by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]]) |
824 have "list_eq2 l (a # delete_raw r a)" by (rule list_eq2.intros(6)[OF i h]) |
896 have "list_eq2 l (a # delete_raw r a)" by (rule list_eq2.intros(6)[OF i h]) |
825 then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp |
897 then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp |
826 qed |
898 qed |
827 } |
899 } |
828 then show "l \<approx> r \<Longrightarrow> list_eq2 l r" by blast |
900 then show "l \<approx> r \<Longrightarrow> list_eq2 l r" by blast |
829 qed |
901 qed |
830 |
902 |
|
903 text {* Set *} |
|
904 |
|
905 lemma sub_list_set: "sub_list xs ys = (set xs \<subseteq> set ys)" |
|
906 by (metis rev_append set_append set_cong set_rev sub_list_append sub_list_append_left sub_list_def sub_list_not_eq subset_Un_eq) |
|
907 |
|
908 lemma sub_list_neq_set: "(sub_list xs ys \<and> \<not> list_eq xs ys) = (set xs \<subset> set ys)" |
|
909 by (auto simp add: sub_list_set) |
|
910 |
|
911 lemma fcard_raw_set: "fcard_raw xs = card (set xs)" |
|
912 by (induct xs) (auto simp add: insert_absorb memb_def card_insert_disjoint finite_set) |
|
913 |
|
914 lemma memb_set: "memb x xs = (x \<in> set xs)" |
|
915 by (simp only: memb_def) |
|
916 |
|
917 lemma filter_set: "set (filter P xs) = P \<inter> (set xs)" |
|
918 by (induct xs, simp) |
|
919 (metis Int_insert_right_if0 Int_insert_right_if1 List.set.simps(2) filter.simps(2) mem_def) |
|
920 |
|
921 lemma delete_raw_set: "set (delete_raw xs x) = set xs - {x}" |
|
922 by (induct xs) auto |
|
923 |
|
924 lemma inter_raw_set: "set (finter_raw xs ys) = set xs \<inter> set ys" |
|
925 by (induct xs) (simp_all add: memb_def) |
|
926 |
|
927 lemma fminus_raw_set: "set (fminus_raw xs ys) = set xs - set ys" |
|
928 by (induct ys arbitrary: xs) |
|
929 (simp_all add: fminus_raw.simps delete_raw_set, blast) |
|
930 |
|
931 text {* Raw theorems of ffilter *} |
|
932 |
|
933 lemma sub_list_filter: "sub_list (filter P xs) (filter Q xs) = (\<forall> x. memb x xs \<longrightarrow> P x \<longrightarrow> Q x)" |
|
934 unfolding sub_list_def memb_def by auto |
|
935 |
|
936 lemma list_eq_filter: "list_eq (filter P xs) (filter Q xs) = (\<forall>x. memb x xs \<longrightarrow> P x = Q x)" |
|
937 unfolding memb_def by auto |
|
938 |
831 text {* Lifted theorems *} |
939 text {* Lifted theorems *} |
832 |
940 |
833 lemma not_fin_fnil: "x |\<notin>| {||}" |
941 lemma not_fin_fnil: "x |\<notin>| {||}" |
834 by (lifting not_memb_nil) |
942 by (lifting not_memb_nil) |
835 |
943 |
897 |
1005 |
898 lemma fcard_1: |
1006 lemma fcard_1: |
899 shows "(fcard S = 1) = (\<exists>x. S = {|x|})" |
1007 shows "(fcard S = 1) = (\<exists>x. S = {|x|})" |
900 by (lifting fcard_raw_1) |
1008 by (lifting fcard_raw_1) |
901 |
1009 |
902 lemma fcard_gt_0: |
1010 lemma fcard_gt_0: |
903 shows "x \<in> fset_to_set S \<Longrightarrow> 0 < fcard S" |
1011 shows "x \<in> fset_to_set S \<Longrightarrow> 0 < fcard S" |
904 by (lifting fcard_raw_gt_0) |
1012 by (lifting fcard_raw_gt_0) |
905 |
1013 |
906 lemma fcard_not_fin: |
1014 lemma fcard_not_fin: |
907 shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))" |
1015 shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))" |
908 by (lifting fcard_raw_not_memb) |
1016 by (lifting fcard_raw_not_memb) |
909 |
1017 |
910 lemma fcard_suc: "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n" |
1018 lemma fcard_suc: "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n" |
911 by (lifting fcard_raw_suc) |
1019 by (lifting fcard_raw_suc) |
920 lemma fin_fcard_not_0: "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0" |
1028 lemma fin_fcard_not_0: "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0" |
921 by (lifting memb_card_not_0) |
1029 by (lifting memb_card_not_0) |
922 |
1030 |
923 text {* funion *} |
1031 text {* funion *} |
924 |
1032 |
925 lemma funion_simps[simp]: |
1033 lemmas [simp] = |
926 shows "{||} |\<union>| S = S" |
1034 sup_bot_left[where 'a="'a fset", standard] |
927 and "finsert x S |\<union>| T = finsert x (S |\<union>| T)" |
1035 sup_bot_right[where 'a="'a fset", standard] |
928 by (lifting append.simps) |
1036 |
929 |
1037 lemma funion_finsert[simp]: |
930 lemma funion_empty[simp]: |
1038 shows "finsert x S |\<union>| T = finsert x (S |\<union>| T)" |
931 shows "S |\<union>| {||} = S" |
1039 by (lifting append.simps(2)) |
932 by (lifting append_Nil2) |
|
933 |
1040 |
934 lemma singleton_union_left: |
1041 lemma singleton_union_left: |
935 "{|a|} |\<union>| S = finsert a S" |
1042 "{|a|} |\<union>| S = finsert a S" |
936 by simp |
1043 by simp |
937 |
1044 |
940 by (subst sup.commute) simp |
1047 by (subst sup.commute) simp |
941 |
1048 |
942 section {* Induction and Cases rules for finite sets *} |
1049 section {* Induction and Cases rules for finite sets *} |
943 |
1050 |
944 lemma fset_strong_cases: |
1051 lemma fset_strong_cases: |
945 "S = {||} \<or> (\<exists>x T. x |\<notin>| T \<and> S = finsert x T)" |
1052 obtains "xs = {||}" |
|
1053 | x ys where "x |\<notin>| ys" and "xs = finsert x ys" |
946 by (lifting fset_raw_strong_cases) |
1054 by (lifting fset_raw_strong_cases) |
947 |
1055 |
948 lemma fset_exhaust[case_names fempty finsert, cases type: fset]: |
1056 lemma fset_exhaust[case_names fempty finsert, cases type: fset]: |
949 shows "\<lbrakk>S = {||} \<Longrightarrow> P; \<And>x S'. S = finsert x S' \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
1057 shows "\<lbrakk>S = {||} \<Longrightarrow> P; \<And>x S'. S = finsert x S' \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
950 by (lifting list.exhaust) |
1058 by (lifting list.exhaust) |
952 lemma fset_induct_weak[case_names fempty finsert]: |
1060 lemma fset_induct_weak[case_names fempty finsert]: |
953 shows "\<lbrakk>P {||}; \<And>x S. P S \<Longrightarrow> P (finsert x S)\<rbrakk> \<Longrightarrow> P S" |
1061 shows "\<lbrakk>P {||}; \<And>x S. P S \<Longrightarrow> P (finsert x S)\<rbrakk> \<Longrightarrow> P S" |
954 by (lifting list.induct) |
1062 by (lifting list.induct) |
955 |
1063 |
956 lemma fset_induct[case_names fempty finsert, induct type: fset]: |
1064 lemma fset_induct[case_names fempty finsert, induct type: fset]: |
957 assumes prem1: "P {||}" |
1065 assumes prem1: "P {||}" |
958 and prem2: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (finsert x S)" |
1066 and prem2: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (finsert x S)" |
959 shows "P S" |
1067 shows "P S" |
960 proof(induct S rule: fset_induct_weak) |
1068 proof(induct S rule: fset_induct_weak) |
961 case fempty |
1069 case fempty |
962 show "P {||}" by (rule prem1) |
1070 show "P {||}" by (rule prem1) |
978 apply simp_all |
1086 apply simp_all |
979 apply (induct_tac xa rule: fset_induct) |
1087 apply (induct_tac xa rule: fset_induct) |
980 apply simp_all |
1088 apply simp_all |
981 done |
1089 done |
982 |
1090 |
|
1091 lemma fset_fcard_induct: |
|
1092 assumes a: "P {||}" |
|
1093 and b: "\<And>xs ys. Suc (fcard xs) = (fcard ys) \<Longrightarrow> P xs \<Longrightarrow> P ys" |
|
1094 shows "P zs" |
|
1095 proof (induct zs) |
|
1096 show "P {||}" by (rule a) |
|
1097 next |
|
1098 fix x :: 'a and zs :: "'a fset" |
|
1099 assume h: "P zs" |
|
1100 assume "x |\<notin>| zs" |
|
1101 then have H1: "Suc (fcard zs) = fcard (finsert x zs)" using fcard_suc by auto |
|
1102 then show "P (finsert x zs)" using b h by simp |
|
1103 qed |
|
1104 |
983 text {* fmap *} |
1105 text {* fmap *} |
984 |
1106 |
985 lemma fmap_simps[simp]: |
1107 lemma fmap_simps[simp]: |
986 "fmap (f :: 'a \<Rightarrow> 'b) {||} = {||}" |
1108 "fmap (f :: 'a \<Rightarrow> 'b) {||} = {||}" |
987 "fmap f (finsert x S) = finsert (f x) (fmap f S)" |
1109 "fmap f (finsert x S) = finsert (f x) (fmap f S)" |
988 by (lifting map.simps) |
1110 by (lifting map.simps) |
989 |
1111 |
990 lemma fmap_set_image: |
1112 lemma fmap_set_image: |
991 "fset_to_set (fmap f S) = f ` (fset_to_set S)" |
1113 "fset_to_set (fmap f S) = f ` (fset_to_set S)" |
992 by (induct S) (simp_all) |
1114 by (induct S) simp_all |
993 |
1115 |
994 lemma inj_fmap_eq_iff: |
1116 lemma inj_fmap_eq_iff: |
995 "inj f \<Longrightarrow> (fmap f S = fmap f T) = (S = T)" |
1117 "inj f \<Longrightarrow> (fmap f S = fmap f T) = (S = T)" |
996 by (lifting inj_map_eq_iff) |
1118 by (lifting inj_map_eq_iff) |
997 |
1119 |
1000 |
1122 |
1001 lemma fin_funion: |
1123 lemma fin_funion: |
1002 "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T" |
1124 "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T" |
1003 by (lifting memb_append) |
1125 by (lifting memb_append) |
1004 |
1126 |
|
1127 text {* to_set *} |
|
1128 |
|
1129 lemma fin_set: "(x |\<in>| xs) = (x \<in> fset_to_set xs)" |
|
1130 by (lifting memb_set) |
|
1131 |
|
1132 lemma fnotin_set: "(x |\<notin>| xs) = (x \<notin> fset_to_set xs)" |
|
1133 by (simp add: fin_set) |
|
1134 |
|
1135 lemma fcard_set: "fcard xs = card (fset_to_set xs)" |
|
1136 by (lifting fcard_raw_set) |
|
1137 |
|
1138 lemma fsubseteq_set: "(xs |\<subseteq>| ys) = (fset_to_set xs \<subseteq> fset_to_set ys)" |
|
1139 by (lifting sub_list_set) |
|
1140 |
|
1141 lemma fsubset_set: "(xs |\<subset>| ys) = (fset_to_set xs \<subset> fset_to_set ys)" |
|
1142 unfolding less_fset by (lifting sub_list_neq_set) |
|
1143 |
|
1144 lemma ffilter_set: "fset_to_set (ffilter P xs) = P \<inter> fset_to_set xs" |
|
1145 by (lifting filter_set) |
|
1146 |
|
1147 lemma fdelete_set: "fset_to_set (fdelete xs x) = fset_to_set xs - {x}" |
|
1148 by (lifting delete_raw_set) |
|
1149 |
|
1150 lemma inter_set: "fset_to_set (xs |\<inter>| ys) = fset_to_set xs \<inter> fset_to_set ys" |
|
1151 by (lifting inter_raw_set) |
|
1152 |
|
1153 lemma union_set: "fset_to_set (xs |\<union>| ys) = fset_to_set xs \<union> fset_to_set ys" |
|
1154 by (lifting set_append) |
|
1155 |
|
1156 lemma fminus_set: "fset_to_set (xs - ys) = fset_to_set xs - fset_to_set ys" |
|
1157 by (lifting fminus_raw_set) |
|
1158 |
|
1159 lemmas fset_to_set_trans = |
|
1160 fin_set fnotin_set fcard_set fsubseteq_set fsubset_set |
|
1161 inter_set union_set ffilter_set fset_to_set_simps |
|
1162 fset_cong fdelete_set fmap_set_image fminus_set |
|
1163 |
|
1164 |
1005 text {* ffold *} |
1165 text {* ffold *} |
1006 |
1166 |
1007 lemma ffold_nil: "ffold f z {||} = z" |
1167 lemma ffold_nil: "ffold f z {||} = z" |
1008 by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"]) |
1168 by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"]) |
1009 |
1169 |
1015 "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete b h))" |
1175 "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete b h))" |
1016 by (lifting memb_commute_ffold_raw) |
1176 by (lifting memb_commute_ffold_raw) |
1017 |
1177 |
1018 text {* fdelete *} |
1178 text {* fdelete *} |
1019 |
1179 |
1020 lemma fin_fdelete: |
1180 lemma fin_fdelete: |
1021 shows "x |\<in>| fdelete S y \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y" |
1181 shows "x |\<in>| fdelete S y \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y" |
1022 by (lifting memb_delete_raw) |
1182 by (lifting memb_delete_raw) |
1023 |
1183 |
1024 lemma fin_fdelete_ident: |
1184 lemma fin_fdelete_ident: |
1025 shows "x |\<notin>| fdelete S x" |
1185 shows "x |\<notin>| fdelete S x" |
1026 by (lifting memb_delete_raw_ident) |
1186 by (lifting memb_delete_raw_ident) |
1027 |
1187 |
1028 lemma not_memb_fdelete_ident: |
1188 lemma not_memb_fdelete_ident: |
1029 shows "x |\<notin>| S \<Longrightarrow> fdelete S x = S" |
1189 shows "x |\<notin>| S \<Longrightarrow> fdelete S x = S" |
1030 by (lifting not_memb_delete_raw_ident) |
1190 by (lifting not_memb_delete_raw_ident) |
1031 |
1191 |
1032 lemma fset_fdelete_cases: |
1192 lemma fset_fdelete_cases: |
1033 shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete S x))" |
1193 shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete S x))" |
1057 by (lifting sub_list_def[simplified memb_def[symmetric]]) |
1217 by (lifting sub_list_def[simplified memb_def[symmetric]]) |
1058 |
1218 |
1059 lemma fsubset_fin: "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)" |
1219 lemma fsubset_fin: "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)" |
1060 by (rule meta_eq_to_obj_eq) |
1220 by (rule meta_eq_to_obj_eq) |
1061 (lifting sub_list_def[simplified memb_def[symmetric]]) |
1221 (lifting sub_list_def[simplified memb_def[symmetric]]) |
|
1222 |
|
1223 lemma fminus_fin: "(x |\<in>| xs - ys) = (x |\<in>| xs \<and> x |\<notin>| ys)" |
|
1224 by (lifting fminus_raw_memb) |
|
1225 |
|
1226 lemma fminus_red: "finsert x xs - ys = (if x |\<in>| ys then xs - ys else finsert x (xs - ys))" |
|
1227 by (lifting fminus_raw_red) |
|
1228 |
|
1229 lemma fminus_red_fin[simp]: "x |\<in>| ys \<Longrightarrow> finsert x xs - ys = xs - ys" |
|
1230 by (simp add: fminus_red) |
|
1231 |
|
1232 lemma fminus_red_fnotin[simp]: "x |\<notin>| ys \<Longrightarrow> finsert x xs - ys = finsert x (xs - ys)" |
|
1233 by (simp add: fminus_red) |
1062 |
1234 |
1063 lemma expand_fset_eq: |
1235 lemma expand_fset_eq: |
1064 "(S = T) = (\<forall>x. (x |\<in>| S) = (x |\<in>| T))" |
1236 "(S = T) = (\<forall>x. (x |\<in>| S) = (x |\<in>| T))" |
1065 by (lifting list_eq.simps[simplified memb_def[symmetric]]) |
1237 by (lifting list_eq.simps[simplified memb_def[symmetric]]) |
1066 |
1238 |
1100 by (lifting concat.simps(2)) |
1272 by (lifting concat.simps(2)) |
1101 |
1273 |
1102 lemma "fconcat (xs |\<union>| ys) = fconcat xs |\<union>| fconcat ys" |
1274 lemma "fconcat (xs |\<union>| ys) = fconcat xs |\<union>| fconcat ys" |
1103 by (lifting concat_append) |
1275 by (lifting concat_append) |
1104 |
1276 |
|
1277 text {* ffilter *} |
|
1278 |
|
1279 lemma subseteq_filter: "ffilter P xs <= ffilter Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)" |
|
1280 by (lifting sub_list_filter) |
|
1281 |
|
1282 lemma eq_ffilter: "(ffilter P xs = ffilter Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)" |
|
1283 by (lifting list_eq_filter) |
|
1284 |
|
1285 lemma subset_ffilter: "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> ffilter P xs < ffilter Q xs" |
|
1286 unfolding less_fset by (auto simp add: subseteq_filter eq_ffilter) |
|
1287 |
|
1288 section {* lemmas transferred from Finite_Set theory *} |
|
1289 |
|
1290 text {* finiteness for finite sets holds *} |
|
1291 lemma finite_fset: "finite (fset_to_set S)" |
|
1292 by (induct S) auto |
|
1293 |
|
1294 lemma fset_choice: "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)" |
|
1295 unfolding fset_to_set_trans |
|
1296 by (rule finite_set_choice[simplified Ball_def, OF finite_fset]) |
|
1297 |
|
1298 lemma fsubseteq_fnil: "xs |\<subseteq>| {||} = (xs = {||})" |
|
1299 unfolding fset_to_set_trans |
|
1300 by (rule subset_empty) |
|
1301 |
|
1302 lemma not_fsubset_fnil: "\<not> xs |\<subset>| {||}" |
|
1303 unfolding fset_to_set_trans |
|
1304 by (rule not_psubset_empty) |
|
1305 |
|
1306 lemma fcard_mono: "xs |\<subseteq>| ys \<Longrightarrow> fcard xs \<le> fcard ys" |
|
1307 unfolding fset_to_set_trans |
|
1308 by (rule card_mono[OF finite_fset]) |
|
1309 |
|
1310 lemma fcard_fseteq: "xs |\<subseteq>| ys \<Longrightarrow> fcard ys \<le> fcard xs \<Longrightarrow> xs = ys" |
|
1311 unfolding fset_to_set_trans |
|
1312 by (rule card_seteq[OF finite_fset]) |
|
1313 |
|
1314 lemma psubset_fcard_mono: "xs |\<subset>| ys \<Longrightarrow> fcard xs < fcard ys" |
|
1315 unfolding fset_to_set_trans |
|
1316 by (rule psubset_card_mono[OF finite_fset]) |
|
1317 |
|
1318 lemma fcard_funion_finter: "fcard xs + fcard ys = fcard (xs |\<union>| ys) + fcard (xs |\<inter>| ys)" |
|
1319 unfolding fset_to_set_trans |
|
1320 by (rule card_Un_Int[OF finite_fset finite_fset]) |
|
1321 |
|
1322 lemma fcard_funion_disjoint: "xs |\<inter>| ys = {||} \<Longrightarrow> fcard (xs |\<union>| ys) = fcard xs + fcard ys" |
|
1323 unfolding fset_to_set_trans |
|
1324 by (rule card_Un_disjoint[OF finite_fset finite_fset]) |
|
1325 |
|
1326 lemma fcard_delete1_less: "x |\<in>| xs \<Longrightarrow> fcard (fdelete xs x) < fcard xs" |
|
1327 unfolding fset_to_set_trans |
|
1328 by (rule card_Diff1_less[OF finite_fset]) |
|
1329 |
|
1330 lemma fcard_delete2_less: "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete (fdelete xs x) y) < fcard xs" |
|
1331 unfolding fset_to_set_trans |
|
1332 by (rule card_Diff2_less[OF finite_fset]) |
|
1333 |
|
1334 lemma fcard_delete1_le: "fcard (fdelete xs x) <= fcard xs" |
|
1335 unfolding fset_to_set_trans |
|
1336 by (rule card_Diff1_le[OF finite_fset]) |
|
1337 |
|
1338 lemma fcard_psubset: "ys |\<subseteq>| xs \<Longrightarrow> fcard ys < fcard xs \<Longrightarrow> ys |\<subset>| xs" |
|
1339 unfolding fset_to_set_trans |
|
1340 by (rule card_psubset[OF finite_fset]) |
|
1341 |
|
1342 lemma fcard_fmap_le: "fcard (fmap f xs) \<le> fcard xs" |
|
1343 unfolding fset_to_set_trans |
|
1344 by (rule card_image_le[OF finite_fset]) |
|
1345 |
|
1346 lemma fin_fminus_fnotin: "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S" |
|
1347 unfolding fset_to_set_trans |
|
1348 by blast |
|
1349 |
|
1350 lemma fin_fnotin_fminus: "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S" |
|
1351 unfolding fset_to_set_trans |
|
1352 by blast |
|
1353 |
|
1354 lemma fin_mdef: "x |\<in>| F = ((x |\<notin>| (F - {|x|})) & (F = finsert x (F - {|x|})))" |
|
1355 unfolding fset_to_set_trans |
|
1356 by blast |
|
1357 |
|
1358 lemma fcard_fminus_finsert[simp]: |
|
1359 assumes "a |\<in>| A" and "a |\<notin>| B" |
|
1360 shows "fcard(A - finsert a B) = fcard(A - B) - 1" |
|
1361 using assms unfolding fset_to_set_trans |
|
1362 by (rule card_Diff_insert[OF finite_fset]) |
|
1363 |
|
1364 lemma fcard_fminus_fsubset: |
|
1365 assumes "B |\<subseteq>| A" |
|
1366 shows "fcard (A - B) = fcard A - fcard B" |
|
1367 using assms unfolding fset_to_set_trans |
|
1368 by (rule card_Diff_subset[OF finite_fset]) |
|
1369 |
|
1370 lemma fcard_fminus_subset_finter: |
|
1371 "fcard (A - B) = fcard A - fcard (A |\<inter>| B)" |
|
1372 unfolding fset_to_set_trans |
|
1373 by (rule card_Diff_subset_Int) (fold inter_set, rule finite_fset) |
|
1374 |
|
1375 |
1105 ML {* |
1376 ML {* |
1106 fun dest_fsetT (Type ("FSet.fset", [T])) = T |
1377 fun dest_fsetT (Type (@{type_name fset}, [T])) = T |
1107 | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []); |
1378 | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []); |
1108 *} |
1379 *} |
1109 |
1380 |
1110 no_notation |
1381 no_notation |
1111 list_eq (infix "\<approx>" 50) |
1382 list_eq (infix "\<approx>" 50) |