| author | sultana | 
| Wed, 19 Feb 2014 15:57:02 +0000 | |
| changeset 55586 | c94f1a72d9c5 | 
| parent 55565 | f663fc1e653b | 
| child 55732 | 07906fc6af7a | 
| permissions | -rw-r--r-- | 
| 53953 | 1 | (* Title: HOL/Library/FSet.thy | 
| 2 | Author: Ondrej Kuncar, TU Muenchen | |
| 3 | Author: Cezary Kaliszyk and Christian Urban | |
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 4 | Author: Andrei Popescu, TU Muenchen | 
| 53953 | 5 | *) | 
| 6 | ||
| 7 | header {* Type of finite sets defined as a subtype of sets *}
 | |
| 8 | ||
| 9 | theory FSet | |
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 10 | imports Conditionally_Complete_Lattices | 
| 53953 | 11 | begin | 
| 12 | ||
| 13 | subsection {* Definition of the type *}
 | |
| 14 | ||
| 15 | typedef 'a fset = "{A :: 'a set. finite A}"  morphisms fset Abs_fset
 | |
| 16 | by auto | |
| 17 | ||
| 18 | setup_lifting type_definition_fset | |
| 19 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 20 | |
| 53953 | 21 | subsection {* Basic operations and type class instantiations *}
 | 
| 22 | ||
| 23 | (* FIXME transfer and right_total vs. bi_total *) | |
| 24 | instantiation fset :: (finite) finite | |
| 25 | begin | |
| 26 | instance by default (transfer, simp) | |
| 27 | end | |
| 28 | ||
| 29 | instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
 | |
| 30 | begin | |
| 31 | ||
| 32 | interpretation lifting_syntax . | |
| 33 | ||
| 34 | lift_definition bot_fset :: "'a fset" is "{}" parametric empty_transfer by simp 
 | |
| 35 | ||
| 36 | lift_definition less_eq_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" is subset_eq parametric subset_transfer | |
| 55565 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 37 | . | 
| 53953 | 38 | |
| 39 | definition less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" where "xs < ys \<equiv> xs \<le> ys \<and> xs \<noteq> (ys::'a fset)" | |
| 40 | ||
| 41 | lemma less_fset_transfer[transfer_rule]: | |
| 42 | assumes [transfer_rule]: "bi_unique A" | |
| 43 | shows "((pcr_fset A) ===> (pcr_fset A) ===> op =) op \<subset> op <" | |
| 44 | unfolding less_fset_def[abs_def] psubset_eq[abs_def] by transfer_prover | |
| 45 | ||
| 46 | ||
| 47 | lift_definition sup_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is union parametric union_transfer | |
| 48 | by simp | |
| 49 | ||
| 50 | lift_definition inf_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is inter parametric inter_transfer | |
| 51 | by simp | |
| 52 | ||
| 53 | lift_definition minus_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is minus parametric Diff_transfer | |
| 54 | by simp | |
| 55 | ||
| 56 | instance | |
| 57 | by default (transfer, auto)+ | |
| 58 | ||
| 59 | end | |
| 60 | ||
| 61 | abbreviation fempty :: "'a fset" ("{||}") where "{||} \<equiv> bot"
 | |
| 62 | abbreviation fsubset_eq :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50) where "xs |\<subseteq>| ys \<equiv> xs \<le> ys" | |
| 63 | abbreviation fsubset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50) where "xs |\<subset>| ys \<equiv> xs < ys" | |
| 64 | abbreviation funion :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" (infixl "|\<union>|" 65) where "xs |\<union>| ys \<equiv> sup xs ys" | |
| 65 | abbreviation finter :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" (infixl "|\<inter>|" 65) where "xs |\<inter>| ys \<equiv> inf xs ys" | |
| 66 | abbreviation fminus :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" (infixl "|-|" 65) where "xs |-| ys \<equiv> minus xs ys" | |
| 67 | ||
| 54014 | 68 | instantiation fset :: (equal) equal | 
| 69 | begin | |
| 70 | definition "HOL.equal A B \<longleftrightarrow> A |\<subseteq>| B \<and> B |\<subseteq>| A" | |
| 71 | instance by intro_classes (auto simp add: equal_fset_def) | |
| 72 | end | |
| 73 | ||
| 53953 | 74 | instantiation fset :: (type) conditionally_complete_lattice | 
| 75 | begin | |
| 76 | ||
| 77 | interpretation lifting_syntax . | |
| 78 | ||
| 79 | lemma right_total_Inf_fset_transfer: | |
| 80 | assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "right_total A" | |
| 81 | shows "(set_rel (set_rel A) ===> set_rel A) | |
| 82 |     (\<lambda>S. if finite (Inter S \<inter> Collect (Domainp A)) then Inter S \<inter> Collect (Domainp A) else {}) 
 | |
| 83 |       (\<lambda>S. if finite (Inf S) then Inf S else {})"
 | |
| 84 | by transfer_prover | |
| 85 | ||
| 86 | lemma Inf_fset_transfer: | |
| 87 | assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "bi_total A" | |
| 88 |   shows "(set_rel (set_rel A) ===> set_rel A) (\<lambda>A. if finite (Inf A) then Inf A else {}) 
 | |
| 89 |     (\<lambda>A. if finite (Inf A) then Inf A else {})"
 | |
| 90 | by transfer_prover | |
| 91 | ||
| 92 | lift_definition Inf_fset :: "'a fset set \<Rightarrow> 'a fset" is "\<lambda>A. if finite (Inf A) then Inf A else {}" 
 | |
| 93 | parametric right_total_Inf_fset_transfer Inf_fset_transfer by simp | |
| 94 | ||
| 95 | lemma Sup_fset_transfer: | |
| 96 | assumes [transfer_rule]: "bi_unique A" | |
| 97 |   shows "(set_rel (set_rel A) ===> set_rel A) (\<lambda>A. if finite (Sup A) then Sup A else {})
 | |
| 98 |   (\<lambda>A. if finite (Sup A) then Sup A else {})" by transfer_prover
 | |
| 99 | ||
| 100 | lift_definition Sup_fset :: "'a fset set \<Rightarrow> 'a fset" is "\<lambda>A. if finite (Sup A) then Sup A else {}"
 | |
| 101 | parametric Sup_fset_transfer by simp | |
| 102 | ||
| 103 | lemma finite_Sup: "\<exists>z. finite z \<and> (\<forall>a. a \<in> X \<longrightarrow> a \<le> z) \<Longrightarrow> finite (Sup X)" | |
| 104 | by (auto intro: finite_subset) | |
| 105 | ||
| 54258 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 106 | lemma transfer_bdd_below[transfer_rule]: "(set_rel (pcr_fset op =) ===> op =) bdd_below bdd_below" | 
| 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 107 | by auto | 
| 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 108 | |
| 53953 | 109 | instance | 
| 110 | proof | |
| 111 | fix x z :: "'a fset" | |
| 112 | fix X :: "'a fset set" | |
| 113 |   {
 | |
| 54258 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 114 | assume "x \<in> X" "bdd_below X" | 
| 53953 | 115 | then show "Inf X |\<subseteq>| x" by transfer auto | 
| 116 | next | |
| 117 |     assume "X \<noteq> {}" "(\<And>x. x \<in> X \<Longrightarrow> z |\<subseteq>| x)"
 | |
| 118 | then show "z |\<subseteq>| Inf X" by transfer (clarsimp, blast) | |
| 119 | next | |
| 54258 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 120 | assume "x \<in> X" "bdd_above X" | 
| 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 121 | then obtain z where "x \<in> X" "(\<And>x. x \<in> X \<Longrightarrow> x |\<subseteq>| z)" | 
| 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 122 | by (auto simp: bdd_above_def) | 
| 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 123 | then show "x |\<subseteq>| Sup X" | 
| 
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
 hoelzl parents: 
54014diff
changeset | 124 | by transfer (auto intro!: finite_Sup) | 
| 53953 | 125 | next | 
| 126 |     assume "X \<noteq> {}" "(\<And>x. x \<in> X \<Longrightarrow> x |\<subseteq>| z)"
 | |
| 127 | then show "Sup X |\<subseteq>| z" by transfer (clarsimp, blast) | |
| 128 | } | |
| 129 | qed | |
| 130 | end | |
| 131 | ||
| 132 | instantiation fset :: (finite) complete_lattice | |
| 133 | begin | |
| 134 | ||
| 135 | lift_definition top_fset :: "'a fset" is UNIV parametric right_total_UNIV_transfer UNIV_transfer by simp | |
| 136 | ||
| 137 | instance by default (transfer, auto)+ | |
| 138 | end | |
| 139 | ||
| 140 | instantiation fset :: (finite) complete_boolean_algebra | |
| 141 | begin | |
| 142 | ||
| 143 | lift_definition uminus_fset :: "'a fset \<Rightarrow> 'a fset" is uminus | |
| 144 | parametric right_total_Compl_transfer Compl_transfer by simp | |
| 145 | ||
| 146 | instance by (default, simp_all only: INF_def SUP_def) (transfer, auto)+ | |
| 147 | ||
| 148 | end | |
| 149 | ||
| 150 | abbreviation fUNIV :: "'a::finite fset" where "fUNIV \<equiv> top" | |
| 151 | abbreviation fuminus :: "'a::finite fset \<Rightarrow> 'a fset" ("|-| _" [81] 80) where "|-| x \<equiv> uminus x"
 | |
| 152 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 153 | |
| 53953 | 154 | subsection {* Other operations *}
 | 
| 155 | ||
| 156 | lift_definition finsert :: "'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is insert parametric Lifting_Set.insert_transfer | |
| 157 | by simp | |
| 158 | ||
| 159 | syntax | |
| 160 |   "_insert_fset"     :: "args => 'a fset"  ("{|(_)|}")
 | |
