| author | wenzelm | 
| Wed, 02 Sep 2015 21:54:00 +0200 | |
| changeset 61092 | d261ac466180 | 
| parent 60515 | 484559628038 | 
| child 63167 | 0909deb8059b | 
| permissions | -rw-r--r-- | 
| 47455 | 1 | (* Title: HOL/Quotient_Examples/FSet.thy | 
| 36465 | 2 | Author: Cezary Kaliszyk, TU Munich | 
| 3 | Author: Christian Urban, TU Munich | |
| 36280 | 4 | |
| 41467 | 5 | Type of finite sets. | 
| 36280 | 6 | *) | 
| 36465 | 7 | |
| 54336 
9a21e5c6e5d9
declare Quotient_Examples/FSet.thy as almost obsolete
 kuncar parents: 
53374diff
changeset | 8 | (******************************************************************** | 
| 
9a21e5c6e5d9
declare Quotient_Examples/FSet.thy as almost obsolete
 kuncar parents: 
53374diff
changeset | 9 | WARNING: There is a formalization of 'a fset as a subtype of sets in | 
| 
9a21e5c6e5d9
declare Quotient_Examples/FSet.thy as almost obsolete
 kuncar parents: 
53374diff
changeset | 10 | HOL/Library/FSet.thy using Lifting/Transfer. The user should use | 
| 
9a21e5c6e5d9
declare Quotient_Examples/FSet.thy as almost obsolete
 kuncar parents: 
53374diff
changeset | 11 | that file rather than this file unless there are some very specific | 
| 
9a21e5c6e5d9
declare Quotient_Examples/FSet.thy as almost obsolete
 kuncar parents: 
53374diff
changeset | 12 | reasons. | 
| 
9a21e5c6e5d9
declare Quotient_Examples/FSet.thy as almost obsolete
 kuncar parents: 
53374diff
changeset | 13 | *********************************************************************) | 
| 
9a21e5c6e5d9
declare Quotient_Examples/FSet.thy as almost obsolete
 kuncar parents: 
53374diff
changeset | 14 | |
| 36280 | 15 | theory FSet | 
| 45994 | 16 | imports "~~/src/HOL/Library/Multiset" "~~/src/HOL/Library/Quotient_List" | 
| 36280 | 17 | begin | 
| 18 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 19 | text {* 
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 20 | The type of finite sets is created by a quotient construction | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 21 | over lists. The definition of the equivalence: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 22 | *} | 
| 36280 | 23 | |
| 40467 
dc0439fdd7c5
more appropriate specification packages; fun_rel_def is no simp rule by default
 haftmann parents: 
40034diff
changeset | 24 | definition | 
| 36280 | 25 | list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50) | 
| 26 | where | |
| 40952 | 27 | [simp]: "xs \<approx> ys \<longleftrightarrow> set xs = set ys" | 
| 36280 | 28 | |
| 40822 | 29 | lemma list_eq_reflp: | 
| 30 | "reflp list_eq" | |
| 31 | by (auto intro: reflpI) | |
| 32 | ||
| 33 | lemma list_eq_symp: | |
| 34 | "symp list_eq" | |
| 35 | by (auto intro: sympI) | |
| 36 | ||
| 37 | lemma list_eq_transp: | |
| 38 | "transp list_eq" | |
| 39 | by (auto intro: transpI) | |
| 40 | ||
| 36280 | 41 | lemma list_eq_equivp: | 
| 40822 | 42 | "equivp list_eq" | 
| 43 | by (auto intro: equivpI list_eq_reflp list_eq_symp list_eq_transp) | |
| 36280 | 44 | |
| 40688 
a961ec75fc29
corrected abd4e7358847 where SOMEthing went utterly wrong
 haftmann parents: 
40672diff
changeset | 45 | text {* The @{text fset} type *}
 | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 46 | |
| 36280 | 47 | quotient_type | 
| 48 | 'a fset = "'a list" / "list_eq" | |
| 49 | by (rule list_eq_equivp) | |
| 50 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 51 | text {* 
 | 
| 40953 | 52 | Definitions for sublist, cardinality, | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 53 | intersection, difference and respectful fold over | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 54 | lists. | 
| 39994 
7bd8013b903f
FSet: give names to respectfulness theorems, rename list_all2_refl to avoid clash
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
39302diff
changeset | 55 | *} | 
| 36280 | 56 | |
| 40953 | 57 | declare List.member_def [simp] | 
| 36280 | 58 | |
| 40034 | 59 | definition | 
| 36280 | 60 | sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 61 | where | 
| 40034 | 62 | [simp]: "sub_list xs ys \<longleftrightarrow> set xs \<subseteq> set ys" | 
| 36280 | 63 | |
| 40034 | 64 | definition | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 65 | card_list :: "'a list \<Rightarrow> nat" | 
| 36280 | 66 | where | 
| 40034 | 67 | [simp]: "card_list xs = card (set xs)" | 
| 36675 
806ea6e282e4
fminus and some more theorems ported from Finite_Set.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36646diff
changeset | 68 | |
| 40034 | 69 | definition | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 70 | inter_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" | 
| 36675 
806ea6e282e4
fminus and some more theorems ported from Finite_Set.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36646diff
changeset | 71 | where | 
| 40034 | 72 | [simp]: "inter_list xs ys = [x \<leftarrow> xs. x \<in> set xs \<and> x \<in> set ys]" | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 73 | |
| 40034 | 74 | definition | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 75 | diff_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 76 | where | 
| 40034 | 77 | [simp]: "diff_list xs ys = [x \<leftarrow> xs. x \<notin> set ys]" | 
| 36280 | 78 | |
| 79 | definition | |
| 40954 
ecca598474dd
conventional point-free characterization of rsp_fold
 haftmann parents: 
40953diff
changeset | 80 |   rsp_fold :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> bool"
 | 
| 36280 | 81 | where | 
| 40954 
ecca598474dd
conventional point-free characterization of rsp_fold
 haftmann parents: 
40953diff
changeset | 82 | "rsp_fold f \<longleftrightarrow> (\<forall>u v. f u \<circ> f v = f v \<circ> f u)" | 
| 36280 | 83 | |
| 40961 | 84 | lemma rsp_foldI: | 
| 85 | "(\<And>u v. f u \<circ> f v = f v \<circ> f u) \<Longrightarrow> rsp_fold f" | |
| 86 | by (simp add: rsp_fold_def) | |
| 87 | ||
| 88 | lemma rsp_foldE: | |
| 89 | assumes "rsp_fold f" | |
| 90 | obtains "f u \<circ> f v = f v \<circ> f u" | |
| 91 | using assms by (simp add: rsp_fold_def) | |
| 92 | ||
| 40962 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 93 | definition | 
| 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 94 |   fold_once :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a list \<Rightarrow> 'b \<Rightarrow> 'b"
 | 
| 36280 | 95 | where | 
| 40962 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 96 | "fold_once f xs = (if rsp_fold f then fold f (remdups xs) else id)" | 
| 36280 | 97 | |
| 40962 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 98 | lemma fold_once_default [simp]: | 
| 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 99 | "\<not> rsp_fold f \<Longrightarrow> fold_once f xs = id" | 
| 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 100 | by (simp add: fold_once_def) | 
| 40961 | 101 | |
| 40962 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 102 | lemma fold_once_fold_remdups: | 
| 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 103 | "rsp_fold f \<Longrightarrow> fold_once f xs = fold f (remdups xs)" | 
| 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 104 | by (simp add: fold_once_def) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 105 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 106 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 107 | section {* Quotient composition lemmas *}
 | 
