equal
deleted
inserted
replaced
20 begin |
20 begin |
21 |
21 |
22 lemma option_rec_conv_option_case: "option_rec = option_case" |
22 lemma option_rec_conv_option_case: "option_rec = option_case" |
23 by (simp add: fun_eq_iff split: option.split) |
23 by (simp add: fun_eq_iff split: option.split) |
24 |
24 |
25 bnf_def Option.map [Option.set] "\<lambda>_::'a option. natLeq" ["None"] option_rel |
25 bnf Option.map [Option.set] "\<lambda>_::'a option. natLeq" ["None"] option_rel |
26 proof - |
26 proof - |
27 show "Option.map id = id" by (simp add: fun_eq_iff Option.map_def split: option.split) |
27 show "Option.map id = id" by (simp add: fun_eq_iff Option.map_def split: option.split) |
28 next |
28 next |
29 fix f g |
29 fix f g |
30 show "Option.map (g \<circ> f) = Option.map g \<circ> Option.map f" |
30 show "Option.map (g \<circ> f) = Option.map g \<circ> Option.map f" |
198 } |
198 } |
199 thus "\<forall>as bs. as \<in> ?B1 \<and> bs \<in> ?B2 \<and> map f1 as = map f2 bs \<longrightarrow> |
199 thus "\<forall>as bs. as \<in> ?B1 \<and> bs \<in> ?B2 \<and> map f1 as = map f2 bs \<longrightarrow> |
200 (\<exists>zs \<in> ?A. map p1 zs = as \<and> map p2 zs = bs)" by blast |
200 (\<exists>zs \<in> ?A. map p1 zs = as \<and> map p2 zs = bs)" by blast |
201 qed |
201 qed |
202 |
202 |
203 bnf_def map [set] "\<lambda>_::'a list. natLeq" ["[]"] |
203 bnf map [set] "\<lambda>_::'a list. natLeq" ["[]"] |
204 proof - |
204 proof - |
205 show "map id = id" by (rule List.map.id) |
205 show "map id = id" by (rule List.map.id) |
206 next |
206 next |
207 fix f g |
207 fix f g |
208 show "map (g o f) = map g o map f" by (rule List.map.comp[symmetric]) |
208 show "map (g o f) = map g o map f" by (rule List.map.comp[symmetric]) |
325 then obtain x where X'eq: "X' = fset x" by transfer (metis finite_list) |
325 then obtain x where X'eq: "X' = fset x" by transfer (metis finite_list) |
326 show "\<exists>x. fset x \<subseteq> A \<and> fmap p1 x = y1 \<and> fmap p2 x = y2" |
326 show "\<exists>x. fset x \<subseteq> A \<and> fmap p1 x = y1 \<and> fmap p2 x = y2" |
327 using X' Y1 Y2 by (auto simp: X'eq intro!: exI[of _ "x"]) (transfer, simp)+ |
327 using X' Y1 Y2 by (auto simp: X'eq intro!: exI[of _ "x"]) (transfer, simp)+ |
328 qed |
328 qed |
329 |
329 |
330 bnf_def fmap [fset] "\<lambda>_::'a fset. natLeq" ["{||}"] fset_rel |
330 bnf fmap [fset] "\<lambda>_::'a fset. natLeq" ["{||}"] fset_rel |
331 apply - |
331 apply - |
332 apply transfer' apply simp |
332 apply transfer' apply simp |
333 apply transfer' apply simp |
333 apply transfer' apply simp |
334 apply transfer apply force |
334 apply transfer apply force |
335 apply transfer apply force |
335 apply transfer apply force |
445 apply (clarsimp, metis (lifting, no_types) rcset_map' image_iff surjective_pairing) |
445 apply (clarsimp, metis (lifting, no_types) rcset_map' image_iff surjective_pairing) |
446 apply (clarsimp) |
446 apply (clarsimp) |
447 by (metis Domain.intros Range.simps rcset_map' fst_eq_Domain snd_eq_Range) |
447 by (metis Domain.intros Range.simps rcset_map' fst_eq_Domain snd_eq_Range) |
448 qed |
448 qed |
449 |
449 |
450 bnf_def cIm [rcset] "\<lambda>_::'a cset. natLeq" ["cEmp"] cset_rel |
450 bnf cIm [rcset] "\<lambda>_::'a cset. natLeq" ["cEmp"] cset_rel |
451 proof - |
451 proof - |
452 show "cIm id = id" unfolding cIm_def[abs_def] id_def by auto |
452 show "cIm id = id" unfolding cIm_def[abs_def] id_def by auto |
453 next |
453 next |
454 fix f g show "cIm (g \<circ> f) = cIm g \<circ> cIm f" |
454 fix f g show "cIm (g \<circ> f) = cIm g \<circ> cIm f" |
455 unfolding cIm_def[abs_def] apply(rule ext) unfolding comp_def by auto |
455 unfolding cIm_def[abs_def] apply(rule ext) unfolding comp_def by auto |
1073 qed |
1073 qed |
1074 |
1074 |
1075 definition multiset_map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a multiset \<Rightarrow> 'b multiset" where |
1075 definition multiset_map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a multiset \<Rightarrow> 'b multiset" where |
1076 "multiset_map h = Abs_multiset \<circ> mmap h \<circ> count" |
1076 "multiset_map h = Abs_multiset \<circ> mmap h \<circ> count" |
1077 |
1077 |
1078 bnf_def multiset_map [set_of] "\<lambda>_::'a multiset. natLeq" ["{#}"] |
1078 bnf multiset_map [set_of] "\<lambda>_::'a multiset. natLeq" ["{#}"] |
1079 unfolding multiset_map_def |
1079 unfolding multiset_map_def |
1080 proof - |
1080 proof - |
1081 show "Abs_multiset \<circ> mmap id \<circ> count = id" unfolding mmap_id by (auto simp: count_inverse) |
1081 show "Abs_multiset \<circ> mmap id \<circ> count = id" unfolding mmap_id by (auto simp: count_inverse) |
1082 next |
1082 next |
1083 fix f g |
1083 fix f g |