| 161 | ||
| 162 | translations | |
| 163 |   "{|x, xs|}" == "CONST finsert x {|xs|}"
 | |
| 164 |   "{|x|}"     == "CONST finsert x {||}"
 | |
| 165 | ||
| 166 | lift_definition fmember :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<in>|" 50) is Set.member | |
| 55565 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 167 | parametric member_transfer . | 
| 53953 | 168 | |
| 169 | abbreviation notin_fset :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50) where "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)" | |
| 170 | ||
| 171 | context | |
| 172 | begin | |
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 173 | |
| 53953 | 174 | interpretation lifting_syntax . | 
| 175 | ||
| 176 | lift_definition ffilter :: "('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is Set.filter 
 | |
| 177 | parametric Lifting_Set.filter_transfer unfolding Set.filter_def by simp | |
| 178 | ||
| 179 | lemma compose_rel_to_Domainp: | |
| 180 | assumes "left_unique R" | |
| 181 | assumes "(R ===> op=) P P'" | |
| 182 | shows "(R OO Lifting.invariant P' OO R\<inverse>\<inverse>) x y \<longleftrightarrow> Domainp R x \<and> P x \<and> x = y" | |
| 183 | using assms unfolding OO_def conversep_iff Domainp_iff left_unique_def fun_rel_def invariant_def | |
| 184 | by blast | |
| 185 | ||
| 186 | lift_definition fPow :: "'a fset \<Rightarrow> 'a fset fset" is Pow parametric Pow_transfer | |
| 187 | by (subst compose_rel_to_Domainp [OF _ finite_transfer]) (auto intro: transfer_raw finite_subset | |
| 188 | simp add: fset.pcr_cr_eq[symmetric] Domainp_set fset.domain_eq) | |
| 189 | ||
| 55565 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 190 | lift_definition fcard :: "'a fset \<Rightarrow> nat" is card parametric card_transfer . | 
| 53953 | 191 | |
| 192 | lift_definition fimage :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset" (infixr "|`|" 90) is image 
 | |
| 193 | parametric image_transfer by simp | |
| 194 | ||
| 55565 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 195 | lift_definition fthe_elem :: "'a fset \<Rightarrow> 'a" is the_elem . | 
| 53953 | 196 | |
| 197 | (* FIXME why is not invariant here unfolded ? *) | |
| 198 | lift_definition fbind :: "'a fset \<Rightarrow> ('a \<Rightarrow> 'b fset) \<Rightarrow> 'b fset" is Set.bind parametric bind_transfer
 | |
| 199 | unfolding invariant_def Set.bind_def by clarsimp metis | |
| 200 | ||
| 201 | lift_definition ffUnion :: "'a fset fset \<Rightarrow> 'a fset" is Union parametric Union_transfer | |
| 202 | by (subst(asm) compose_rel_to_Domainp [OF _ finite_transfer]) | |
| 203 | (auto intro: transfer_raw simp add: fset.pcr_cr_eq[symmetric] Domainp_set fset.domain_eq invariant_def) | |
| 204 | ||
| 55565 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 205 | lift_definition fBall :: "'a fset \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" is Ball parametric Ball_transfer .
 | 
| 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 206 | lift_definition fBex :: "'a fset \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" is Bex parametric Bex_transfer .
 | 
| 53953 | 207 | |
| 55565 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 208 | lift_definition ffold :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b" is Finite_Set.fold .
 | 
| 53963 | 209 | |
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 210 | |
| 53953 | 211 | subsection {* Transferred lemmas from Set.thy *}
 | 
| 212 | ||
| 213 | lemmas fset_eqI = set_eqI[Transfer.transferred] | |
| 214 | lemmas fset_eq_iff[no_atp] = set_eq_iff[Transfer.transferred] | |
| 215 | lemmas fBallI[intro!] = ballI[Transfer.transferred] | |
| 216 | lemmas fbspec[dest?] = bspec[Transfer.transferred] | |
| 217 | lemmas fBallE[elim] = ballE[Transfer.transferred] | |
| 218 | lemmas fBexI[intro] = bexI[Transfer.transferred] | |
| 219 | lemmas rev_fBexI[intro?] = rev_bexI[Transfer.transferred] | |
| 220 | lemmas fBexCI = bexCI[Transfer.transferred] | |
| 221 | lemmas fBexE[elim!] = bexE[Transfer.transferred] | |
| 222 | lemmas fBall_triv[simp] = ball_triv[Transfer.transferred] | |
| 223 | lemmas fBex_triv[simp] = bex_triv[Transfer.transferred] | |
| 224 | lemmas fBex_triv_one_point1[simp] = bex_triv_one_point1[Transfer.transferred] | |
| 225 | lemmas fBex_triv_one_point2[simp] = bex_triv_one_point2[Transfer.transferred] | |
| 226 | lemmas fBex_one_point1[simp] = bex_one_point1[Transfer.transferred] | |
| 227 | lemmas fBex_one_point2[simp] = bex_one_point2[Transfer.transferred] | |
| 228 | lemmas fBall_one_point1[simp] = ball_one_point1[Transfer.transferred] | |
| 229 | lemmas fBall_one_point2[simp] = ball_one_point2[Transfer.transferred] | |
| 230 | lemmas fBall_conj_distrib = ball_conj_distrib[Transfer.transferred] | |
| 231 | lemmas fBex_disj_distrib = bex_disj_distrib[Transfer.transferred] | |
| 232 | lemmas fBall_cong = ball_cong[Transfer.transferred] | |
| 233 | lemmas fBex_cong = bex_cong[Transfer.transferred] | |
| 53964 | 234 | lemmas fsubsetI[intro!] = subsetI[Transfer.transferred] | 
| 235 | lemmas fsubsetD[elim, intro?] = subsetD[Transfer.transferred] | |
| 236 | lemmas rev_fsubsetD[no_atp,intro?] = rev_subsetD[Transfer.transferred] | |
| 237 | lemmas fsubsetCE[no_atp,elim] = subsetCE[Transfer.transferred] | |
| 238 | lemmas fsubset_eq[no_atp] = subset_eq[Transfer.transferred] | |
| 239 | lemmas contra_fsubsetD[no_atp] = contra_subsetD[Transfer.transferred] | |
| 240 | lemmas fsubset_refl = subset_refl[Transfer.transferred] | |
| 241 | lemmas fsubset_trans = subset_trans[Transfer.transferred] | |
| 53953 | 242 | lemmas fset_rev_mp = set_rev_mp[Transfer.transferred] | 
| 243 | lemmas fset_mp = set_mp[Transfer.transferred] | |
| 53964 | 244 | lemmas fsubset_not_fsubset_eq[code] = subset_not_subset_eq[Transfer.transferred] | 
| 53953 | 245 | lemmas eq_fmem_trans = eq_mem_trans[Transfer.transferred] | 
| 53964 | 246 | lemmas fsubset_antisym[intro!] = subset_antisym[Transfer.transferred] | 
| 53953 | 247 | lemmas fequalityD1 = equalityD1[Transfer.transferred] | 
| 248 | lemmas fequalityD2 = equalityD2[Transfer.transferred] | |
| 249 | lemmas fequalityE = equalityE[Transfer.transferred] | |
| 250 | lemmas fequalityCE[elim] = equalityCE[Transfer.transferred] | |
| 251 | lemmas eqfset_imp_iff = eqset_imp_iff[Transfer.transferred] | |
| 252 | lemmas eqfelem_imp_iff = eqelem_imp_iff[Transfer.transferred] | |
| 253 | lemmas fempty_iff[simp] = empty_iff[Transfer.transferred] | |
| 53964 | 254 | lemmas fempty_fsubsetI[iff] = empty_subsetI[Transfer.transferred] | 
| 53953 | 255 | lemmas equalsffemptyI = equals0I[Transfer.transferred] | 
| 256 | lemmas equalsffemptyD = equals0D[Transfer.transferred] | |
| 257 | lemmas fBall_fempty[simp] = ball_empty[Transfer.transferred] | |
| 258 | lemmas fBex_fempty[simp] = bex_empty[Transfer.transferred] | |
| 259 | lemmas fPow_iff[iff] = Pow_iff[Transfer.transferred] | |
| 260 | lemmas fPowI = PowI[Transfer.transferred] | |
| 261 | lemmas fPowD = PowD[Transfer.transferred] | |
| 262 | lemmas fPow_bottom = Pow_bottom[Transfer.transferred] | |
| 263 | lemmas fPow_top = Pow_top[Transfer.transferred] | |
| 264 | lemmas fPow_not_fempty = Pow_not_empty[Transfer.transferred] | |
| 265 | lemmas finter_iff[simp] = Int_iff[Transfer.transferred] | |
| 266 | lemmas finterI[intro!] = IntI[Transfer.transferred] | |
| 267 | lemmas finterD1 = IntD1[Transfer.transferred] | |
| 268 | lemmas finterD2 = IntD2[Transfer.transferred] | |
| 269 | lemmas finterE[elim!] = IntE[Transfer.transferred] | |
| 270 | lemmas funion_iff[simp] = Un_iff[Transfer.transferred] | |
| 271 | lemmas funionI1[elim?] = UnI1[Transfer.transferred] | |
| 272 | lemmas funionI2[elim?] = UnI2[Transfer.transferred] | |
| 273 | lemmas funionCI[intro!] = UnCI[Transfer.transferred] | |
| 274 | lemmas funionE[elim!] = UnE[Transfer.transferred] | |
| 275 | lemmas fminus_iff[simp] = Diff_iff[Transfer.transferred] | |
| 276 | lemmas fminusI[intro!] = DiffI[Transfer.transferred] | |
| 277 | lemmas fminusD1 = DiffD1[Transfer.transferred] | |
| 278 | lemmas fminusD2 = DiffD2[Transfer.transferred] | |
| 279 | lemmas fminusE[elim!] = DiffE[Transfer.transferred] | |
| 280 | lemmas finsert_iff[simp] = insert_iff[Transfer.transferred] | |
| 281 | lemmas finsertI1 = insertI1[Transfer.transferred] | |
| 282 | lemmas finsertI2 = insertI2[Transfer.transferred] | |
| 283 | lemmas finsertE[elim!] = insertE[Transfer.transferred] | |
| 284 | lemmas finsertCI[intro!] = insertCI[Transfer.transferred] | |
| 53964 | 285 | lemmas fsubset_finsert_iff = subset_insert_iff[Transfer.transferred] | 
| 53953 | 286 | lemmas finsert_ident = insert_ident[Transfer.transferred] | 
| 287 | lemmas fsingletonI[intro!,no_atp] = singletonI[Transfer.transferred] | |
| 288 | lemmas fsingletonD[dest!,no_atp] = singletonD[Transfer.transferred] | |
| 289 | lemmas fsingleton_iff = singleton_iff[Transfer.transferred] | |
| 290 | lemmas fsingleton_inject[dest!] = singleton_inject[Transfer.transferred] | |
| 291 | lemmas fsingleton_finsert_inj_eq[iff,no_atp] = singleton_insert_inj_eq[Transfer.transferred] | |
| 292 | lemmas fsingleton_finsert_inj_eq'[iff,no_atp] = singleton_insert_inj_eq'[Transfer.transferred] | |
| 53964 | 293 | lemmas fsubset_fsingletonD = subset_singletonD[Transfer.transferred] | 
| 53953 | 294 | lemmas fminus_single_finsert = diff_single_insert[Transfer.transferred] | 
| 295 | lemmas fdoubleton_eq_iff = doubleton_eq_iff[Transfer.transferred] | |
| 296 | lemmas funion_fsingleton_iff = Un_singleton_iff[Transfer.transferred] | |
| 297 | lemmas fsingleton_funion_iff = singleton_Un_iff[Transfer.transferred] | |
| 298 | lemmas fimage_eqI[simp, intro] = image_eqI[Transfer.transferred] | |
| 299 | lemmas fimageI = imageI[Transfer.transferred] | |
| 300 | lemmas rev_fimage_eqI = rev_image_eqI[Transfer.transferred] | |
| 301 | lemmas fimageE[elim!] = imageE[Transfer.transferred] | |
| 302 | lemmas Compr_fimage_eq = Compr_image_eq[Transfer.transferred] | |
| 303 | lemmas fimage_funion = image_Un[Transfer.transferred] | |
| 304 | lemmas fimage_iff = image_iff[Transfer.transferred] | |
| 53964 | 305 | lemmas fimage_fsubset_iff[no_atp] = image_subset_iff[Transfer.transferred] | 
| 306 | lemmas fimage_fsubsetI = image_subsetI[Transfer.transferred] | |
| 53953 | 307 | lemmas fimage_ident[simp] = image_ident[Transfer.transferred] | 
| 308 | lemmas split_if_fmem1 = split_if_mem1[Transfer.transferred] | |
| 309 | lemmas split_if_fmem2 = split_if_mem2[Transfer.transferred] | |
| 53964 | 310 | lemmas pfsubsetI[intro!,no_atp] = psubsetI[Transfer.transferred] | 
| 311 | lemmas pfsubsetE[elim!,no_atp] = psubsetE[Transfer.transferred] | |
| 312 | lemmas pfsubset_finsert_iff = psubset_insert_iff[Transfer.transferred] | |
| 313 | lemmas pfsubset_eq = psubset_eq[Transfer.transferred] | |
| 314 | lemmas pfsubset_imp_fsubset = psubset_imp_subset[Transfer.transferred] | |
| 315 | lemmas pfsubset_trans = psubset_trans[Transfer.transferred] | |
| 316 | lemmas pfsubsetD = psubsetD[Transfer.transferred] | |
| 317 | lemmas pfsubset_fsubset_trans = psubset_subset_trans[Transfer.transferred] | |
| 318 | lemmas fsubset_pfsubset_trans = subset_psubset_trans[Transfer.transferred] | |
| 319 | lemmas pfsubset_imp_ex_fmem = psubset_imp_ex_mem[Transfer.transferred] | |
| 53953 | 320 | lemmas fimage_fPow_mono = image_Pow_mono[Transfer.transferred] | 
| 321 | lemmas fimage_fPow_surj = image_Pow_surj[Transfer.transferred] | |
| 53964 | 322 | lemmas fsubset_finsertI = subset_insertI[Transfer.transferred] | 
| 323 | lemmas fsubset_finsertI2 = subset_insertI2[Transfer.transferred] | |
| 324 | lemmas fsubset_finsert = subset_insert[Transfer.transferred] | |
| 53953 | 325 | lemmas funion_upper1 = Un_upper1[Transfer.transferred] | 
| 326 | lemmas funion_upper2 = Un_upper2[Transfer.transferred] | |
| 327 | lemmas funion_least = Un_least[Transfer.transferred] | |
| 328 | lemmas finter_lower1 = Int_lower1[Transfer.transferred] | |
| 329 | lemmas finter_lower2 = Int_lower2[Transfer.transferred] | |
| 330 | lemmas finter_greatest = Int_greatest[Transfer.transferred] | |
| 53964 | 331 | lemmas fminus_fsubset = Diff_subset[Transfer.transferred] | 
| 332 | lemmas fminus_fsubset_conv = Diff_subset_conv[Transfer.transferred] | |
| 333 | lemmas fsubset_fempty[simp] = subset_empty[Transfer.transferred] | |
| 334 | lemmas not_pfsubset_fempty[iff] = not_psubset_empty[Transfer.transferred] | |
| 53953 | 335 | lemmas finsert_is_funion = insert_is_Un[Transfer.transferred] | 
| 336 | lemmas finsert_not_fempty[simp] = insert_not_empty[Transfer.transferred] | |
| 337 | lemmas fempty_not_finsert = empty_not_insert[Transfer.transferred] | |
| 338 | lemmas finsert_absorb = insert_absorb[Transfer.transferred] | |
| 339 | lemmas finsert_absorb2[simp] = insert_absorb2[Transfer.transferred] | |
| 340 | lemmas finsert_commute = insert_commute[Transfer.transferred] | |
| 53964 | 341 | lemmas finsert_fsubset[simp] = insert_subset[Transfer.transferred] | 
| 53953 | 342 | lemmas finsert_inter_finsert[simp] = insert_inter_insert[Transfer.transferred] | 
| 343 | lemmas finsert_disjoint[simp,no_atp] = insert_disjoint[Transfer.transferred] | |
| 344 | lemmas disjoint_finsert[simp,no_atp] = disjoint_insert[Transfer.transferred] | |
| 345 | lemmas fimage_fempty[simp] = image_empty[Transfer.transferred] | |
| 346 | lemmas fimage_finsert[simp] = image_insert[Transfer.transferred] | |
| 347 | lemmas fimage_constant = image_constant[Transfer.transferred] | |
| 348 | lemmas fimage_constant_conv = image_constant_conv[Transfer.transferred] | |
| 349 | lemmas fimage_fimage = image_image[Transfer.transferred] | |
| 350 | lemmas finsert_fimage[simp] = insert_image[Transfer.transferred] | |
| 351 | lemmas fimage_is_fempty[iff] = image_is_empty[Transfer.transferred] | |
| 352 | lemmas fempty_is_fimage[iff] = empty_is_image[Transfer.transferred] | |
| 353 | lemmas fimage_cong = image_cong[Transfer.transferred] | |
| 53964 | 354 | lemmas fimage_finter_fsubset = image_Int_subset[Transfer.transferred] | 
| 355 | lemmas fimage_fminus_fsubset = image_diff_subset[Transfer.transferred] | |
| 53953 | 356 | lemmas finter_absorb = Int_absorb[Transfer.transferred] | 
| 357 | lemmas finter_left_absorb = Int_left_absorb[Transfer.transferred] | |
| 358 | lemmas finter_commute = Int_commute[Transfer.transferred] | |
| 359 | lemmas finter_left_commute = Int_left_commute[Transfer.transferred] | |
| 360 | lemmas finter_assoc = Int_assoc[Transfer.transferred] | |
| 361 | lemmas finter_ac = Int_ac[Transfer.transferred] | |
| 362 | lemmas finter_absorb1 = Int_absorb1[Transfer.transferred] | |
| 363 | lemmas finter_absorb2 = Int_absorb2[Transfer.transferred] | |
| 364 | lemmas finter_fempty_left = Int_empty_left[Transfer.transferred] | |
| 365 | lemmas finter_fempty_right = Int_empty_right[Transfer.transferred] | |
| 366 | lemmas disjoint_iff_fnot_equal = disjoint_iff_not_equal[Transfer.transferred] | |
| 367 | lemmas finter_funion_distrib = Int_Un_distrib[Transfer.transferred] | |
| 368 | lemmas finter_funion_distrib2 = Int_Un_distrib2[Transfer.transferred] | |
| 53964 | 369 | lemmas finter_fsubset_iff[no_atp, simp] = Int_subset_iff[Transfer.transferred] | 
| 53953 | 370 | lemmas funion_absorb = Un_absorb[Transfer.transferred] | 
| 371 | lemmas funion_left_absorb = Un_left_absorb[Transfer.transferred] | |
| 372 | lemmas funion_commute = Un_commute[Transfer.transferred] | |
| 373 | lemmas funion_left_commute = Un_left_commute[Transfer.transferred] | |
| 374 | lemmas funion_assoc = Un_assoc[Transfer.transferred] | |
| 375 | lemmas funion_ac = Un_ac[Transfer.transferred] | |
| 376 | lemmas funion_absorb1 = Un_absorb1[Transfer.transferred] | |
| 377 | lemmas funion_absorb2 = Un_absorb2[Transfer.transferred] | |
| 378 | lemmas funion_fempty_left = Un_empty_left[Transfer.transferred] | |
| 379 | lemmas funion_fempty_right = Un_empty_right[Transfer.transferred] | |
| 380 | lemmas funion_finsert_left[simp] = Un_insert_left[Transfer.transferred] | |
| 381 | lemmas funion_finsert_right[simp] = Un_insert_right[Transfer.transferred] | |
| 382 | lemmas finter_finsert_left = Int_insert_left[Transfer.transferred] | |
| 383 | lemmas finter_finsert_left_ifffempty[simp] = Int_insert_left_if0[Transfer.transferred] | |
| 384 | lemmas finter_finsert_left_if1[simp] = Int_insert_left_if1[Transfer.transferred] | |
| 385 | lemmas finter_finsert_right = Int_insert_right[Transfer.transferred] | |
| 386 | lemmas finter_finsert_right_ifffempty[simp] = Int_insert_right_if0[Transfer.transferred] | |
| 387 | lemmas finter_finsert_right_if1[simp] = Int_insert_right_if1[Transfer.transferred] | |
| 388 | lemmas funion_finter_distrib = Un_Int_distrib[Transfer.transferred] | |
| 389 | lemmas funion_finter_distrib2 = Un_Int_distrib2[Transfer.transferred] | |
| 390 | lemmas funion_finter_crazy = Un_Int_crazy[Transfer.transferred] | |
| 53964 | 391 | lemmas fsubset_funion_eq = subset_Un_eq[Transfer.transferred] | 
| 53953 | 392 | lemmas funion_fempty[iff] = Un_empty[Transfer.transferred] | 
| 53964 | 393 | lemmas funion_fsubset_iff[no_atp, simp] = Un_subset_iff[Transfer.transferred] | 
| 53953 | 394 | lemmas funion_fminus_finter = Un_Diff_Int[Transfer.transferred] | 
| 395 | lemmas fminus_finter2 = Diff_Int2[Transfer.transferred] | |
| 396 | lemmas funion_finter_assoc_eq = Un_Int_assoc_eq[Transfer.transferred] | |
| 397 | lemmas fBall_funion = ball_Un[Transfer.transferred] | |
| 398 | lemmas fBex_funion = bex_Un[Transfer.transferred] | |
| 399 | lemmas fminus_eq_fempty_iff[simp,no_atp] = Diff_eq_empty_iff[Transfer.transferred] | |
| 400 | lemmas fminus_cancel[simp] = Diff_cancel[Transfer.transferred] | |
| 401 | lemmas fminus_idemp[simp] = Diff_idemp[Transfer.transferred] | |
| 402 | lemmas fminus_triv = Diff_triv[Transfer.transferred] | |
| 403 | lemmas fempty_fminus[simp] = empty_Diff[Transfer.transferred] | |
| 404 | lemmas fminus_fempty[simp] = Diff_empty[Transfer.transferred] | |
| 405 | lemmas fminus_finsertffempty[simp,no_atp] = Diff_insert0[Transfer.transferred] | |
| 406 | lemmas fminus_finsert = Diff_insert[Transfer.transferred] | |
| 407 | lemmas fminus_finsert2 = Diff_insert2[Transfer.transferred] | |
| 408 | lemmas finsert_fminus_if = insert_Diff_if[Transfer.transferred] | |
| 409 | lemmas finsert_fminus1[simp] = insert_Diff1[Transfer.transferred] | |
| 410 | lemmas finsert_fminus_single[simp] = insert_Diff_single[Transfer.transferred] | |
| 411 | lemmas finsert_fminus = insert_Diff[Transfer.transferred] | |
| 412 | lemmas fminus_finsert_absorb = Diff_insert_absorb[Transfer.transferred] | |
| 413 | lemmas fminus_disjoint[simp] = Diff_disjoint[Transfer.transferred] | |
| 414 | lemmas fminus_partition = Diff_partition[Transfer.transferred] | |
| 415 | lemmas double_fminus = double_diff[Transfer.transferred] | |
| 416 | lemmas funion_fminus_cancel[simp] = Un_Diff_cancel[Transfer.transferred] | |
| 417 | lemmas funion_fminus_cancel2[simp] = Un_Diff_cancel2[Transfer.transferred] | |
| 418 | lemmas fminus_funion = Diff_Un[Transfer.transferred] | |
| 419 | lemmas fminus_finter = Diff_Int[Transfer.transferred] | |
| 420 | lemmas funion_fminus = Un_Diff[Transfer.transferred] | |
| 421 | lemmas finter_fminus = Int_Diff[Transfer.transferred] | |
| 422 | lemmas fminus_finter_distrib = Diff_Int_distrib[Transfer.transferred] | |
| 423 | lemmas fminus_finter_distrib2 = Diff_Int_distrib2[Transfer.transferred] | |
| 424 | lemmas fUNIV_bool[no_atp] = UNIV_bool[Transfer.transferred] | |
| 425 | lemmas fPow_fempty[simp] = Pow_empty[Transfer.transferred] | |
| 426 | lemmas fPow_finsert = Pow_insert[Transfer.transferred] | |
| 53964 | 427 | lemmas funion_fPow_fsubset = Un_Pow_subset[Transfer.transferred] | 
| 53953 | 428 | lemmas fPow_finter_eq[simp] = Pow_Int_eq[Transfer.transferred] | 
| 53964 | 429 | lemmas fset_eq_fsubset = set_eq_subset[Transfer.transferred] | 
| 430 | lemmas fsubset_iff[no_atp] = subset_iff[Transfer.transferred] | |
| 431 | lemmas fsubset_iff_pfsubset_eq = subset_iff_psubset_eq[Transfer.transferred] | |
| 53953 | 432 | lemmas all_not_fin_conv[simp] = all_not_in_conv[Transfer.transferred] | 
| 433 | lemmas ex_fin_conv = ex_in_conv[Transfer.transferred] | |
| 434 | lemmas fimage_mono = image_mono[Transfer.transferred] | |
| 435 | lemmas fPow_mono = Pow_mono[Transfer.transferred] | |
| 436 | lemmas finsert_mono = insert_mono[Transfer.transferred] | |
| 437 | lemmas funion_mono = Un_mono[Transfer.transferred] | |
| 438 | lemmas finter_mono = Int_mono[Transfer.transferred] | |
| 439 | lemmas fminus_mono = Diff_mono[Transfer.transferred] | |
| 440 | lemmas fin_mono = in_mono[Transfer.transferred] | |
| 441 | lemmas fthe_felem_eq[simp] = the_elem_eq[Transfer.transferred] | |
| 442 | lemmas fLeast_mono = Least_mono[Transfer.transferred] | |
| 443 | lemmas fbind_fbind = bind_bind[Transfer.transferred] | |
| 444 | lemmas fempty_fbind[simp] = empty_bind[Transfer.transferred] | |
| 445 | lemmas nonfempty_fbind_const = nonempty_bind_const[Transfer.transferred] | |
| 446 | lemmas fbind_const = bind_const[Transfer.transferred] | |
| 447 | lemmas ffmember_filter[simp] = member_filter[Transfer.transferred] | |
| 448 | lemmas fequalityI = equalityI[Transfer.transferred] | |
| 449 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 450 | |
| 53953 | 451 | subsection {* Additional lemmas*}
 | 
| 452 | ||
| 53969 | 453 | subsubsection {* @{text fsingleton} *}
 | 
| 53953 | 454 | |
| 455 | lemmas fsingletonE = fsingletonD [elim_format] | |
| 456 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 457 | |
| 53969 | 458 | subsubsection {* @{text femepty} *}
 | 
| 53953 | 459 | |
| 460 | lemma fempty_ffilter[simp]: "ffilter (\<lambda>_. False) A = {||}"
 | |
| 461 | by transfer auto | |
| 462 | ||
| 463 | (* FIXME, transferred doesn't work here *) | |
| 464 | lemma femptyE [elim!]: "a |\<in>| {||} \<Longrightarrow> P"
 | |
| 465 | by simp | |
| 466 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 467 | |
| 53969 | 468 | subsubsection {* @{text fset} *}
 | 
| 53953 | 469 | |
| 53963 | 470 | lemmas fset_simps[simp] = bot_fset.rep_eq finsert.rep_eq | 
| 53953 | 471 | |
| 472 | lemma finite_fset [simp]: | |
| 473 | shows "finite (fset S)" | |
| 474 | by transfer simp | |
| 475 | ||
| 53963 | 476 | lemmas fset_cong = fset_inject | 
| 53953 | 477 | |
| 478 | lemma filter_fset [simp]: | |
| 479 | shows "fset (ffilter P xs) = Collect P \<inter> fset xs" | |
| 480 | by transfer auto | |
| 481 | ||
| 53963 | 482 | lemma notin_fset: "x |\<notin>| S \<longleftrightarrow> x \<notin> fset S" by (simp add: fmember.rep_eq) | 
| 483 | ||
| 484 | lemmas inter_fset[simp] = inf_fset.rep_eq | |
| 53953 | 485 | |
| 53963 | 486 | lemmas union_fset[simp] = sup_fset.rep_eq | 
| 53953 | 487 | |
| 53963 | 488 | lemmas minus_fset[simp] = minus_fset.rep_eq | 
| 53953 | 489 | |
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 490 | |
| 53969 | 491 | subsubsection {* @{text filter_fset} *}
 | 
| 53953 | 492 | |
| 493 | lemma subset_ffilter: | |
| 494 | "ffilter P A |\<subseteq>| ffilter Q A = (\<forall> x. x |\<in>| A \<longrightarrow> P x \<longrightarrow> Q x)" | |
| 495 | by transfer auto | |
| 496 | ||
| 497 | lemma eq_ffilter: | |
| 498 | "(ffilter P A = ffilter Q A) = (\<forall>x. x |\<in>| A \<longrightarrow> P x = Q x)" | |
| 499 | by transfer auto | |
| 500 | ||
| 53964 | 501 | lemma pfsubset_ffilter: | 
| 53953 | 502 | "(\<And>x. x |\<in>| A \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| A & \<not> P x & Q x) \<Longrightarrow> | 
| 503 | ffilter P A |\<subset>| ffilter Q A" | |
| 504 | unfolding less_fset_def by (auto simp add: subset_ffilter eq_ffilter) | |
| 505 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 506 | |
| 53969 | 507 | subsubsection {* @{text finsert} *}
 | 
| 53953 | 508 | |
| 509 | (* FIXME, transferred doesn't work here *) | |
| 510 | lemma set_finsert: | |
| 511 | assumes "x |\<in>| A" | |
| 512 | obtains B where "A = finsert x B" and "x |\<notin>| B" | |
| 513 | using assms by transfer (metis Set.set_insert finite_insert) | |
| 514 | ||
| 515 | lemma mk_disjoint_finsert: "a |\<in>| A \<Longrightarrow> \<exists>B. A = finsert a B \<and> a |\<notin>| B" | |
| 516 |   by (rule_tac x = "A |-| {|a|}" in exI, blast)
 | |
| 517 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 518 | |
| 53969 | 519 | subsubsection {* @{text fimage} *}
 | 
| 53953 | 520 | |
| 521 | lemma subset_fimage_iff: "(B |\<subseteq>| f|`|A) = (\<exists> AA. AA |\<subseteq>| A \<and> B = f|`|AA)" | |
| 522 | by transfer (metis mem_Collect_eq rev_finite_subset subset_image_iff) | |
| 523 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 524 | |
| 53953 | 525 | subsubsection {* bounded quantification *}
 | 
| 526 | ||
| 527 | lemma bex_simps [simp, no_atp]: | |
| 528 | "\<And>A P Q. fBex A (\<lambda>x. P x \<and> Q) = (fBex A P \<and> Q)" | |
| 529 | "\<And>A P Q. fBex A (\<lambda>x. P \<and> Q x) = (P \<and> fBex A Q)" | |
| 530 |   "\<And>P. fBex {||} P = False" 
 | |
| 531 | "\<And>a B P. fBex (finsert a B) P = (P a \<or> fBex B P)" | |
| 532 | "\<And>A P f. fBex (f |`| A) P = fBex A (\<lambda>x. P (f x))" | |
| 533 | "\<And>A P. (\<not> fBex A P) = fBall A (\<lambda>x. \<not> P x)" | |
| 534 | by auto | |
| 535 | ||
| 536 | lemma ball_simps [simp, no_atp]: | |
| 537 | "\<And>A P Q. fBall A (\<lambda>x. P x \<or> Q) = (fBall A P \<or> Q)" | |
| 538 | "\<And>A P Q. fBall A (\<lambda>x. P \<or> Q x) = (P \<or> fBall A Q)" | |
| 539 | "\<And>A P Q. fBall A (\<lambda>x. P \<longrightarrow> Q x) = (P \<longrightarrow> fBall A Q)" | |
| 540 | "\<And>A P Q. fBall A (\<lambda>x. P x \<longrightarrow> Q) = (fBex A P \<longrightarrow> Q)" | |
| 541 |   "\<And>P. fBall {||} P = True"
 | |