| 36280 | 108 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 109 | lemma list_all2_refl': | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 110 | assumes q: "equivp R" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 111 | shows "(list_all2 R) r r" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 112 | by (rule list_all2_refl) (metis equivp_def q) | 
| 36280 | 113 | |
| 114 | lemma compose_list_refl: | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 115 | assumes q: "equivp R" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 116 | shows "(list_all2 R OOO op \<approx>) r r" | 
| 36280 | 117 | proof | 
| 36465 | 118 | have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp]) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 119 | show "list_all2 R r r" by (rule list_all2_refl'[OF q]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 120 | with * show "(op \<approx> OO list_all2 R) r r" .. | 
| 36280 | 121 | qed | 
| 122 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 123 | lemma map_list_eq_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba" | 
| 40467 
dc0439fdd7c5
more appropriate specification packages; fun_rel_def is no simp rule by default
 haftmann parents: 
40034diff
changeset | 124 | by (simp only: list_eq_def set_map) | 
| 36280 | 125 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 126 | lemma quotient_compose_list_g: | 
| 47308 | 127 | assumes q: "Quotient3 R Abs Rep" | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 128 | and e: "equivp R" | 
| 47308 | 129 | shows "Quotient3 ((list_all2 R) OOO (op \<approx>)) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 130 | (abs_fset \<circ> (map Abs)) ((map Rep) \<circ> rep_fset)" | 
| 47308 | 131 | unfolding Quotient3_def comp_def | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 132 | proof (intro conjI allI) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 133 | fix a r s | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 134 | show "abs_fset (map Abs (map Rep (rep_fset a))) = a" | 
| 47308 | 135 | by (simp add: abs_o_rep[OF q] Quotient3_abs_rep[OF Quotient3_fset] List.map.id) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 136 | have b: "list_all2 R (map Rep (rep_fset a)) (map Rep (rep_fset a))" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 137 | by (rule list_all2_refl'[OF e]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 138 | have c: "(op \<approx> OO list_all2 R) (map Rep (rep_fset a)) (map Rep (rep_fset a))" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 139 | by (rule, rule equivp_reflp[OF fset_equivp]) (rule b) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 140 | show "(list_all2 R OOO op \<approx>) (map Rep (rep_fset a)) (map Rep (rep_fset a))" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 141 | by (rule, rule list_all2_refl'[OF e]) (rule c) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 142 | show "(list_all2 R OOO op \<approx>) r s = ((list_all2 R OOO op \<approx>) r r \<and> | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 143 | (list_all2 R OOO op \<approx>) s s \<and> abs_fset (map Abs r) = abs_fset (map Abs s))" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 144 | proof (intro iffI conjI) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 145 | show "(list_all2 R OOO op \<approx>) r r" by (rule compose_list_refl[OF e]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 146 | show "(list_all2 R OOO op \<approx>) s s" by (rule compose_list_refl[OF e]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 147 | next | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 148 | assume a: "(list_all2 R OOO op \<approx>) r s" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 149 | then have b: "map Abs r \<approx> map Abs s" | 
| 47434 
b75ce48a93ee
dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
 griff parents: 
47198diff
changeset | 150 | proof (elim relcomppE) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 151 | fix b ba | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 152 | assume c: "list_all2 R r b" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 153 | assume d: "b \<approx> ba" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 154 | assume e: "list_all2 R ba s" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 155 | have f: "map Abs r = map Abs b" | 
| 47308 | 156 | using Quotient3_rel[OF list_quotient3[OF q]] c by blast | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 157 | have "map Abs ba = map Abs s" | 
| 47308 | 158 | using Quotient3_rel[OF list_quotient3[OF q]] e by blast | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 159 | then have g: "map Abs s = map Abs ba" by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 160 | then show "map Abs r \<approx> map Abs s" using d f map_list_eq_cong by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 161 | qed | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 162 | then show "abs_fset (map Abs r) = abs_fset (map Abs s)" | 
| 47308 | 163 | using Quotient3_rel[OF Quotient3_fset] by blast | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 164 | next | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 165 | assume a: "(list_all2 R OOO op \<approx>) r r \<and> (list_all2 R OOO op \<approx>) s s | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 166 | \<and> abs_fset (map Abs r) = abs_fset (map Abs s)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 167 | then have s: "(list_all2 R OOO op \<approx>) s s" by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 168 | have d: "map Abs r \<approx> map Abs s" | 
| 47308 | 169 | by (subst Quotient3_rel [OF Quotient3_fset, symmetric]) (simp add: a) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 170 | have b: "map Rep (map Abs r) \<approx> map Rep (map Abs s)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 171 | by (rule map_list_eq_cong[OF d]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 172 | have y: "list_all2 R (map Rep (map Abs s)) s" | 
| 47308 | 173 | by (fact rep_abs_rsp_left[OF list_quotient3[OF q], OF list_all2_refl'[OF e, of s]]) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 174 | have c: "(op \<approx> OO list_all2 R) (map Rep (map Abs r)) s" | 
| 47434 
b75ce48a93ee
dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
 griff parents: 
47198diff
changeset | 175 | by (rule relcomppI) (rule b, rule y) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 176 | have z: "list_all2 R r (map Rep (map Abs r))" | 
| 47308 | 177 | by (fact rep_abs_rsp[OF list_quotient3[OF q], OF list_all2_refl'[OF e, of r]]) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 178 | then show "(list_all2 R OOO op \<approx>) r s" | 
| 47434 
b75ce48a93ee
dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
 griff parents: 
47198diff
changeset | 179 | using a c relcomppI by simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 180 | qed | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 181 | qed | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 182 | |
| 36280 | 183 | lemma quotient_compose_list[quot_thm]: | 
| 47308 | 184 | shows "Quotient3 ((list_all2 op \<approx>) OOO (op \<approx>)) | 
| 36280 | 185 | (abs_fset \<circ> (map abs_fset)) ((map rep_fset) \<circ> rep_fset)" | 
| 47308 | 186 | by (rule quotient_compose_list_g, rule Quotient3_fset, rule list_eq_equivp) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 187 | |
| 36280 | 188 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 189 | section {* Quotient definitions for fsets *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 190 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 191 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 192 | subsection {* Finite sets are a bounded, distributive lattice with minus *}
 | 
| 36280 | 193 | |
| 37634 
2116425cebc8
cleaned by using descending instead of lifting
 Christian Urban <urbanc@in.tum.de> parents: 
37492diff
changeset | 194 | instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
 | 
| 36280 | 195 | begin | 
| 196 | ||
| 197 | quotient_definition | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 198 | "bot :: 'a fset" | 
| 47092 | 199 | is "Nil :: 'a list" done | 
| 36280 | 200 | |
| 201 | abbreviation | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 202 |   empty_fset  ("{||}")
 | 
| 36280 | 203 | where | 
| 204 |   "{||} \<equiv> bot :: 'a fset"
 | |
| 205 | ||
| 206 | quotient_definition | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 207 |   "less_eq_fset :: ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
 | 
| 47092 | 208 |   is "sub_list :: ('a list \<Rightarrow> 'a list \<Rightarrow> bool)" by simp
 | 
| 36280 | 209 | |
| 210 | abbreviation | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 211 | subset_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50) | 
| 36280 | 212 | where | 
| 213 | "xs |\<subseteq>| ys \<equiv> xs \<le> ys" | |
| 214 | ||
| 215 | definition | |
| 39995 | 216 | less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" | 
| 217 | where | |
| 218 | "xs < ys \<equiv> xs \<le> ys \<and> xs \<noteq> (ys::'a fset)" | |
| 36280 | 219 | |
| 220 | abbreviation | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 221 | psubset_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50) | 
| 36280 | 222 | where | 
| 223 | "xs |\<subset>| ys \<equiv> xs < ys" | |
| 224 | ||
| 225 | quotient_definition | |
| 39995 | 226 | "sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" | 
| 47092 | 227 | is "append :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" by simp | 
| 36280 | 228 | |
| 229 | abbreviation | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 230 | union_fset (infixl "|\<union>|" 65) | 
| 36280 | 231 | where | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 232 | "xs |\<union>| ys \<equiv> sup xs (ys::'a fset)" | 
| 36280 | 233 | |
| 234 | quotient_definition | |
| 39995 | 235 | "inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" | 
| 47092 | 236 | is "inter_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" by simp | 
| 36280 | 237 | |
| 238 | abbreviation | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 239 | inter_fset (infixl "|\<inter>|" 65) | 
| 36280 | 240 | where | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 241 | "xs |\<inter>| ys \<equiv> inf xs (ys::'a fset)" | 
| 36280 | 242 | |
| 36675 
806ea6e282e4
fminus and some more theorems ported from Finite_Set.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36646diff
changeset | 243 | quotient_definition | 
| 37634 
2116425cebc8
cleaned by using descending instead of lifting
 Christian Urban <urbanc@in.tum.de> parents: 
37492diff
changeset | 244 | "minus :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" | 
| 47092 | 245 | is "diff_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" by fastforce | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 246 | |
| 36280 | 247 | instance | 
| 248 | proof | |
| 249 | fix x y z :: "'a fset" | |
| 37634 
2116425cebc8
cleaned by using descending instead of lifting
 Christian Urban <urbanc@in.tum.de> parents: 
37492diff
changeset | 250 | show "x |\<subset>| y \<longleftrightarrow> x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x" | 
| 40467 
dc0439fdd7c5
more appropriate specification packages; fun_rel_def is no simp rule by default
 haftmann parents: 
40034diff
changeset | 251 | by (unfold less_fset_def, descending) auto | 
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 252 | show "x |\<subseteq>| x" by (descending) (simp) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 253 |   show "{||} |\<subseteq>| x" by (descending) (simp)
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 254 | show "x |\<subseteq>| x |\<union>| y" by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 255 | show "y |\<subseteq>| x |\<union>| y" by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 256 | show "x |\<inter>| y |\<subseteq>| x" by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 257 | show "x |\<inter>| y |\<subseteq>| y" by (descending) (auto) | 
| 37634 
2116425cebc8
cleaned by using descending instead of lifting
 Christian Urban <urbanc@in.tum.de> parents: 
37492diff
changeset | 258 | show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)" | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 259 | by (descending) (auto) | 
| 36280 | 260 | next | 
| 261 | fix x y z :: "'a fset" | |
| 262 | assume a: "x |\<subseteq>| y" | |
| 263 | assume b: "y |\<subseteq>| z" | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 264 | show "x |\<subseteq>| z" using a b by (descending) (simp) | 
| 36280 | 265 | next | 
| 266 | fix x y :: "'a fset" | |
| 267 | assume a: "x |\<subseteq>| y" | |
| 268 | assume b: "y |\<subseteq>| x" | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 269 | show "x = y" using a b by (descending) (auto) | 
| 36280 | 270 | next | 
| 271 | fix x y z :: "'a fset" | |
| 272 | assume a: "y |\<subseteq>| x" | |
| 273 | assume b: "z |\<subseteq>| x" | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 274 | show "y |\<union>| z |\<subseteq>| x" using a b by (descending) (simp) | 
| 36280 | 275 | next | 
| 276 | fix x y z :: "'a fset" | |
| 277 | assume a: "x |\<subseteq>| y" | |
| 278 | assume b: "x |\<subseteq>| z" | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 279 | show "x |\<subseteq>| y |\<inter>| z" using a b by (descending) (auto) | 
| 36280 | 280 | qed | 
| 281 | ||
| 282 | end | |
| 283 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 284 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 285 | subsection {* Other constants for fsets *}
 | 
| 36280 | 286 | |
| 287 | quotient_definition | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 288 | "insert_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" | 
| 47092 | 289 | is "Cons" by auto | 
| 36280 | 290 | |
| 291 | syntax | |
| 45343 | 292 |   "_insert_fset"     :: "args => 'a fset"  ("{|(_)|}")
 | 
| 36280 | 293 | |
| 294 | translations | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 295 |   "{|x, xs|}" == "CONST insert_fset x {|xs|}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 296 |   "{|x|}"     == "CONST insert_fset x {||}"
 | 
| 36280 | 297 | |
| 298 | quotient_definition | |
| 40953 | 299 | fset_member | 
| 36280 | 300 | where | 
| 47092 | 301 | "fset_member :: 'a fset \<Rightarrow> 'a \<Rightarrow> bool" is "List.member" by fastforce | 
| 40953 | 302 | |
| 303 | abbreviation | |
| 304 | in_fset :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<in>|" 50) | |
| 305 | where | |
| 306 | "x |\<in>| S \<equiv> fset_member S x" | |
| 36280 | 307 | |
| 308 | abbreviation | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 309 | notin_fset :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50) | 
| 36280 | 310 | where | 
| 311 | "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)" | |
| 312 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 313 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 314 | subsection {* Other constants on the Quotient Type *}
 | 
| 36280 | 315 | |
| 316 | quotient_definition | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 317 | "card_fset :: 'a fset \<Rightarrow> nat" | 
| 47092 | 318 | is card_list by simp | 
| 36280 | 319 | |
| 320 | quotient_definition | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 321 |   "map_fset :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
 | 
| 47092 | 322 | is map by simp | 
| 36280 | 323 | |
| 324 | quotient_definition | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 325 | "remove_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" | 
| 47092 | 326 | is removeAll by simp | 
| 36280 | 327 | |
| 328 | quotient_definition | |
| 39996 
c02078ff8691
FSet: definition changes propagated from Nominal and more use of 'descending' tactic
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
39995diff
changeset | 329 | "fset :: 'a fset \<Rightarrow> 'a set" | 
| 47092 | 330 | is "set" by simp | 
| 331 | ||
| 332 | lemma fold_once_set_equiv: | |
| 333 | assumes "xs \<approx> ys" | |
| 334 | shows "fold_once f xs = fold_once f ys" | |
| 335 | proof (cases "rsp_fold f") | |
| 336 | case False then show ?thesis by simp | |
| 337 | next | |
| 338 | case True | |
| 339 | then have "\<And>x y. x \<in> set (remdups xs) \<Longrightarrow> y \<in> set (remdups xs) \<Longrightarrow> f x \<circ> f y = f y \<circ> f x" | |
| 340 | by (rule rsp_foldE) | |
| 60515 | 341 | moreover from assms have "mset (remdups xs) = mset (remdups ys)" | 
| 342 | by (simp add: set_eq_iff_mset_remdups_eq) | |
| 47092 | 343 | ultimately have "fold f (remdups xs) = fold f (remdups ys)" | 
| 344 | by (rule fold_multiset_equiv) | |
| 345 | with True show ?thesis by (simp add: fold_once_fold_remdups) | |
| 346 | qed | |
| 36280 | 347 | |
| 348 | quotient_definition | |
| 40961 | 349 |   "fold_fset :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b \<Rightarrow> 'b"
 | 
| 47092 | 350 | is fold_once by (rule fold_once_set_equiv) | 
| 351 | ||
| 352 | lemma concat_rsp_pre: | |
| 353 | assumes a: "list_all2 op \<approx> x x'" | |
| 354 | and b: "x' \<approx> y'" | |
| 355 | and c: "list_all2 op \<approx> y' y" | |
| 356 | and d: "\<exists>x\<in>set x. xa \<in> set x" | |
| 357 | shows "\<exists>x\<in>set y. xa \<in> set x" | |
| 358 | proof - | |
| 359 | obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto | |
| 360 | have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_all2_find_element[OF e a]) | |
| 361 | then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto | |
| 362 | have "ya \<in> set y'" using b h by simp | |
| 363 | then have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" using c by (rule list_all2_find_element) | |
| 364 | then show ?thesis using f i by auto | |
| 365 | qed | |
| 36280 | 366 | |
| 367 | quotient_definition | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 368 |   "concat_fset :: ('a fset) fset \<Rightarrow> 'a fset"
 | 
| 47092 | 369 | is concat | 
| 47434 
b75ce48a93ee
dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
 griff parents: 
47198diff
changeset | 370 | proof (elim relcomppE) | 
| 47092 | 371 | fix a b ba bb | 
| 372 | assume a: "list_all2 op \<approx> a ba" | |
| 373 | with list_symp [OF list_eq_symp] have a': "list_all2 op \<approx> ba a" by (rule sympE) | |
| 374 | assume b: "ba \<approx> bb" | |
| 375 | with list_eq_symp have b': "bb \<approx> ba" by (rule sympE) | |
| 376 | assume c: "list_all2 op \<approx> bb b" | |
| 377 | with list_symp [OF list_eq_symp] have c': "list_all2 op \<approx> b bb" by (rule sympE) | |
| 378 | have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" | |
| 379 | proof | |
| 380 | fix x | |
| 381 | show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" | |
| 382 | proof | |
| 383 | assume d: "\<exists>xa\<in>set a. x \<in> set xa" | |
| 384 | show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d]) | |
| 385 | next | |
| 386 | assume e: "\<exists>xa\<in>set b. x \<in> set xa" | |
| 387 | show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e]) | |
| 388 | qed | |
| 389 | qed | |
| 390 | then show "concat a \<approx> concat b" by auto | |
| 391 | qed | |
| 36280 | 392 | |
| 36639 
6243b49498ea
added function ffilter and some lemmas from Finite_Set to the FSet theory
 bulwahn parents: 
