diff -r b4aa77aef6a8 -r 182f89d83432 src/HOL/BNF_Comp.thy --- a/src/HOL/BNF_Comp.thy Tue Sep 02 14:40:14 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ -(* Title: HOL/BNF_Comp.thy - Author: Dmitriy Traytel, TU Muenchen - Author: Jasmin Blanchette, TU Muenchen - Copyright 2012, 2013, 2014 - -Composition of bounded natural functors. -*) - -header {* Composition of Bounded Natural Functors *} - -theory BNF_Comp -imports BNF_Def -begin - -lemma empty_natural: "(\_. {}) o f = image g o (\_. {})" -by (rule ext) simp - -lemma Union_natural: "Union o image (image f) = image f o Union" -by (rule ext) (auto simp only: comp_apply) - -lemma in_Union_o_assoc: "x \ (Union o gset o gmap) A \ x \ (Union o (gset o gmap)) A" -by (unfold comp_assoc) - -lemma comp_single_set_bd: - assumes fbd_Card_order: "Card_order fbd" and - fset_bd: "\x. |fset x| \o fbd" and - gset_bd: "\x. |gset x| \o gbd" - shows "|\(fset ` gset x)| \o gbd *c fbd" -apply simp -apply (rule ordLeq_transitive) -apply (rule card_of_UNION_Sigma) -apply (subst SIGMA_CSUM) -apply (rule ordLeq_transitive) -apply (rule card_of_Csum_Times') -apply (rule fbd_Card_order) -apply (rule ballI) -apply (rule fset_bd) -apply (rule ordLeq_transitive) -apply (rule cprod_mono1) -apply (rule gset_bd) -apply (rule ordIso_imp_ordLeq) -apply (rule ordIso_refl) -apply (rule Card_order_cprod) -done - -lemma csum_dup: "cinfinite r \ Card_order r \ p +c p' =o r +c r \ p +c p' =o r" -apply (erule ordIso_transitive) -apply (frule csum_absorb2') -apply (erule ordLeq_refl) -by simp - -lemma cprod_dup: "cinfinite r \ Card_order r \ p *c p' =o r *c r \ p *c p' =o r" -apply (erule ordIso_transitive) -apply (rule cprod_infinite) -by simp - -lemma Union_image_insert: "\(f ` insert a B) = f a \ \(f ` B)" -by simp - -lemma Union_image_empty: "A \ \(f ` {}) = A" -by simp - -lemma image_o_collect: "collect ((\f. image g o f) ` F) = image g o collect F" -by (rule ext) (auto simp add: collect_def) - -lemma conj_subset_def: "A \ {x. P x \ Q x} = (A \ {x. P x} \ A \ {x. Q x})" -by blast - -lemma UN_image_subset: "\(f ` g x) \ X = (g x \ {x. f x \ X})" -by blast - -lemma comp_set_bd_Union_o_collect: "|\\((\f. f x) ` X)| \o hbd \ |(Union \ collect X) x| \o hbd" -by (unfold comp_apply collect_def) simp - -lemma wpull_cong: -"\A' = A; B1' = B1; B2' = B2; wpull A B1 B2 f1 f2 p1 p2\ \ wpull A' B1' B2' f1 f2 p1 p2" -by simp - -lemma Grp_fst_snd: "(Grp (Collect (split R)) fst)^--1 OO Grp (Collect (split R)) snd = R" -unfolding Grp_def fun_eq_iff relcompp.simps by auto - -lemma OO_Grp_cong: "A = B \ (Grp A f)^--1 OO Grp A g = (Grp B f)^--1 OO Grp B g" -by (rule arg_cong) - -lemma vimage2p_relcompp_mono: "R OO S \ T \ - vimage2p f g R OO vimage2p g h S \ vimage2p f h T" - unfolding vimage2p_def by auto - -lemma type_copy_map_cong0: "M (g x) = N (h x) \ (f o M o g) x = (f o N o h) x" - by auto - -lemma type_copy_set_bd: "(\y. |S y| \o bd) \ |(S o Rep) x| \o bd" - by auto - -lemma vimage2p_cong: "R = S \ vimage2p f g R = vimage2p f g S" - by simp - -context -fixes Rep Abs -assumes type_copy: "type_definition Rep Abs UNIV" -begin - -lemma type_copy_map_id0: "M = id \ Abs o M o Rep = id" - using type_definition.Rep_inverse[OF type_copy] by auto - -lemma type_copy_map_comp0: "M = M1 o M2 \ f o M o g = (f o M1 o Rep) o (Abs o M2 o g)" - using type_definition.Abs_inverse[OF type_copy UNIV_I] by auto - -lemma type_copy_set_map0: "S o M = image f o S' \ (S o Rep) o (Abs o M o g) = image f o (S' o g)" - using type_definition.Abs_inverse[OF type_copy UNIV_I] by (auto simp: o_def fun_eq_iff) - -lemma type_copy_wit: "x \ (S o Rep) (Abs y) \ x \ S y" - using type_definition.Abs_inverse[OF type_copy UNIV_I] by auto - -lemma type_copy_vimage2p_Grp_Rep: "vimage2p f Rep (Grp (Collect P) h) = - Grp (Collect (\x. P (f x))) (Abs o h o f)" - unfolding vimage2p_def Grp_def fun_eq_iff - by (auto simp: type_definition.Abs_inverse[OF type_copy UNIV_I] - type_definition.Rep_inverse[OF type_copy] dest: sym) - -lemma type_copy_vimage2p_Grp_Abs: - "\h. vimage2p g Abs (Grp (Collect P) h) = Grp (Collect (\x. P (g x))) (Rep o h o g)" - unfolding vimage2p_def Grp_def fun_eq_iff - by (auto simp: type_definition.Abs_inverse[OF type_copy UNIV_I] - type_definition.Rep_inverse[OF type_copy] dest: sym) - -lemma type_copy_ex_RepI: "(\b. F b) = (\b. F (Rep b))" -proof safe - fix b assume "F b" - show "\b'. F (Rep b')" - proof (rule exI) - from `F b` show "F (Rep (Abs b))" using type_definition.Abs_inverse[OF type_copy] by auto - qed -qed blast - -lemma vimage2p_relcompp_converse: - "vimage2p f g (R^--1 OO S) = (vimage2p Rep f R)^--1 OO vimage2p Rep g S" - unfolding vimage2p_def relcompp.simps conversep.simps fun_eq_iff image_def - by (auto simp: type_copy_ex_RepI) - -end - -bnf DEADID: 'a - map: "id :: 'a \ 'a" - bd: natLeq - rel: "op = :: 'a \ 'a \ bool" -by (auto simp add: Grp_def natLeq_card_order natLeq_cinfinite) - -definition id_bnf_comp :: "'a \ 'a" where "id_bnf_comp \ (\x. x)" - -lemma id_bnf_comp_apply: "id_bnf_comp x = x" - unfolding id_bnf_comp_def by simp - -bnf ID: 'a - map: "id_bnf_comp :: ('a \ 'b) \ 'a \ 'b" - sets: "\x. {x}" - bd: natLeq - rel: "id_bnf_comp :: ('a \ 'b \ bool) \ 'a \ 'b \ bool" -unfolding id_bnf_comp_def -apply (auto simp: Grp_def fun_eq_iff relcompp.simps natLeq_card_order natLeq_cinfinite) -apply (rule ordLess_imp_ordLeq[OF finite_ordLess_infinite[OF _ natLeq_Well_order]]) -apply (auto simp add: Field_card_of Field_natLeq card_of_well_order_on)[3] -done - -lemma type_definition_id_bnf_comp_UNIV: "type_definition id_bnf_comp id_bnf_comp UNIV" - unfolding id_bnf_comp_def by unfold_locales auto - -ML_file "Tools/BNF/bnf_comp_tactics.ML" -ML_file "Tools/BNF/bnf_comp.ML" - -hide_const (open) id_bnf_comp -hide_fact (open) id_bnf_comp_def type_definition_id_bnf_comp_UNIV - -end