| 542 | "\<And>a B P. fBall (finsert a B) P = (P a \<and> fBall B P)" | |
| 543 | "\<And>A P f. fBall (f |`| A) P = fBall A (\<lambda>x. P (f x))" | |
| 544 | "\<And>A P. (\<not> fBall A P) = fBex A (\<lambda>x. \<not> P x)" | |
| 545 | by auto | |
| 546 | ||
| 547 | lemma atomize_fBall: | |
| 548 | "(\<And>x. x |\<in>| A ==> P x) == Trueprop (fBall A (\<lambda>x. P x))" | |
| 549 | apply (simp only: atomize_all atomize_imp) | |
| 550 | apply (rule equal_intr_rule) | |
| 551 | by (transfer, simp)+ | |
| 552 | ||
| 53963 | 553 | end | 
| 554 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 555 | |
| 53969 | 556 | subsubsection {* @{text fcard} *}
 | 
| 53963 | 557 | |
| 53964 | 558 | (* FIXME: improve transferred to handle bounded meta quantification *) | 
| 559 | ||
| 53963 | 560 | lemma fcard_fempty: | 
| 561 |   "fcard {||} = 0"
 | |
| 562 | by transfer (rule card_empty) | |
| 563 | ||
| 564 | lemma fcard_finsert_disjoint: | |
| 565 | "x |\<notin>| A \<Longrightarrow> fcard (finsert x A) = Suc (fcard A)" | |
| 566 | by transfer (rule card_insert_disjoint) | |
| 567 | ||
| 568 | lemma fcard_finsert_if: | |
| 569 | "fcard (finsert x A) = (if x |\<in>| A then fcard A else Suc (fcard A))" | |
| 570 | by transfer (rule card_insert_if) | |
| 571 | ||
| 572 | lemma card_0_eq [simp, no_atp]: | |
| 573 |   "fcard A = 0 \<longleftrightarrow> A = {||}"
 | |