36524diff
changeset | 393 | quotient_definition | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 394 |   "filter_fset :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
 | 
| 47092 | 395 | is filter by force | 
| 36639 
6243b49498ea
added function ffilter and some lemmas from Finite_Set to the FSet theory
 bulwahn parents: 
36524diff
changeset | 396 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 397 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 398 | subsection {* Compositional respectfulness and preservation lemmas *}
 | 
| 36280 | 399 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 400 | lemma Nil_rsp2 [quot_respect]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 401 | shows "(list_all2 op \<approx> OOO op \<approx>) Nil Nil" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 402 | by (rule compose_list_refl, rule list_eq_equivp) | 
| 36280 | 403 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 404 | lemma Cons_rsp2 [quot_respect]: | 
| 39994 
7bd8013b903f
FSet: give names to respectfulness theorems, rename list_all2_refl to avoid clash
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
39302diff
changeset | 405 | shows "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) Cons Cons" | 
| 55945 | 406 | apply (auto intro!: rel_funI) | 
| 47434 
b75ce48a93ee
dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
 griff parents: 
47198diff
changeset | 407 | apply (rule_tac b="x # b" in relcomppI) | 
| 36280 | 408 | apply auto | 
| 47434 
b75ce48a93ee
dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
 griff parents: 
47198diff
changeset | 409 | apply (rule_tac b="x # ba" in relcomppI) | 
| 36280 | 410 | apply auto | 
| 411 | done | |
| 412 | ||
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 413 | lemma Nil_prs2 [quot_preserve]: | 
| 47308 | 414 | assumes "Quotient3 R Abs Rep" | 
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 415 | shows "(Abs \<circ> map f) [] = Abs []" | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 416 | by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 417 | |
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 418 | lemma Cons_prs2 [quot_preserve]: | 
| 47308 | 419 | assumes q: "Quotient3 R1 Abs1 Rep1" | 
| 420 | and r: "Quotient3 R2 Abs2 Rep2" | |
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 421 | shows "(Rep1 ---> (map Rep1 \<circ> Rep2) ---> (Abs2 \<circ> map Abs1)) (op #) = (id ---> Rep2 ---> Abs2) (op #)" | 
| 47308 | 422 | by (auto simp add: fun_eq_iff comp_def Quotient3_abs_rep [OF q]) | 
| 36280 | 423 | |
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 424 | lemma append_prs2 [quot_preserve]: | 
| 47308 | 425 | assumes q: "Quotient3 R1 Abs1 Rep1" | 
| 426 | and r: "Quotient3 R2 Abs2 Rep2" | |
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 427 | shows "((map Rep1 \<circ> Rep2) ---> (map Rep1 \<circ> Rep2) ---> (Abs2 \<circ> map Abs1)) op @ = | 
| 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 428 | (Rep2 ---> Rep2 ---> Abs2) op @" | 
| 46663 | 429 | by (simp add: fun_eq_iff abs_o_rep[OF q] List.map.id) | 
| 36280 | 430 | |
| 37492 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 431 | lemma list_all2_app_l: | 
| 36280 | 432 | assumes a: "reflp R" | 
| 37492 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 433 | and b: "list_all2 R l r" | 
| 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 434 | shows "list_all2 R (z @ l) (z @ r)" | 
| 40822 | 435 | using a b by (induct z) (auto elim: reflpE) | 
| 36280 | 436 | |
| 437 | lemma append_rsp2_pre0: | |
| 37492 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 438 | assumes a:"list_all2 op \<approx> x x'" | 
| 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 439 | shows "list_all2 op \<approx> (x @ z) (x' @ z)" | 
| 36280 | 440 | using a apply (induct x x' rule: list_induct2') | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 441 | by simp_all (rule list_all2_refl'[OF list_eq_equivp]) | 
| 36280 | 442 | |
| 443 | lemma append_rsp2_pre1: | |
| 37492 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 444 | assumes a:"list_all2 op \<approx> x x'" | 
| 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 445 | shows "list_all2 op \<approx> (z @ x) (z @ x')" | 
| 36280 | 446 | using a apply (induct x x' arbitrary: z rule: list_induct2') | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 447 | apply (rule list_all2_refl'[OF list_eq_equivp]) | 
| 40467 
dc0439fdd7c5
more appropriate specification packages; fun_rel_def is no simp rule by default
 haftmann parents: 
40034diff
changeset | 448 | apply (simp_all del: list_eq_def) | 
| 37492 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 449 | apply (rule list_all2_app_l) | 
| 40822 | 450 | apply (simp_all add: reflpI) | 
| 36280 | 451 | done | 
| 452 | ||
| 453 | lemma append_rsp2_pre: | |
| 40822 | 454 | assumes "list_all2 op \<approx> x x'" | 
| 455 | and "list_all2 op \<approx> z z'" | |
| 37492 
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36675diff
changeset | 456 | shows "list_all2 op \<approx> (x @ z) (x' @ z')" | 
| 40822 | 457 | using assms by (rule list_all2_appendI) | 
| 36280 | 458 | |
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 459 | lemma compositional_rsp3: | 
| 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 460 | assumes "(R1 ===> R2 ===> R3) C C" and "(R4 ===> R5 ===> R6) C C" | 
| 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 461 | shows "(R1 OOO R4 ===> R2 OOO R5 ===> R3 OOO R6) C C" | 
| 55945 | 462 | by (auto intro!: rel_funI) | 
| 463 | (metis (full_types) assms rel_funE relcomppI) | |
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 464 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 465 | lemma append_rsp2 [quot_respect]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 466 | "(list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) append append" | 
| 47092 | 467 | by (intro compositional_rsp3) | 
| 55945 | 468 | (auto intro!: rel_funI simp add: append_rsp2_pre) | 
| 36280 | 469 | |
| 46404 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 470 | lemma map_rsp2 [quot_respect]: | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 471 | "((op \<approx> ===> op \<approx>) ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) map map" | 
| 55945 | 472 | proof (auto intro!: rel_funI) | 
| 46404 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 473 | fix f f' :: "'a list \<Rightarrow> 'b list" | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 474 | fix xa ya x y :: "'a list list" | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 475 | assume fs: "(op \<approx> ===> op \<approx>) f f'" and x: "list_all2 op \<approx> xa x" and xy: "set x = set y" and y: "list_all2 op \<approx> y ya" | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 476 | have a: "(list_all2 op \<approx>) (map f xa) (map f x)" | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 477 | using x | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 478 | by (induct xa x rule: list_induct2') | 
| 55945 | 479 | (simp_all, metis fs rel_funE list_eq_def) | 
| 46404 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 480 | have b: "set (map f x) = set (map f y)" | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 481 | using xy fs | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 482 | by (induct x y rule: list_induct2') | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 483 | (simp_all, metis image_insert) | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 484 | have c: "(list_all2 op \<approx>) (map f y) (map f' ya)" | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 485 | using y fs | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 486 | by (induct y ya rule: list_induct2') | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 487 | (simp_all, metis apply_rsp' list_eq_def) | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 488 | show "(list_all2 op \<approx> OOO op \<approx>) (map f xa) (map f' ya)" | 
| 47434 
b75ce48a93ee
dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
 griff parents: 
47198diff
changeset | 489 | by (metis a b c list_eq_def relcomppI) | 
| 46404 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 490 | qed | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 491 | |
| 46404 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 492 | lemma map_prs2 [quot_preserve]: | 
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 493 | shows "((abs_fset ---> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> abs_fset \<circ> map abs_fset) map = (id ---> rep_fset ---> abs_fset) map" | 
| 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 494 | by (auto simp add: fun_eq_iff) | 
| 47308 | 495 | (simp only: map_map[symmetric] map_prs_aux[OF Quotient3_fset Quotient3_fset]) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 496 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 497 | section {* Lifted theorems *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 498 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 499 | subsection {* fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 500 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 501 | lemma fset_simps [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 502 |   shows "fset {||} = {}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 503 | and "fset (insert_fset x S) = insert x (fset S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 504 | by (descending, simp)+ | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 505 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 506 | lemma finite_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 507 | shows "finite (fset S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 508 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 509 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 510 | lemma fset_cong: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 511 | shows "fset S = fset T \<longleftrightarrow> S = T" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 512 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 513 | |
| 44204 
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
41467diff
changeset | 514 | lemma filter_fset [simp]: | 
| 
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
41467diff
changeset | 515 | shows "fset (filter_fset P xs) = Collect P \<inter> fset xs" | 
| 
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
41467diff
changeset | 516 | by (descending) (auto) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 517 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 518 | lemma remove_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 519 |   shows "fset (remove_fset x xs) = fset xs - {x}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 520 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 521 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 522 | lemma inter_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 523 | shows "fset (xs |\<inter>| ys) = fset xs \<inter> fset ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 524 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 525 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 526 | lemma union_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 527 | shows "fset (xs |\<union>| ys) = fset xs \<union> fset ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 528 | by (lifting set_append) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 529 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 530 | lemma minus_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 531 | shows "fset (xs - ys) = fset xs - fset ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 532 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 533 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 534 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 535 | subsection {* in_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 536 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 537 | lemma in_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 538 | shows "x |\<in>| S \<longleftrightarrow> x \<in> fset S" | 
| 40953 | 539 | by descending simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 540 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 541 | lemma notin_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 542 | shows "x |\<notin>| S \<longleftrightarrow> x \<notin> fset S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 543 | by (simp add: in_fset) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 544 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 545 | lemma notin_empty_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 546 |   shows "x |\<notin>| {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 547 | by (simp add: in_fset) | 
| 36280 | 548 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 549 | lemma fset_eq_iff: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 550 | shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))" | 
| 40953 | 551 | by descending auto | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 552 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 553 | lemma none_in_empty_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 554 |   shows "(\<forall>x. x |\<notin>| S) \<longleftrightarrow> S = {||}"
 | 
| 40953 | 555 | by descending simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 556 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 557 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 558 | subsection {* insert_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 559 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 560 | lemma in_insert_fset_iff [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 561 | shows "x |\<in>| insert_fset y S \<longleftrightarrow> x = y \<or> x |\<in>| S" | 
| 40953 | 562 | by descending simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 563 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 564 | lemma | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 565 | shows insert_fsetI1: "x |\<in>| insert_fset x S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 566 | and insert_fsetI2: "x |\<in>| S \<Longrightarrow> x |\<in>| insert_fset y S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 567 | by simp_all | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 568 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 569 | lemma insert_absorb_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 570 | shows "x |\<in>| S \<Longrightarrow> insert_fset x S = S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 571 | by (descending) (auto) | 
| 36280 | 572 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 573 | lemma empty_not_insert_fset[simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 574 |   shows "{||} \<noteq> insert_fset x S"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 575 |   and   "insert_fset x S \<noteq> {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 576 | by (descending, simp)+ | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 577 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 578 | lemma insert_fset_left_comm: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 579 | shows "insert_fset x (insert_fset y S) = insert_fset y (insert_fset x S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 580 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 581 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 582 | lemma insert_fset_left_idem: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 583 | shows "insert_fset x (insert_fset x S) = insert_fset x S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 584 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 585 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 586 | lemma singleton_fset_eq[simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 587 |   shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 588 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 589 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 590 | lemma in_fset_mdef: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 591 |   shows "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = insert_fset x (F - {|x|})"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 592 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 593 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 594 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 595 | subsection {* union_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 596 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 597 | lemmas [simp] = | 
| 45605 | 598 | sup_bot_left[where 'a="'a fset"] | 
| 599 | sup_bot_right[where 'a="'a fset"] | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 600 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 601 | lemma union_insert_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 602 | shows "insert_fset x S |\<union>| T = insert_fset x (S |\<union>| T)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 603 | by (lifting append.simps(2)) | 
| 36280 | 604 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 605 | lemma singleton_union_fset_left: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 606 |   shows "{|a|} |\<union>| S = insert_fset a S"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 607 | by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 608 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 609 | lemma singleton_union_fset_right: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 610 |   shows "S |\<union>| {|a|} = insert_fset a S"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 611 | by (subst sup.commute) simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 612 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 613 | lemma in_union_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 614 | shows "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 615 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 616 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 617 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 618 | subsection {* minus_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 619 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 620 | lemma minus_in_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 621 | shows "x |\<in>| (xs - ys) \<longleftrightarrow> x |\<in>| xs \<and> x |\<notin>| ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 622 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 623 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 624 | lemma minus_insert_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 625 | shows "insert_fset x xs - ys = (if x |\<in>| ys then xs - ys else insert_fset x (xs - ys))" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 626 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 627 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 628 | lemma minus_insert_in_fset[simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 629 | shows "x |\<in>| ys \<Longrightarrow> insert_fset x xs - ys = xs - ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 630 | by (simp add: minus_insert_fset) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 631 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 632 | lemma minus_insert_notin_fset[simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 633 | shows "x |\<notin>| ys \<Longrightarrow> insert_fset x xs - ys = insert_fset x (xs - ys)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 634 | by (simp add: minus_insert_fset) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 635 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 636 | lemma in_minus_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 637 | shows "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 638 | unfolding in_fset minus_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 639 | by blast | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 640 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 641 | lemma notin_minus_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 642 | shows "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 643 | unfolding in_fset minus_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 644 | by blast | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 645 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 646 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 647 | subsection {* remove_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 648 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 649 | lemma in_remove_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 650 | shows "x |\<in>| remove_fset y S \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 651 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 652 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 653 | lemma notin_remove_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 654 | shows "x |\<notin>| remove_fset x S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 655 | by (descending) (simp) | 
| 36280 | 656 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 657 | lemma notin_remove_ident_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 658 | shows "x |\<notin>| S \<Longrightarrow> remove_fset x S = S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 659 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 660 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 661 | lemma remove_fset_cases: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 662 |   shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = insert_fset x (remove_fset x S))"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 663 | by (descending) (auto simp add: insert_absorb) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 664 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 665 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 666 | subsection {* inter_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 667 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 668 | lemma inter_empty_fset_l: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 669 |   shows "{||} |\<inter>| S = {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 670 | by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 671 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 672 | lemma inter_empty_fset_r: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 673 |   shows "S |\<inter>| {||} = {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 674 | by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 675 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 676 | lemma inter_insert_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 677 | shows "insert_fset x S |\<inter>| T = (if x |\<in>| T then insert_fset x (S |\<inter>| T) else S |\<inter>| T)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 678 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 679 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 680 | lemma in_inter_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 681 | shows "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 682 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 683 | |
| 36280 | 684 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 685 | subsection {* subset_fset and psubset_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 686 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 687 | lemma subset_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 688 | shows "xs |\<subseteq>| ys \<longleftrightarrow> fset xs \<subseteq> fset ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 689 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 690 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 691 | lemma psubset_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 692 | shows "xs |\<subset>| ys \<longleftrightarrow> fset xs \<subset> fset ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 693 | unfolding less_fset_def | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 694 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 695 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 696 | lemma subset_insert_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 697 | shows "(insert_fset x xs) |\<subseteq>| ys \<longleftrightarrow> x |\<in>| ys \<and> xs |\<subseteq>| ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 698 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 699 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 700 | lemma subset_in_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 701 | shows "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 702 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 703 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 704 | lemma subset_empty_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 705 |   shows "xs |\<subseteq>| {||} \<longleftrightarrow> xs = {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 706 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 707 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 708 | lemma not_psubset_empty_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 709 |   shows "\<not> xs |\<subset>| {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 710 | by (metis fset_simps(1) psubset_fset not_psubset_empty) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 711 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 712 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 713 | subsection {* map_fset *}
 | 
| 36280 | 714 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 715 | lemma map_fset_simps [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 716 |    shows "map_fset f {||} = {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 717 | and "map_fset f (insert_fset x S) = insert_fset (f x) (map_fset f S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 718 | by (descending, simp)+ | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 719 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 720 | lemma map_fset_image [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 721 | shows "fset (map_fset f S) = f ` (fset S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 722 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 723 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 724 | lemma inj_map_fset_cong: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 725 | shows "inj f \<Longrightarrow> map_fset f S = map_fset f T \<longleftrightarrow> S = T" | 
| 40467 
dc0439fdd7c5
more appropriate specification packages; fun_rel_def is no simp rule by default
 haftmann parents: 
40034diff
changeset | 726 | by (descending) (metis inj_vimage_image_eq list_eq_def set_map) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 727 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 728 | lemma map_union_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 729 | shows "map_fset f (S |\<union>| T) = map_fset f S |\<union>| map_fset f T" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 730 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 731 | |
| 51371 | 732 | lemma in_fset_map_fset[simp]: "a |\<in>| map_fset f X = (\<exists>b. b |\<in>| X \<and> a = f b)" | 
| 733 | by descending auto | |
| 734 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 735 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 736 | subsection {* card_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 737 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 738 | lemma card_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 739 | shows "card_fset xs = card (fset xs)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 740 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 741 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 742 | lemma card_insert_fset_iff [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 743 | shows "card_fset (insert_fset x S) = (if x |\<in>| S then card_fset S else Suc (card_fset S))" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 744 | by (descending) (simp add: insert_absorb) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 745 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 746 | lemma card_fset_0[simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 747 |   shows "card_fset S = 0 \<longleftrightarrow> S = {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 748 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 749 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 750 | lemma card_empty_fset[simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 751 |   shows "card_fset {||} = 0"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 752 | by (simp add: card_fset) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 753 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 754 | lemma card_fset_1: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 755 |   shows "card_fset S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 756 | by (descending) (auto simp add: card_Suc_eq) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 757 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 758 | lemma card_fset_gt_0: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 759 | shows "x \<in> fset S \<Longrightarrow> 0 < card_fset S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 760 | by (descending) (auto simp add: card_gt_0_iff) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 761 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 762 | lemma card_notin_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 763 | shows "(x |\<notin>| S) = (card_fset (insert_fset x S) = Suc (card_fset S))" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 764 | by simp | 
| 36280 | 765 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 766 | lemma card_fset_Suc: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 767 | shows "card_fset S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = insert_fset x T \<and> card_fset T = n" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 768 | apply(descending) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 769 | apply(auto dest!: card_eq_SucD) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 770 | by (metis Diff_insert_absorb set_removeAll) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 771 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 772 | lemma card_remove_fset_iff [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 773 | shows "card_fset (remove_fset y S) = (if y |\<in>| S then card_fset S - 1 else card_fset S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 774 | by (descending) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 775 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 776 | lemma card_Suc_exists_in_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 777 | shows "card_fset S = Suc n \<Longrightarrow> \<exists>a. a |\<in>| S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 778 | by (drule card_fset_Suc) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 779 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 780 | lemma in_card_fset_not_0: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 781 | shows "a |\<in>| A \<Longrightarrow> card_fset A \<noteq> 0" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 782 | by (descending) (auto) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 783 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 784 | lemma card_fset_mono: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 785 | shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset xs \<le> card_fset ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 786 | unfolding card_fset psubset_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 787 | by (simp add: card_mono subset_fset) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 788 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 789 | lemma card_subset_fset_eq: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 790 | shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset ys \<le> card_fset xs \<Longrightarrow> xs = ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 791 | unfolding card_fset subset_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 792 | by (auto dest: card_seteq[OF finite_fset] simp add: fset_cong) | 
| 36675 
806ea6e282e4
fminus and some more theorems ported from Finite_Set.
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
36646diff
changeset | 793 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 794 | lemma psubset_card_fset_mono: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 795 | shows "xs |\<subset>| ys \<Longrightarrow> card_fset xs < card_fset ys" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 796 | unfolding card_fset subset_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 797 | by (metis finite_fset psubset_fset psubset_card_mono) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 798 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 799 | lemma card_union_inter_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 800 | shows "card_fset xs + card_fset ys = card_fset (xs |\<union>| ys) + card_fset (xs |\<inter>| ys)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 801 | unfolding card_fset union_fset inter_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 802 | by (rule card_Un_Int[OF finite_fset finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 803 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 804 | lemma card_union_disjoint_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 805 |   shows "xs |\<inter>| ys = {||} \<Longrightarrow> card_fset (xs |\<union>| ys) = card_fset xs + card_fset ys"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 806 | unfolding card_fset union_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 807 | apply (rule card_Un_disjoint[OF finite_fset finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 808 | by (metis inter_fset fset_simps(1)) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 809 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 810 | lemma card_remove_fset_less1: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 811 | shows "x |\<in>| xs \<Longrightarrow> card_fset (remove_fset x xs) < card_fset xs" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 812 | unfolding card_fset in_fset remove_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 813 | by (rule card_Diff1_less[OF finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 814 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 815 | lemma card_remove_fset_less2: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 816 | shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> card_fset (remove_fset y (remove_fset x xs)) < card_fset xs" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 817 | unfolding card_fset remove_fset in_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 818 | by (rule card_Diff2_less[OF finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 819 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 820 | lemma card_remove_fset_le1: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 821 | shows "card_fset (remove_fset x xs) \<le> card_fset xs" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 822 | unfolding remove_fset card_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 823 | by (rule card_Diff1_le[OF finite_fset]) | 
| 36280 | 824 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 825 | lemma card_psubset_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 826 | shows "ys |\<subseteq>| xs \<Longrightarrow> card_fset ys < card_fset xs \<Longrightarrow> ys |\<subset>| xs" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 827 | unfolding card_fset psubset_fset subset_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 828 | by (rule card_psubset[OF finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 829 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 830 | lemma card_map_fset_le: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 831 | shows "card_fset (map_fset f xs) \<le> card_fset xs" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 832 | unfolding card_fset map_fset_image | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 833 | by (rule card_image_le[OF finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 834 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 835 | lemma card_minus_insert_fset[simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 836 | assumes "a |\<in>| A" and "a |\<notin>| B" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 837 | shows "card_fset (A - insert_fset a B) = card_fset (A - B) - 1" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 838 | using assms | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 839 | unfolding in_fset card_fset minus_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 840 | by (simp add: card_Diff_insert[OF finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 841 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 842 | lemma card_minus_subset_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 843 | assumes "B |\<subseteq>| A" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 844 | shows "card_fset (A - B) = card_fset A - card_fset B" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 845 | using assms | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 846 | unfolding subset_fset card_fset minus_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 847 | by (rule card_Diff_subset[OF finite_fset]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 848 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 849 | lemma card_minus_fset: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 850 | shows "card_fset (A - B) = card_fset A - card_fset (A |\<inter>| B)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 851 | unfolding inter_fset card_fset minus_fset | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 852 | by (rule card_Diff_subset_Int) (simp) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 853 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 854 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 855 | subsection {* concat_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 856 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 857 | lemma concat_empty_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 858 |   shows "concat_fset {||} = {||}"
 | 
| 46416 
5f5665a0b973
Make automatic derivation of raw/quotient types more greedy to allow descending and quot_lifted for compound quotients.
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46404diff
changeset | 859 | by descending simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 860 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 861 | lemma concat_insert_fset [simp]: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 862 | shows "concat_fset (insert_fset x S) = x |\<union>| concat_fset S" | 
| 46416 
5f5665a0b973
Make automatic derivation of raw/quotient types more greedy to allow descending and quot_lifted for compound quotients.
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46404diff
changeset | 863 | by descending simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 864 | |
| 46441 
992a1688303f
Generalize the compositional preservation theorems
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46416diff
changeset | 865 | lemma concat_union_fset [simp]: | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 866 | shows "concat_fset (xs |\<union>| ys) = concat_fset xs |\<union>| concat_fset ys" | 
| 46416 
5f5665a0b973
Make automatic derivation of raw/quotient types more greedy to allow descending and quot_lifted for compound quotients.
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46404diff
changeset | 867 | by descending simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 868 | |
| 46404 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 869 | lemma map_concat_fset: | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 870 | shows "map_fset f (concat_fset xs) = concat_fset (map_fset (map_fset f) xs)" | 
| 
7736068b9f56
Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
 Cezary Kaliszyk <cezarykaliszyk@gmail.com> parents: 
46133diff
changeset | 871 | by (lifting map_concat) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 872 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 873 | subsection {* filter_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 874 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 875 | lemma subset_filter_fset: | 
| 40961 | 876 | "filter_fset P xs |\<subseteq>| filter_fset Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)" | 
| 877 | by descending auto | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 878 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 879 | lemma eq_filter_fset: | 
| 40961 | 880 | "(filter_fset P xs = filter_fset Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)" | 
| 881 | by descending auto | |
| 36280 | 882 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 883 | lemma psubset_filter_fset: | 
| 40961 | 884 | "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 885 | filter_fset P xs |\<subset>| filter_fset Q xs" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 886 | unfolding less_fset_def by (auto simp add: subset_filter_fset eq_filter_fset) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 887 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 888 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 889 | subsection {* fold_fset *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 890 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 891 | lemma fold_empty_fset: | 
| 40961 | 892 |   "fold_fset f {||} = id"
 | 
| 40962 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 893 | by descending (simp add: fold_once_def) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 894 | |
| 40961 | 895 | lemma fold_insert_fset: "fold_fset f (insert_fset a A) = | 
| 40962 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 896 | (if rsp_fold f then if a |\<in>| A then fold_fset f A else fold_fset f A \<circ> f a else id)" | 
| 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 897 | by descending (simp add: fold_once_fold_remdups) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 898 | |
| 47092 | 899 | lemma remdups_removeAll: | 
| 900 | "remdups (removeAll x xs) = remove1 x (remdups xs)" | |
| 901 | by (induct xs) auto | |
| 902 | ||
| 903 | lemma member_commute_fold_once: | |
| 904 | assumes "rsp_fold f" | |
| 905 | and "x \<in> set xs" | |
| 906 | shows "fold_once f xs = fold_once f (removeAll x xs) \<circ> f x" | |
| 907 | proof - | |
| 908 | from assms have "fold f (remdups xs) = fold f (remove1 x (remdups xs)) \<circ> f x" | |
| 909 | by (auto intro!: fold_remove1_split elim: rsp_foldE) | |
| 910 | then show ?thesis using `rsp_fold f` by (simp add: fold_once_fold_remdups remdups_removeAll) | |
| 911 | qed | |
| 912 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 913 | lemma in_commute_fold_fset: | 
| 40962 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 914 | "rsp_fold f \<Longrightarrow> h |\<in>| b \<Longrightarrow> fold_fset f b = fold_fset f (remove_fset h b) \<circ> f h" | 
| 
069cd1c1f39b
more intimate definition of fold_list / fold_once in terms of fold
 haftmann parents: 
40961diff
changeset | 915 | by descending (simp add: member_commute_fold_once) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 916 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 917 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 918 | subsection {* Choice in fsets *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 919 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 920 | lemma fset_choice: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 921 | assumes a: "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 922 | shows "\<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 923 | using a | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 924 | apply(descending) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 925 | using finite_set_choice | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 926 | by (auto simp add: Ball_def) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 927 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 928 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 929 | section {* Induction and Cases rules for fsets *}
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 930 | |
| 41070 | 931 | lemma fset_exhaust [case_names empty insert, cases type: fset]: | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 932 |   assumes empty_fset_case: "S = {||} \<Longrightarrow> P" 
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 933 | and insert_fset_case: "\<And>x S'. S = insert_fset x S' \<Longrightarrow> P" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 934 | shows "P" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 935 | using assms by (lifting list.exhaust) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 936 | |
| 41070 | 937 | lemma fset_induct [case_names empty insert]: | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 938 |   assumes empty_fset_case: "P {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 939 | and insert_fset_case: "\<And>x S. P S \<Longrightarrow> P (insert_fset x S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 940 | shows "P S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 941 | using assms | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 942 | by (descending) (blast intro: list.induct) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 943 | |
| 41070 | 944 | lemma fset_induct_stronger [case_names empty insert, induct type: fset]: | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 945 |   assumes empty_fset_case: "P {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 946 | and insert_fset_case: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (insert_fset x S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 947 | shows "P S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 948 | proof(induct S rule: fset_induct) | 
| 41070 | 949 | case empty | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 950 |   show "P {||}" using empty_fset_case by simp
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 951 | next | 
| 41070 | 952 | case (insert x S) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 953 | have "P S" by fact | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 954 | then show "P (insert_fset x S)" using insert_fset_case | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 955 | by (cases "x |\<in>| S") (simp_all) | 
| 36280 | 956 | qed | 
| 957 | ||
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 958 | lemma fset_card_induct: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 959 |   assumes empty_fset_case: "P {||}"
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 960 | and card_fset_Suc_case: "\<And>S T. Suc (card_fset S) = (card_fset T) \<Longrightarrow> P S \<Longrightarrow> P T" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 961 | shows "P S" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 962 | proof (induct S) | 
| 41070 | 963 | case empty | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 964 |   show "P {||}" by (rule empty_fset_case)
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 965 | next | 
| 41070 | 966 | case (insert x S) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 967 | have h: "P S" by fact | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 968 | have "x |\<notin>| S" by fact | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 969 | then have "Suc (card_fset S) = card_fset (insert_fset x S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 970 | using card_fset_Suc by auto | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 971 | then show "P (insert_fset x S)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 972 | using h card_fset_Suc_case by simp | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 973 | qed | 
| 36280 | 974 | |
| 975 | lemma fset_raw_strong_cases: | |
| 36465 | 976 | obtains "xs = []" | 
| 40953 | 977 | | ys x where "\<not> List.member ys x" and "xs \<approx> x # ys" | 
| 45129 
1fce03e3e8ad
tuned proofs -- eliminated vacuous "induct arbitrary: ..." situations;
 wenzelm parents: 
44512diff
changeset | 978 | proof (induct xs) | 
| 36465 | 979 | case Nil | 
| 980 | then show thesis by simp | |
| 981 | next | |
| 982 | case (Cons a xs) | |
| 40953 | 983 | have a: "\<lbrakk>xs = [] \<Longrightarrow> thesis; \<And>x ys. \<lbrakk>\<not> List.member ys x; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis" | 
| 984 | by (rule Cons(1)) | |
| 985 | have b: "\<And>x' ys'. \<lbrakk>\<not> List.member ys' x'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 986 | have c: "xs = [] \<Longrightarrow> thesis" using b | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 987 | apply(simp) | 
| 57816 
d8bbb97689d3
no need for 'set_simps' now that 'datatype_new' generates the desired 'set' property
 blanchet parents: 
55945diff
changeset | 988 | by (metis list.set(1) emptyE empty_subsetI) | 
| 40953 | 989 | have "\<And>x ys. \<lbrakk>\<not> List.member ys x; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis" | 
| 36465 | 990 | proof - | 
| 991 | fix x :: 'a | |
| 992 | fix ys :: "'a list" | |
| 40953 | 993 | assume d:"\<not> List.member ys x" | 
| 36465 | 994 | assume e:"xs \<approx> x # ys" | 
| 995 | show thesis | |
| 996 | proof (cases "x = a") | |
| 997 | assume h: "x = a" | |
| 40953 | 998 | then have f: "\<not> List.member ys a" using d by simp | 
| 36465 | 999 | have g: "a # xs \<approx> a # ys" using e h by auto | 
| 1000 | show thesis using b f g by simp | |
| 1001 | next | |
| 1002 | assume h: "x \<noteq> a" | |
| 40953 | 1003 | then have f: "\<not> List.member (a # ys) x" using d by auto | 
| 36465 | 1004 | have g: "a # xs \<approx> x # (a # ys)" using e h by auto | 
| 40953 | 1005 | show thesis using b f g by (simp del: List.member_def) | 
| 36465 | 1006 | qed | 
| 1007 | qed | |
| 1008 | then show thesis using a c by blast | |
| 1009 | qed | |
| 36280 | 1010 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1011 | |
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1012 | lemma fset_strong_cases: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1013 |   obtains "xs = {||}"
 | 
| 40953 | 1014 | | ys x where "x |\<notin>| ys" and "xs = insert_fset x ys" | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1015 | by (lifting fset_raw_strong_cases) | 
| 36280 | 1016 | |
| 39996 
c02078ff8691
FSet: definition changes propagated from Nominal and more use of 'descending' tactic
 Cezary Kaliszyk <kaliszyk@in.tum.de> parents: 
39995diff
changeset | 1017 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1018 | lemma fset_induct2: | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1019 |   "P {||} {||} \<Longrightarrow>
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1020 |   (\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (insert_fset x xs) {||}) \<Longrightarrow>
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1021 |   (\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (insert_fset y ys)) \<Longrightarrow>
 | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1022 | (\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (insert_fset x xs) (insert_fset y ys)) \<Longrightarrow> | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1023 | P xsa ysa" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1024 | apply (induct xsa arbitrary: ysa) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1025 | apply (induct_tac x rule: fset_induct_stronger) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1026 | apply simp_all | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1027 | apply (induct_tac xa rule: fset_induct_stronger) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1028 | apply simp_all | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1029 | done | 
| 36280 | 1030 | |
| 41070 | 1031 | text {* Extensionality *}
 | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1032 | |
| 41070 | 1033 | lemma fset_eqI: | 
| 1034 | assumes "\<And>x. x \<in> fset A \<longleftrightarrow> x \<in> fset B" | |
| 1035 | shows "A = B" | |
| 1036 | using assms proof (induct A arbitrary: B) | |
| 1037 | case empty then show ?case | |
| 1038 | by (auto simp add: in_fset none_in_empty_fset [symmetric] sym) | |
| 1039 | next | |
| 1040 | case (insert x A) | |
| 1041 |   from insert.prems insert.hyps(1) have "\<And>z. z \<in> fset A \<longleftrightarrow> z \<in> fset (B - {|x|})"
 | |
| 1042 | by (auto simp add: in_fset) | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
51371diff
changeset | 1043 |   then have A: "A = B - {|x|}" by (rule insert.hyps(2))
 | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
51371diff
changeset | 1044 | with insert.prems [symmetric, of x] have "x |\<in>| B" by (simp add: in_fset) | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
51371diff
changeset | 1045 | with A show ?case by (metis in_fset_mdef) | 
| 41070 | 1046 | qed | 
| 36280 | 1047 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1048 | subsection {* alternate formulation with a different decomposition principle
 | 
| 36280 | 1049 | and a proof of equivalence *} | 
| 1050 | ||
| 1051 | inductive | |
| 40952 | 1052 |   list_eq2 :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<approx>2 _")
 | 
| 36280 | 1053 | where | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1054 | "(a # b # xs) \<approx>2 (b # a # xs)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1055 | | "[] \<approx>2 []" | 
| 40952 | 1056 | | "xs \<approx>2 ys \<Longrightarrow> ys \<approx>2 xs" | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1057 | | "(a # a # xs) \<approx>2 (a # xs)" | 
| 40952 | 1058 | | "xs \<approx>2 ys \<Longrightarrow> (a # xs) \<approx>2 (a # ys)" | 
| 1059 | | "xs1 \<approx>2 xs2 \<Longrightarrow> xs2 \<approx>2 xs3 \<Longrightarrow> xs1 \<approx>2 xs3" | |
| 36280 | 1060 | |
| 1061 | lemma list_eq2_refl: | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1062 | shows "xs \<approx>2 xs" | 
| 36280 | 1063 | by (induct xs) (auto intro: list_eq2.intros) | 
| 1064 | ||
| 1065 | lemma cons_delete_list_eq2: | |
| 40953 | 1066 | shows "(a # (removeAll a A)) \<approx>2 (if List.member A a then A else a # A)" | 
| 36280 | 1067 | apply (induct A) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1068 | apply (simp add: list_eq2_refl) | 
| 40953 | 1069 | apply (case_tac "List.member (aa # A) a") | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1070 | apply (simp_all) | 
| 36280 | 1071 | apply (case_tac [!] "a = aa") | 
| 1072 | apply (simp_all) | |
| 40953 | 1073 | apply (case_tac "List.member A a") | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1074 | apply (auto)[2] | 
| 36280 | 1075 | apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6)) | 
| 1076 | apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6)) | |
| 40953 | 1077 | apply (auto simp add: list_eq2_refl) | 
| 36280 | 1078 | done | 
| 1079 | ||
| 40953 | 1080 | lemma member_delete_list_eq2: | 
| 1081 | assumes a: "List.member r e" | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1082 | shows "(e # removeAll e r) \<approx>2 r" | 
| 36280 | 1083 | using a cons_delete_list_eq2[of e r] | 
| 1084 | by simp | |
| 1085 | ||
| 1086 | lemma list_eq2_equiv: | |
| 1087 | "(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)" | |
| 1088 | proof | |
| 1089 | show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto | |
| 1090 | next | |
| 1091 |   {
 | |
| 1092 | fix n | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1093 | assume a: "card_list l = n" and b: "l \<approx> r" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1094 | have "l \<approx>2 r" | 
| 36280 | 1095 | using a b | 
| 1096 | proof (induct n arbitrary: l r) | |
| 1097 | case 0 | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1098 | have "card_list l = 0" by fact | 
| 40953 | 1099 | then have "\<forall>x. \<not> List.member l x" by auto | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1100 | then have z: "l = []" by auto | 
| 36280 | 1101 | then have "r = []" using `l \<approx> r` by simp | 
| 1102 | then show ?case using z list_eq2_refl by simp | |
| 1103 | next | |
| 1104 | case (Suc m) | |
| 1105 | have b: "l \<approx> r" by fact | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1106 | have d: "card_list l = Suc m" by fact | 
| 40953 | 1107 | then have "\<exists>a. List.member l a" | 
| 41067 | 1108 | apply(simp) | 
| 1109 | apply(drule card_eq_SucD) | |
| 1110 | apply(blast) | |
| 1111 | done | |
| 40953 | 1112 | then obtain a where e: "List.member l a" by auto | 
| 1113 | then have e': "List.member r a" using list_eq_def [simplified List.member_def [symmetric], of l r] b | |
| 41067 | 1114 | by auto | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1115 | have f: "card_list (removeAll a l) = m" using e d by (simp) | 
| 47198 
cfd8ff62eab1
use qualified names for rsp and rep_eq theorems in quotient_def
 kuncar parents: 
47092diff
changeset | 1116 | have g: "removeAll a l \<approx> removeAll a r" using remove_fset.rsp b by simp | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1117 | have "(removeAll a l) \<approx>2 (removeAll a r)" by (rule Suc.hyps[OF f g]) | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1118 | then have h: "(a # removeAll a l) \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(5)) | 
| 41067 | 1119 | have i: "l \<approx>2 (a # removeAll a l)" | 
| 40953 | 1120 | by (rule list_eq2.intros(3)[OF member_delete_list_eq2[OF e]]) | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1121 | have "l \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h]) | 
| 40953 | 1122 | then show ?case using list_eq2.intros(6)[OF _ member_delete_list_eq2[OF e']] by simp | 
| 36280 | 1123 | qed | 
| 1124 | } | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1125 | then show "l \<approx> r \<Longrightarrow> l \<approx>2 r" by blast | 
| 36280 | 1126 | qed | 
| 1127 | ||
| 1128 | ||
| 1129 | (* We cannot write it as "assumes .. shows" since Isabelle changes | |
| 1130 | the quantifiers to schematic variables and reintroduces them in | |
| 1131 | a different order *) | |
| 1132 | lemma fset_eq_cases: | |
| 1133 | "\<lbrakk>a1 = a2; | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1134 | \<And>a b xs. \<lbrakk>a1 = insert_fset a (insert_fset b xs); a2 = insert_fset b (insert_fset a xs)\<rbrakk> \<Longrightarrow> P; | 
| 36280 | 1135 |    \<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P;
 | 
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1136 | \<And>a xs. \<lbrakk>a1 = insert_fset a (insert_fset a xs); a2 = insert_fset a xs\<rbrakk> \<Longrightarrow> P; | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1137 | \<And>xs ys a. \<lbrakk>a1 = insert_fset a xs; a2 = insert_fset a ys; xs = ys\<rbrakk> \<Longrightarrow> P; | 
| 36280 | 1138 | \<And>xs1 xs2 xs3. \<lbrakk>a1 = xs1; a2 = xs3; xs1 = xs2; xs2 = xs3\<rbrakk> \<Longrightarrow> P\<rbrakk> | 
| 1139 | \<Longrightarrow> P" | |
| 1140 | by (lifting list_eq2.cases[simplified list_eq2_equiv[symmetric]]) | |
| 1141 | ||
| 1142 | lemma fset_eq_induct: | |
| 1143 | assumes "x1 = x2" | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1144 | and "\<And>a b xs. P (insert_fset a (insert_fset b xs)) (insert_fset b (insert_fset a xs))" | 
| 36280 | 1145 |   and "P {||} {||}"
 | 
| 1146 | and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs" | |
| 40030 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1147 | and "\<And>a xs. P (insert_fset a (insert_fset a xs)) (insert_fset a xs)" | 
| 
9f8dcf6ef563
reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
 Christian Urban <urbanc@in.tum.de> parents: 
39996diff
changeset | 1148 | and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (insert_fset a xs) (insert_fset a ys)" | 
| 36280 | 1149 | and "\<And>xs1 xs2 xs3. \<lbrakk>xs1 = xs2; P xs1 xs2; xs2 = xs3; P xs2 xs3\<rbrakk> \<Longrightarrow> P xs1 xs3" | 
| 1150 | shows "P x1 x2" | |
| 1151 | using assms | |
| 1152 | by (lifting list_eq2.induct[simplified list_eq2_equiv[symmetric]]) | |
| 1153 | ||
| 1154 | ML {*
 | |
| 36465 | 1155 | fun dest_fsetT (Type (@{type_name fset}, [T])) = T
 | 
| 36280 | 1156 |   | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []);
 | 
| 1157 | *} | |
| 1158 | ||
| 1159 | no_notation | |
| 40034 | 1160 | list_eq (infix "\<approx>" 50) and | 
| 1161 | list_eq2 (infix "\<approx>2" 50) | |
| 36280 | 1162 | |
| 1163 | end |