351 apply (erule wpull_fmap) |
351 apply (erule wpull_fmap) |
352 apply (simp add: Gr_def relcomp_unfold converse_unfold fset_rel_def fset_rel_aux) |
352 apply (simp add: Gr_def relcomp_unfold converse_unfold fset_rel_def fset_rel_aux) |
353 apply transfer apply simp |
353 apply transfer apply simp |
354 done |
354 done |
355 |
355 |
356 lemmas [simp] = fset.map_comp' fset.map_id' fset.set_natural' |
356 lemmas [simp] = fset.map_comp' fset.map_id' fset.set_map' |
357 |
357 |
358 lemma fset_rel_fset: "set_rel \<chi> (fset A1) (fset A2) = fset_rel \<chi> A1 A2" |
358 lemma fset_rel_fset: "set_rel \<chi> (fset A1) (fset A2) = fset_rel \<chi> A1 A2" |
359 unfolding fset_rel_def set_rel_def by auto |
359 unfolding fset_rel_def set_rel_def by auto |
360 |
360 |
361 (* Countable sets *) |
361 (* Countable sets *) |
420 |
420 |
421 lemma Collect_Int_Times: |
421 lemma Collect_Int_Times: |
422 "{(x, y). R x y} \<inter> A \<times> B = {(x, y). R x y \<and> x \<in> A \<and> y \<in> B}" |
422 "{(x, y). R x y} \<inter> A \<times> B = {(x, y). R x y \<and> x \<in> A \<and> y \<in> B}" |
423 by auto |
423 by auto |
424 |
424 |
425 lemma rcset_natural': "rcset (cIm f x) = f ` rcset x" |
425 lemma rcset_map': "rcset (cIm f x) = f ` rcset x" |
426 unfolding cIm_def[abs_def] by simp |
426 unfolding cIm_def[abs_def] by simp |
427 |
427 |
428 definition cset_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a cset \<Rightarrow> 'b cset \<Rightarrow> bool" where |
428 definition cset_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a cset \<Rightarrow> 'b cset \<Rightarrow> bool" where |
429 "cset_rel R a b \<longleftrightarrow> |
429 "cset_rel R a b \<longleftrightarrow> |
430 (\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and> |
430 (\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and> |
453 qed (auto simp add: *) |
453 qed (auto simp add: *) |
454 next |
454 next |
455 assume ?R thus ?L unfolding Gr_def relcomp_unfold converse_unfold |
455 assume ?R thus ?L unfolding Gr_def relcomp_unfold converse_unfold |
456 apply (simp add: subset_eq Ball_def) |
456 apply (simp add: subset_eq Ball_def) |
457 apply (rule conjI) |
457 apply (rule conjI) |
458 apply (clarsimp, metis (lifting, no_types) rcset_natural' image_iff surjective_pairing) |
458 apply (clarsimp, metis (lifting, no_types) rcset_map' image_iff surjective_pairing) |
459 apply (clarsimp) |
459 apply (clarsimp) |
460 by (metis Domain.intros Range.simps rcset_natural' fst_eq_Domain snd_eq_Range) |
460 by (metis Domain.intros Range.simps rcset_map' fst_eq_Domain snd_eq_Range) |
461 qed |
461 qed |
462 |
462 |
463 bnf_def cIm [rcset] "\<lambda>_::'a cset. natLeq" ["cEmp"] cset_rel |
463 bnf_def cIm [rcset] "\<lambda>_::'a cset. natLeq" ["cEmp"] cset_rel |
464 proof - |
464 proof - |
465 show "cIm id = id" unfolding cIm_def[abs_def] id_def by auto |
465 show "cIm id = id" unfolding cIm_def[abs_def] id_def by auto |
1149 Zero: "multiset_rel' R {#} {#}" |
1149 Zero: "multiset_rel' R {#} {#}" |
1150 | |
1150 | |
1151 Plus: "\<lbrakk>R a b; multiset_rel' R M N\<rbrakk> \<Longrightarrow> multiset_rel' R (M + {#a#}) (N + {#b#})" |
1151 Plus: "\<lbrakk>R a b; multiset_rel' R M N\<rbrakk> \<Longrightarrow> multiset_rel' R (M + {#a#}) (N + {#b#})" |
1152 |
1152 |
1153 lemma multiset_map_Zero_iff[simp]: "multiset_map f M = {#} \<longleftrightarrow> M = {#}" |
1153 lemma multiset_map_Zero_iff[simp]: "multiset_map f M = {#} \<longleftrightarrow> M = {#}" |
1154 by (metis image_is_empty multiset.set_natural' set_of_eq_empty_iff) |
1154 by (metis image_is_empty multiset.set_map' set_of_eq_empty_iff) |
1155 |
1155 |
1156 lemma multiset_map_Zero[simp]: "multiset_map f {#} = {#}" by simp |
1156 lemma multiset_map_Zero[simp]: "multiset_map f {#} = {#}" by simp |
1157 |
1157 |
1158 lemma multiset_rel_Zero: "multiset_rel R {#} {#}" |
1158 lemma multiset_rel_Zero: "multiset_rel R {#} {#}" |
1159 unfolding multiset_rel_def Gr_def relcomp_unfold by auto |
1159 unfolding multiset_rel_def Gr_def relcomp_unfold by auto |
1285 lemma msed_map_invL: |
1285 lemma msed_map_invL: |
1286 assumes "multiset_map f (M + {#a#}) = N" |
1286 assumes "multiset_map f (M + {#a#}) = N" |
1287 shows "\<exists> N1. N = N1 + {#f a#} \<and> multiset_map f M = N1" |
1287 shows "\<exists> N1. N = N1 + {#f a#} \<and> multiset_map f M = N1" |
1288 proof- |
1288 proof- |
1289 have "f a \<in># N" |
1289 have "f a \<in># N" |
1290 using assms multiset.set_natural'[of f "M + {#a#}"] by auto |
1290 using assms multiset.set_map'[of f "M + {#a#}"] by auto |
1291 then obtain N1 where N: "N = N1 + {#f a#}" using multi_member_split by metis |
1291 then obtain N1 where N: "N = N1 + {#f a#}" using multi_member_split by metis |
1292 have "multiset_map f M = N1" using assms unfolding N by simp |
1292 have "multiset_map f M = N1" using assms unfolding N by simp |
1293 thus ?thesis using N by blast |
1293 thus ?thesis using N by blast |
1294 qed |
1294 qed |
1295 |
1295 |
1296 lemma msed_map_invR: |
1296 lemma msed_map_invR: |
1297 assumes "multiset_map f M = N + {#b#}" |
1297 assumes "multiset_map f M = N + {#b#}" |
1298 shows "\<exists> M1 a. M = M1 + {#a#} \<and> f a = b \<and> multiset_map f M1 = N" |
1298 shows "\<exists> M1 a. M = M1 + {#a#} \<and> f a = b \<and> multiset_map f M1 = N" |
1299 proof- |
1299 proof- |
1300 obtain a where a: "a \<in># M" and fa: "f a = b" |
1300 obtain a where a: "a \<in># M" and fa: "f a = b" |
1301 using multiset.set_natural'[of f M] unfolding assms |
1301 using multiset.set_map'[of f M] unfolding assms |
1302 by (metis image_iff mem_set_of_iff union_single_eq_member) |
1302 by (metis image_iff mem_set_of_iff union_single_eq_member) |
1303 then obtain M1 where M: "M = M1 + {#a#}" using multi_member_split by metis |
1303 then obtain M1 where M: "M = M1 + {#a#}" using multi_member_split by metis |
1304 have "multiset_map f M1 = N" using assms unfolding M fa[symmetric] by simp |
1304 have "multiset_map f M1 = N" using assms unfolding M fa[symmetric] by simp |
1305 thus ?thesis using M fa by blast |
1305 thus ?thesis using M fa by blast |
1306 qed |
1306 qed |