| 574 | by transfer (rule card_0_eq) | |
| 575 | ||
| 576 | lemma fcard_Suc_fminus1: | |
| 577 |   "x |\<in>| A \<Longrightarrow> Suc (fcard (A |-| {|x|})) = fcard A"
 | |
| 578 | by transfer (rule card_Suc_Diff1) | |
| 579 | ||
| 580 | lemma fcard_fminus_fsingleton: | |
| 581 |   "x |\<in>| A \<Longrightarrow> fcard (A |-| {|x|}) = fcard A - 1"
 | |
| 582 | by transfer (rule card_Diff_singleton) | |
| 583 | ||
| 584 | lemma fcard_fminus_fsingleton_if: | |
| 585 |   "fcard (A |-| {|x|}) = (if x |\<in>| A then fcard A - 1 else fcard A)"
 | |
| 586 | by transfer (rule card_Diff_singleton_if) | |
| 587 | ||
| 588 | lemma fcard_fminus_finsert[simp]: | |
| 589 | assumes "a |\<in>| A" and "a |\<notin>| B" | |
| 590 | shows "fcard (A |-| finsert a B) = fcard (A |-| B) - 1" | |
| 591 | using assms by transfer (rule card_Diff_insert) | |
| 592 | ||
| 593 | lemma fcard_finsert: "fcard (finsert x A) = Suc (fcard (A |-| {|x|}))"
 | |
| 594 | by transfer (rule card_insert) | |
| 595 | ||
| 596 | lemma fcard_finsert_le: "fcard A \<le> fcard (finsert x A)" | |
| 597 | by transfer (rule card_insert_le) | |
| 598 | ||
| 599 | lemma fcard_mono: | |
| 600 | "A |\<subseteq>| B \<Longrightarrow> fcard A \<le> fcard B" | |
| 601 | by transfer (rule card_mono) | |
| 602 | ||
| 603 | lemma fcard_seteq: "A |\<subseteq>| B \<Longrightarrow> fcard B \<le> fcard A \<Longrightarrow> A = B" | |
| 604 | by transfer (rule card_seteq) | |
| 605 | ||
| 606 | lemma pfsubset_fcard_mono: "A |\<subset>| B \<Longrightarrow> fcard A < fcard B" | |
| 607 | by transfer (rule psubset_card_mono) | |
| 608 | ||
| 609 | lemma fcard_funion_finter: | |
| 610 | "fcard A + fcard B = fcard (A |\<union>| B) + fcard (A |\<inter>| B)" | |
| 611 | by transfer (rule card_Un_Int) | |
| 612 | ||
| 613 | lemma fcard_funion_disjoint: | |
| 614 |   "A |\<inter>| B = {||} \<Longrightarrow> fcard (A |\<union>| B) = fcard A + fcard B"
 | |
| 615 | by transfer (rule card_Un_disjoint) | |
| 616 | ||
| 617 | lemma fcard_funion_fsubset: | |
| 618 | "B |\<subseteq>| A \<Longrightarrow> fcard (A |-| B) = fcard A - fcard B" | |
| 619 | by transfer (rule card_Diff_subset) | |
| 620 | ||
| 621 | lemma diff_fcard_le_fcard_fminus: | |
| 622 | "fcard A - fcard B \<le> fcard(A |-| B)" | |
| 623 | by transfer (rule diff_card_le_card_Diff) | |
| 624 | ||
| 625 | lemma fcard_fminus1_less: "x |\<in>| A \<Longrightarrow> fcard (A |-| {|x|}) < fcard A"
 | |
| 626 | by transfer (rule card_Diff1_less) | |
| 627 | ||
| 628 | lemma fcard_fminus2_less: | |
| 629 |   "x |\<in>| A \<Longrightarrow> y |\<in>| A \<Longrightarrow> fcard (A |-| {|x|} |-| {|y|}) < fcard A"
 | |
| 630 | by transfer (rule card_Diff2_less) | |
| 631 | ||
| 632 | lemma fcard_fminus1_le: "fcard (A |-| {|x|}) \<le> fcard A"
 | |
| 633 | by transfer (rule card_Diff1_le) | |
| 634 | ||
| 635 | lemma fcard_pfsubset: "A |\<subseteq>| B \<Longrightarrow> fcard A < fcard B \<Longrightarrow> A < B" | |
| 636 | by transfer (rule card_psubset) | |
| 637 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 638 | |
| 53969 | 639 | subsubsection {* @{text ffold} *}
 | 
| 53963 | 640 | |
| 641 | (* FIXME: improve transferred to handle bounded meta quantification *) | |
| 642 | ||
| 643 | context comp_fun_commute | |
| 644 | begin | |
| 645 | lemmas ffold_empty[simp] = fold_empty[Transfer.transferred] | |
| 646 | ||
| 647 | lemma ffold_finsert [simp]: | |
| 648 | assumes "x |\<notin>| A" | |
| 649 | shows "ffold f z (finsert x A) = f x (ffold f z A)" | |
| 650 | using assms by (transfer fixing: f) (rule fold_insert) | |
| 651 | ||
| 652 | lemma ffold_fun_left_comm: | |
| 653 | "f x (ffold f z A) = ffold f (f x z) A" | |
| 654 | by (transfer fixing: f) (rule fold_fun_left_comm) | |
| 655 | ||
| 656 | lemma ffold_finsert2: | |
| 657 | "x |\<notin>| A \<Longrightarrow> ffold f z (finsert x A) = ffold f (f x z) A" | |
| 658 | by (transfer fixing: f) (rule fold_insert2) | |
| 659 | ||
| 660 | lemma ffold_rec: | |
| 661 | assumes "x |\<in>| A" | |
| 662 |     shows "ffold f z A = f x (ffold f z (A |-| {|x|}))"
 | |
| 663 | using assms by (transfer fixing: f) (rule fold_rec) | |
| 664 | ||
| 665 | lemma ffold_finsert_fremove: | |
| 666 |     "ffold f z (finsert x A) = f x (ffold f z (A |-| {|x|}))"
 | |
| 667 | by (transfer fixing: f) (rule fold_insert_remove) | |
| 668 | end | |
| 669 | ||
| 670 | lemma ffold_fimage: | |
| 671 | assumes "inj_on g (fset A)" | |
| 672 | shows "ffold f z (g |`| A) = ffold (f \<circ> g) z A" | |
| 673 | using assms by transfer' (rule fold_image) | |
| 674 | ||
| 675 | lemma ffold_cong: | |
| 676 | assumes "comp_fun_commute f" "comp_fun_commute g" | |
| 677 | "\<And>x. x |\<in>| A \<Longrightarrow> f x = g x" | |
| 678 | and "s = t" and "A = B" | |
| 679 | shows "ffold f s A = ffold g t B" | |
| 680 | using assms by transfer (metis Finite_Set.fold_cong) | |
| 681 | ||
| 682 | context comp_fun_idem | |
| 683 | begin | |
| 684 | ||
| 685 | lemma ffold_finsert_idem: | |
| 686 | "ffold f z (finsert x A) = f x (ffold f z A)" | |
| 687 | by (transfer fixing: f) (rule fold_insert_idem) | |
| 688 | ||
| 689 | declare ffold_finsert [simp del] ffold_finsert_idem [simp] | |
| 690 | ||
| 691 | lemma ffold_finsert_idem2: | |
| 692 | "ffold f z (finsert x A) = ffold f (f x z) A" | |
| 693 | by (transfer fixing: f) (rule fold_insert_idem2) | |
| 694 | ||
| 695 | end | |
| 696 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 697 | |
| 53953 | 698 | subsection {* Choice in fsets *}
 | 
| 699 | ||
| 700 | lemma fset_choice: | |
| 701 | assumes "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y)" | |
| 702 | shows "\<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)" | |
| 703 | using assms by transfer metis | |
| 704 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 705 | |
| 53953 | 706 | subsection {* Induction and Cases rules for fsets *}
 | 
| 707 | ||
| 708 | lemma fset_exhaust [case_names empty insert, cases type: fset]: | |
| 709 |   assumes fempty_case: "S = {||} \<Longrightarrow> P" 
 | |
| 710 | and finsert_case: "\<And>x S'. S = finsert x S' \<Longrightarrow> P" | |
| 711 | shows "P" | |
| 712 | using assms by transfer blast | |
| 713 | ||
| 714 | lemma fset_induct [case_names empty insert]: | |
| 715 |   assumes fempty_case: "P {||}"
 | |
| 716 | and finsert_case: "\<And>x S. P S \<Longrightarrow> P (finsert x S)" | |
| 717 | shows "P S" | |
| 718 | proof - | |
| 719 | (* FIXME transfer and right_total vs. bi_total *) | |
| 720 | note Domainp_forall_transfer[transfer_rule] | |
| 721 | show ?thesis | |
| 722 | using assms by transfer (auto intro: finite_induct) | |
| 723 | qed | |
| 724 | ||
| 725 | lemma fset_induct_stronger [case_names empty insert, induct type: fset]: | |
| 726 |   assumes empty_fset_case: "P {||}"
 | |
| 727 | and insert_fset_case: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (finsert x S)" | |
| 728 | shows "P S" | |
| 729 | proof - | |
| 730 | (* FIXME transfer and right_total vs. bi_total *) | |
| 731 | note Domainp_forall_transfer[transfer_rule] | |
| 732 | show ?thesis | |
| 733 | using assms by transfer (auto intro: finite_induct) | |
| 734 | qed | |
| 735 | ||
| 736 | lemma fset_card_induct: | |
| 737 |   assumes empty_fset_case: "P {||}"
 | |
| 738 | and card_fset_Suc_case: "\<And>S T. Suc (fcard S) = (fcard T) \<Longrightarrow> P S \<Longrightarrow> P T" | |
| 739 | shows "P S" | |
| 740 | proof (induct S) | |
| 741 | case empty | |
| 742 |   show "P {||}" by (rule empty_fset_case)
 | |
| 743 | next | |
| 744 | case (insert x S) | |
| 745 | have h: "P S" by fact | |
| 746 | have "x |\<notin>| S" by fact | |
| 747 | then have "Suc (fcard S) = fcard (finsert x S)" | |
| 748 | by transfer auto | |
| 749 | then show "P (finsert x S)" | |
| 750 | using h card_fset_Suc_case by simp | |
| 751 | qed | |
| 752 | ||
| 753 | lemma fset_strong_cases: | |
| 754 |   obtains "xs = {||}"
 | |
| 755 | | ys x where "x |\<notin>| ys" and "xs = finsert x ys" | |
| 756 | by transfer blast | |
| 757 | ||
| 758 | lemma fset_induct2: | |
| 759 |   "P {||} {||} \<Longrightarrow>
 | |
| 760 |   (\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (finsert x xs) {||}) \<Longrightarrow>
 | |
| 761 |   (\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (finsert y ys)) \<Longrightarrow>
 | |
| 762 | (\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (finsert x xs) (finsert y ys)) \<Longrightarrow> | |
| 763 | P xsa ysa" | |
| 764 | apply (induct xsa arbitrary: ysa) | |
| 765 | apply (induct_tac x rule: fset_induct_stronger) | |
| 766 | apply simp_all | |
| 767 | apply (induct_tac xa rule: fset_induct_stronger) | |
| 768 | apply simp_all | |
| 769 | done | |
| 770 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 771 | |
| 53953 | 772 | subsection {* Setup for Lifting/Transfer *}
 | 
| 773 | ||
| 774 | subsubsection {* Relator and predicator properties *}
 | |
| 775 | ||
| 776 | lift_definition fset_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'b fset \<Rightarrow> bool" is set_rel
 | |
| 55565 
f663fc1e653b
simplify proofs because of the stronger reflexivity prover
 kuncar parents: 
55414diff
changeset | 777 | parametric set_rel_transfer . | 
| 53953 | 778 | |
| 779 | lemma fset_rel_alt_def: "fset_rel R = (\<lambda>A B. (\<forall>x.\<exists>y. x|\<in>|A \<longrightarrow> y|\<in>|B \<and> R x y) | |
| 780 | \<and> (\<forall>y. \<exists>x. y|\<in>|B \<longrightarrow> x|\<in>|A \<and> R x y))" | |
| 781 | apply (rule ext)+ | |
| 782 | apply transfer' | |
| 783 | apply (subst set_rel_def[unfolded fun_eq_iff]) | |
| 784 | by blast | |
| 785 | ||
| 786 | lemma fset_rel_conversep: "fset_rel (conversep R) = conversep (fset_rel R)" | |
| 787 | unfolding fset_rel_alt_def by auto | |
| 788 | ||
| 789 | lemmas fset_rel_eq [relator_eq] = set_rel_eq[Transfer.transferred] | |
| 790 | ||
| 791 | lemma fset_rel_mono[relator_mono]: "A \<le> B \<Longrightarrow> fset_rel A \<le> fset_rel B" | |
| 792 | unfolding fset_rel_alt_def by blast | |
| 793 | ||
| 794 | lemma finite_set_rel: | |
| 795 | assumes fin: "finite X" "finite Z" | |
| 796 | assumes R_S: "set_rel (R OO S) X Z" | |
| 797 | shows "\<exists>Y. finite Y \<and> set_rel R X Y \<and> set_rel S Y Z" | |
| 798 | proof - | |
| 799 | obtain f where f: "\<forall>x\<in>X. R x (f x) \<and> (\<exists>z\<in>Z. S (f x) z)" | |
| 800 | apply atomize_elim | |
| 801 | apply (subst bchoice_iff[symmetric]) | |
| 802 | using R_S[unfolded set_rel_def OO_def] by blast | |
| 803 | ||
| 804 | obtain g where g: "\<forall>z\<in>Z. S (g z) z \<and> (\<exists>x\<in>X. R x (g z))" | |
| 805 | apply atomize_elim | |
| 806 | apply (subst bchoice_iff[symmetric]) | |
| 807 | using R_S[unfolded set_rel_def OO_def] by blast | |
| 808 | ||
| 809 | let ?Y = "f ` X \<union> g ` Z" | |
| 810 | have "finite ?Y" by (simp add: fin) | |
| 811 | moreover have "set_rel R X ?Y" | |
| 812 | unfolding set_rel_def | |
| 813 | using f g by clarsimp blast | |
| 814 | moreover have "set_rel S ?Y Z" | |
| 815 | unfolding set_rel_def | |
| 816 | using f g by clarsimp blast | |
| 817 | ultimately show ?thesis by metis | |
| 818 | qed | |
| 819 | ||
| 820 | lemma fset_rel_OO[relator_distr]: "fset_rel R OO fset_rel S = fset_rel (R OO S)" | |
| 821 | apply (rule ext)+ | |
| 822 | by transfer (auto intro: finite_set_rel set_rel_OO[unfolded fun_eq_iff, rule_format, THEN iffD1]) | |
| 823 | ||
| 824 | lemma Domainp_fset[relator_domain]: | |
| 825 | assumes "Domainp T = P" | |
| 826 | shows "Domainp (fset_rel T) = (\<lambda>A. fBall A P)" | |
| 827 | proof - | |
| 828 | from assms obtain f where f: "\<forall>x\<in>Collect P. T x (f x)" | |
| 829 | unfolding Domainp_iff[abs_def] | |
| 830 | apply atomize_elim | |
| 831 | by (subst bchoice_iff[symmetric]) auto | |
| 832 | from assms f show ?thesis | |
| 833 | unfolding fun_eq_iff fset_rel_alt_def Domainp_iff | |
| 834 | apply clarify | |
| 835 | apply (rule iffI) | |
| 836 | apply blast | |
| 837 | by (rename_tac A, rule_tac x="f |`| A" in exI, blast) | |
| 838 | qed | |
| 839 | ||
| 840 | lemma right_total_fset_rel[transfer_rule]: "right_total A \<Longrightarrow> right_total (fset_rel A)" | |
| 841 | unfolding right_total_def | |
| 842 | apply transfer | |
| 843 | apply (subst(asm) choice_iff) | |
| 844 | apply clarsimp | |
| 845 | apply (rename_tac A f y, rule_tac x = "f ` y" in exI) | |
| 846 | by (auto simp add: set_rel_def) | |
| 847 | ||
| 848 | lemma left_total_fset_rel[reflexivity_rule]: "left_total A \<Longrightarrow> left_total (fset_rel A)" | |
| 849 | unfolding left_total_def | |
| 850 | apply transfer | |
| 851 | apply (subst(asm) choice_iff) | |
| 852 | apply clarsimp | |
| 853 | apply (rename_tac A f y, rule_tac x = "f ` y" in exI) | |
| 854 | by (auto simp add: set_rel_def) | |
| 855 | ||
| 856 | lemmas right_unique_fset_rel[transfer_rule] = right_unique_set_rel[Transfer.transferred] | |
| 857 | lemmas left_unique_fset_rel[reflexivity_rule] = left_unique_set_rel[Transfer.transferred] | |
| 858 | ||
| 859 | thm right_unique_fset_rel left_unique_fset_rel | |
| 860 | ||
| 861 | lemma bi_unique_fset_rel[transfer_rule]: "bi_unique A \<Longrightarrow> bi_unique (fset_rel A)" | |
| 862 | by (auto intro: right_unique_fset_rel left_unique_fset_rel iff: bi_unique_iff) | |
| 863 | ||
| 864 | lemma bi_total_fset_rel[transfer_rule]: "bi_total A \<Longrightarrow> bi_total (fset_rel A)" | |
| 865 | by (auto intro: right_total_fset_rel left_total_fset_rel iff: bi_total_iff) | |
| 866 | ||
| 867 | lemmas fset_invariant_commute [invariant_commute] = set_invariant_commute[Transfer.transferred] | |
| 868 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 869 | |
| 53953 | 870 | subsubsection {* Quotient theorem for the Lifting package *}
 | 
| 871 | ||
| 872 | lemma Quotient_fset_map[quot_map]: | |
| 873 | assumes "Quotient R Abs Rep T" | |
| 874 | shows "Quotient (fset_rel R) (fimage Abs) (fimage Rep) (fset_rel T)" | |
| 875 | using assms unfolding Quotient_alt_def4 | |
| 876 | by (simp add: fset_rel_OO[symmetric] fset_rel_conversep) (simp add: fset_rel_alt_def, blast) | |
| 877 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 878 | |
| 53953 | 879 | subsubsection {* Transfer rules for the Transfer package *}
 | 
| 880 | ||
| 881 | text {* Unconditional transfer rules *}
 | |
| 882 | ||
| 53963 | 883 | context | 
| 884 | begin | |
| 885 | ||
| 886 | interpretation lifting_syntax . | |
| 887 | ||
| 53953 | 888 | lemmas fempty_transfer [transfer_rule] = empty_transfer[Transfer.transferred] | 
| 889 | ||
| 890 | lemma finsert_transfer [transfer_rule]: | |
| 891 | "(A ===> fset_rel A ===> fset_rel A) finsert finsert" | |
| 892 | unfolding fun_rel_def fset_rel_alt_def by blast | |
| 893 | ||
| 894 | lemma funion_transfer [transfer_rule]: | |
| 895 | "(fset_rel A ===> fset_rel A ===> fset_rel A) funion funion" | |
| 896 | unfolding fun_rel_def fset_rel_alt_def by blast | |
| 897 | ||
| 898 | lemma ffUnion_transfer [transfer_rule]: | |
| 899 | "(fset_rel (fset_rel A) ===> fset_rel A) ffUnion ffUnion" | |
| 900 | unfolding fun_rel_def fset_rel_alt_def by transfer (simp, fast) | |
| 901 | ||
| 902 | lemma fimage_transfer [transfer_rule]: | |
| 903 | "((A ===> B) ===> fset_rel A ===> fset_rel B) fimage fimage" | |
| 904 | unfolding fun_rel_def fset_rel_alt_def by simp blast | |
| 905 | ||
| 906 | lemma fBall_transfer [transfer_rule]: | |
| 907 | "(fset_rel A ===> (A ===> op =) ===> op =) fBall fBall" | |
| 908 | unfolding fset_rel_alt_def fun_rel_def by blast | |
| 909 | ||
| 910 | lemma fBex_transfer [transfer_rule]: | |
| 911 | "(fset_rel A ===> (A ===> op =) ===> op =) fBex fBex" | |
| 912 | unfolding fset_rel_alt_def fun_rel_def by blast | |
| 913 | ||
| 914 | (* FIXME transfer doesn't work here *) | |
| 915 | lemma fPow_transfer [transfer_rule]: | |
| 916 | "(fset_rel A ===> fset_rel (fset_rel A)) fPow fPow" | |
| 917 | unfolding fun_rel_def | |
| 918 | using Pow_transfer[unfolded fun_rel_def, rule_format, Transfer.transferred] | |
| 919 | by blast | |
| 920 | ||
| 921 | lemma fset_rel_transfer [transfer_rule]: | |
| 922 | "((A ===> B ===> op =) ===> fset_rel A ===> fset_rel B ===> op =) | |
| 923 | fset_rel fset_rel" | |
| 924 | unfolding fun_rel_def | |
| 925 | using set_rel_transfer[unfolded fun_rel_def,rule_format, Transfer.transferred, where A = A and B = B] | |
| 926 | by simp | |
| 927 | ||
| 928 | lemma bind_transfer [transfer_rule]: | |
| 929 | "(fset_rel A ===> (A ===> fset_rel B) ===> fset_rel B) fbind fbind" | |
| 930 | using assms unfolding fun_rel_def | |
| 931 | using bind_transfer[unfolded fun_rel_def, rule_format, Transfer.transferred] by blast | |
| 932 | ||
| 933 | text {* Rules requiring bi-unique, bi-total or right-total relations *}
 | |
| 934 | ||
| 935 | lemma fmember_transfer [transfer_rule]: | |
| 936 | assumes "bi_unique A" | |
| 937 | shows "(A ===> fset_rel A ===> op =) (op |\<in>|) (op |\<in>|)" | |
| 938 | using assms unfolding fun_rel_def fset_rel_alt_def bi_unique_def by metis | |
| 939 | ||
| 940 | lemma finter_transfer [transfer_rule]: | |
| 941 | assumes "bi_unique A" | |
| 942 | shows "(fset_rel A ===> fset_rel A ===> fset_rel A) finter finter" | |
| 943 | using assms unfolding fun_rel_def | |
| 944 | using inter_transfer[unfolded fun_rel_def, rule_format, Transfer.transferred] by blast | |
| 945 | ||
| 53963 | 946 | lemma fminus_transfer [transfer_rule]: | 
| 53953 | 947 | assumes "bi_unique A" | 
| 948 | shows "(fset_rel A ===> fset_rel A ===> fset_rel A) (op |-|) (op |-|)" | |
| 949 | using assms unfolding fun_rel_def | |
| 950 | using Diff_transfer[unfolded fun_rel_def, rule_format, Transfer.transferred] by blast | |
| 951 | ||
| 952 | lemma fsubset_transfer [transfer_rule]: | |
| 953 | assumes "bi_unique A" | |
| 954 | shows "(fset_rel A ===> fset_rel A ===> op =) (op |\<subseteq>|) (op |\<subseteq>|)" | |
| 955 | using assms unfolding fun_rel_def | |
| 956 | using subset_transfer[unfolded fun_rel_def, rule_format, Transfer.transferred] by blast | |
| 957 | ||
| 958 | lemma fSup_transfer [transfer_rule]: | |
| 959 | "bi_unique A \<Longrightarrow> (set_rel (fset_rel A) ===> fset_rel A) Sup Sup" | |
| 960 | using assms unfolding fun_rel_def | |
| 961 | apply clarify | |
| 962 | apply transfer' | |
| 963 | using Sup_fset_transfer[unfolded fun_rel_def] by blast | |
| 964 | ||
| 965 | (* FIXME: add right_total_fInf_transfer *) | |
| 966 | ||
| 967 | lemma fInf_transfer [transfer_rule]: | |
| 968 | assumes "bi_unique A" and "bi_total A" | |
| 969 | shows "(set_rel (fset_rel A) ===> fset_rel A) Inf Inf" | |
| 970 | using assms unfolding fun_rel_def | |
| 971 | apply clarify | |
| 972 | apply transfer' | |
| 973 | using Inf_fset_transfer[unfolded fun_rel_def] by blast | |
| 974 | ||
| 975 | lemma ffilter_transfer [transfer_rule]: | |
| 976 | assumes "bi_unique A" | |
| 977 | shows "((A ===> op=) ===> fset_rel A ===> fset_rel A) ffilter ffilter" | |
| 978 | using assms unfolding fun_rel_def | |
| 979 | using Lifting_Set.filter_transfer[unfolded fun_rel_def, rule_format, Transfer.transferred] by blast | |
| 980 | ||
| 981 | lemma card_transfer [transfer_rule]: | |
| 982 | "bi_unique A \<Longrightarrow> (fset_rel A ===> op =) fcard fcard" | |
| 983 | using assms unfolding fun_rel_def | |
| 984 | using card_transfer[unfolded fun_rel_def, rule_format, Transfer.transferred] by blast | |
| 985 | ||
| 986 | end | |
| 987 | ||
| 988 | lifting_update fset.lifting | |
| 989 | lifting_forget fset.lifting | |
| 990 | ||
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 991 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 992 | subsection {* BNF setup *}
 | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 993 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 994 | context | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 995 | includes fset.lifting | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 996 | begin | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 997 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 998 | lemma fset_rel_alt: | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 999 | "fset_rel R a b \<longleftrightarrow> (\<forall>t \<in> fset a. \<exists>u \<in> fset b. R t u) \<and> (\<forall>t \<in> fset b. \<exists>u \<in> fset a. R u t)" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1000 | by transfer (simp add: set_rel_def) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1001 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1002 | lemma fset_to_fset: "finite A \<Longrightarrow> fset (the_inv fset A) = A" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1003 | apply (rule f_the_inv_into_f[unfolded inj_on_def]) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1004 | apply (simp add: fset_inject) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1005 | apply (rule range_eqI Abs_fset_inverse[symmetric] CollectI)+ | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1006 | . | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1007 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1008 | lemma fset_rel_aux: | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1009 | "(\<forall>t \<in> fset a. \<exists>u \<in> fset b. R t u) \<and> (\<forall>u \<in> fset b. \<exists>t \<in> fset a. R t u) \<longleftrightarrow> | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1010 |  ((BNF_Util.Grp {a. fset a \<subseteq> {(a, b). R a b}} (fimage fst))\<inverse>\<inverse> OO
 | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1011 |   BNF_Util.Grp {a. fset a \<subseteq> {(a, b). R a b}} (fimage snd)) a b" (is "?L = ?R")
 | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1012 | proof | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1013 | assume ?L | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1014 | def R' \<equiv> "the_inv fset (Collect (split R) \<inter> (fset a \<times> fset b))" (is "the_inv fset ?L'") | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1015 | have "finite ?L'" by (intro finite_Int[OF disjI2] finite_cartesian_product) (transfer, simp)+ | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1016 | hence *: "fset R' = ?L'" unfolding R'_def by (intro fset_to_fset) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1017 | show ?R unfolding Grp_def relcompp.simps conversep.simps | 
| 55414 
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
 blanchet parents: 
55129diff
changeset | 1018 | proof (intro CollectI case_prodI exI[of _ a] exI[of _ b] exI[of _ R'] conjI refl) | 
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1019 | from * show "a = fimage fst R'" using conjunct1[OF `?L`] | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1020 | by (transfer, auto simp add: image_def Int_def split: prod.splits) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1021 | from * show "b = fimage snd R'" using conjunct2[OF `?L`] | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1022 | by (transfer, auto simp add: image_def Int_def split: prod.splits) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1023 | qed (auto simp add: *) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1024 | next | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1025 | assume ?R thus ?L unfolding Grp_def relcompp.simps conversep.simps | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1026 | apply (simp add: subset_eq Ball_def) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1027 | apply (rule conjI) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1028 | apply (transfer, clarsimp, metis snd_conv) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1029 | by (transfer, clarsimp, metis fst_conv) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1030 | qed | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1031 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1032 | bnf "'a fset" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1033 | map: fimage | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1034 | sets: fset | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1035 | bd: natLeq | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1036 |   wits: "{||}"
 | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1037 | rel: fset_rel | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1038 | apply - | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1039 | apply transfer' apply simp | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1040 | apply transfer' apply force | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1041 | apply transfer apply force | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1042 | apply transfer' apply force | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1043 | apply (rule natLeq_card_order) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1044 | apply (rule natLeq_cinfinite) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1045 | apply transfer apply (metis ordLess_imp_ordLeq finite_iff_ordLess_natLeq) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1046 | apply (fastforce simp: fset_rel_alt) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1047 | apply (simp add: Grp_def relcompp.simps conversep.simps fun_eq_iff fset_rel_alt fset_rel_aux) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1048 | apply transfer apply simp | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1049 | done | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1050 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1051 | lemma fset_rel_fset: "set_rel \<chi> (fset A1) (fset A2) = fset_rel \<chi> A1 A2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1052 | by transfer (rule refl) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1053 | |
| 53953 | 1054 | end | 
| 55129 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1055 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1056 | lemmas [simp] = fset.map_comp fset.map_id fset.set_map | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1057 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1058 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1059 | subsection {* Advanced relator customization *}
 | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1060 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1061 | (* Set vs. sum relators: *) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1062 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1063 | lemma set_rel_sum_rel[simp]: | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1064 | "set_rel (sum_rel \<chi> \<phi>) A1 A2 \<longleftrightarrow> | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1065 | set_rel \<chi> (Inl -` A1) (Inl -` A2) \<and> set_rel \<phi> (Inr -` A1) (Inr -` A2)" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1066 | (is "?L \<longleftrightarrow> ?Rl \<and> ?Rr") | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1067 | proof safe | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1068 | assume L: "?L" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1069 | show ?Rl unfolding set_rel_def Bex_def vimage_eq proof safe | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1070 | fix l1 assume "Inl l1 \<in> A1" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1071 | then obtain a2 where a2: "a2 \<in> A2" and "sum_rel \<chi> \<phi> (Inl l1) a2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1072 | using L unfolding set_rel_def by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1073 | then obtain l2 where "a2 = Inl l2 \<and> \<chi> l1 l2" by (cases a2, auto) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1074 | thus "\<exists> l2. Inl l2 \<in> A2 \<and> \<chi> l1 l2" using a2 by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1075 | next | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1076 | fix l2 assume "Inl l2 \<in> A2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1077 | then obtain a1 where a1: "a1 \<in> A1" and "sum_rel \<chi> \<phi> a1 (Inl l2)" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1078 | using L unfolding set_rel_def by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1079 | then obtain l1 where "a1 = Inl l1 \<and> \<chi> l1 l2" by (cases a1, auto) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1080 | thus "\<exists> l1. Inl l1 \<in> A1 \<and> \<chi> l1 l2" using a1 by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1081 | qed | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1082 | show ?Rr unfolding set_rel_def Bex_def vimage_eq proof safe | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1083 | fix r1 assume "Inr r1 \<in> A1" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1084 | then obtain a2 where a2: "a2 \<in> A2" and "sum_rel \<chi> \<phi> (Inr r1) a2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1085 | using L unfolding set_rel_def by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1086 | then obtain r2 where "a2 = Inr r2 \<and> \<phi> r1 r2" by (cases a2, auto) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1087 | thus "\<exists> r2. Inr r2 \<in> A2 \<and> \<phi> r1 r2" using a2 by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1088 | next | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1089 | fix r2 assume "Inr r2 \<in> A2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1090 | then obtain a1 where a1: "a1 \<in> A1" and "sum_rel \<chi> \<phi> a1 (Inr r2)" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1091 | using L unfolding set_rel_def by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1092 | then obtain r1 where "a1 = Inr r1 \<and> \<phi> r1 r2" by (cases a1, auto) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1093 | thus "\<exists> r1. Inr r1 \<in> A1 \<and> \<phi> r1 r2" using a1 by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1094 | qed | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1095 | next | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1096 | assume Rl: "?Rl" and Rr: "?Rr" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1097 | show ?L unfolding set_rel_def Bex_def vimage_eq proof safe | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1098 | fix a1 assume a1: "a1 \<in> A1" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1099 | show "\<exists> a2. a2 \<in> A2 \<and> sum_rel \<chi> \<phi> a1 a2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1100 | proof(cases a1) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1101 | case (Inl l1) then obtain l2 where "Inl l2 \<in> A2 \<and> \<chi> l1 l2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1102 | using Rl a1 unfolding set_rel_def by blast | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1103 | thus ?thesis unfolding Inl by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1104 | next | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1105 | case (Inr r1) then obtain r2 where "Inr r2 \<in> A2 \<and> \<phi> r1 r2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1106 | using Rr a1 unfolding set_rel_def by blast | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1107 | thus ?thesis unfolding Inr by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1108 | qed | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1109 | next | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1110 | fix a2 assume a2: "a2 \<in> A2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1111 | show "\<exists> a1. a1 \<in> A1 \<and> sum_rel \<chi> \<phi> a1 a2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1112 | proof(cases a2) | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1113 | case (Inl l2) then obtain l1 where "Inl l1 \<in> A1 \<and> \<chi> l1 l2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1114 | using Rl a2 unfolding set_rel_def by blast | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1115 | thus ?thesis unfolding Inl by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1116 | next | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1117 | case (Inr r2) then obtain r1 where "Inr r1 \<in> A1 \<and> \<phi> r1 r2" | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1118 | using Rr a2 unfolding set_rel_def by blast | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1119 | thus ?thesis unfolding Inr by auto | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1120 | qed | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1121 | qed | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1122 | qed | 
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1123 | |
| 
26bd1cba3ab5
killed 'More_BNFs' by moving its various bits where they (now) belong
 blanchet parents: 
54258diff
changeset | 1124 | end |