src/HOL/Library/Countable_Set_Type.thy
changeset 55934 800e155d051a
parent 55565 f663fc1e653b
child 57398 882091eb1e9a
equal deleted inserted replaced
55933:12ee2c407dad 55934:800e155d051a
   122 
   122 
   123 lemma Collect_Int_Times:
   123 lemma Collect_Int_Times:
   124 "{(x, y). R x y} \<inter> A \<times> B = {(x, y). R x y \<and> x \<in> A \<and> y \<in> B}"
   124 "{(x, y). R x y} \<inter> A \<times> B = {(x, y). R x y \<and> x \<in> A \<and> y \<in> B}"
   125 by auto
   125 by auto
   126 
   126 
   127 definition cset_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a cset \<Rightarrow> 'b cset \<Rightarrow> bool" where
   127 definition rel_cset :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a cset \<Rightarrow> 'b cset \<Rightarrow> bool" where
   128 "cset_rel R a b \<longleftrightarrow>
   128 "rel_cset R a b \<longleftrightarrow>
   129  (\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and>
   129  (\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and>
   130  (\<forall>t \<in> rcset b. \<exists>u \<in> rcset a. R u t)"
   130  (\<forall>t \<in> rcset b. \<exists>u \<in> rcset a. R u t)"
   131 
   131 
   132 lemma cset_rel_aux:
   132 lemma rel_cset_aux:
   133 "(\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and> (\<forall>t \<in> rcset b. \<exists>u \<in> rcset a. R u t) \<longleftrightarrow>
   133 "(\<forall>t \<in> rcset a. \<exists>u \<in> rcset b. R t u) \<and> (\<forall>t \<in> rcset b. \<exists>u \<in> rcset a. R u t) \<longleftrightarrow>
   134  ((Grp {x. rcset x \<subseteq> {(a, b). R a b}} (cimage fst))\<inverse>\<inverse> OO
   134  ((Grp {x. rcset x \<subseteq> {(a, b). R a b}} (cimage fst))\<inverse>\<inverse> OO
   135           Grp {x. rcset x \<subseteq> {(a, b). R a b}} (cimage snd)) a b" (is "?L = ?R")
   135           Grp {x. rcset x \<subseteq> {(a, b). R a b}} (cimage snd)) a b" (is "?L = ?R")
   136 proof
   136 proof
   137   assume ?L
   137   assume ?L
   153 bnf "'a cset"
   153 bnf "'a cset"
   154   map: cimage
   154   map: cimage
   155   sets: rcset
   155   sets: rcset
   156   bd: natLeq
   156   bd: natLeq
   157   wits: "cempty"
   157   wits: "cempty"
   158   rel: cset_rel
   158   rel: rel_cset
   159 proof -
   159 proof -
   160   show "cimage id = id" by transfer' simp
   160   show "cimage id = id" by transfer' simp
   161 next
   161 next
   162   fix f g show "cimage (g \<circ> f) = cimage g \<circ> cimage f" by transfer' fastforce
   162   fix f g show "cimage (g \<circ> f) = cimage g \<circ> cimage f" by transfer' fastforce
   163 next
   163 next
   171   show "cinfinite natLeq" by (rule natLeq_cinfinite)
   171   show "cinfinite natLeq" by (rule natLeq_cinfinite)
   172 next
   172 next
   173   fix C show "|rcset C| \<le>o natLeq" by transfer (unfold countable_card_le_natLeq)
   173   fix C show "|rcset C| \<le>o natLeq" by transfer (unfold countable_card_le_natLeq)
   174 next
   174 next
   175   fix R S
   175   fix R S
   176   show "cset_rel R OO cset_rel S \<le> cset_rel (R OO S)"
   176   show "rel_cset R OO rel_cset S \<le> rel_cset (R OO S)"
   177     unfolding cset_rel_def[abs_def] by fast
   177     unfolding rel_cset_def[abs_def] by fast
   178 next
   178 next
   179   fix R
   179   fix R
   180   show "cset_rel R =
   180   show "rel_cset R =
   181         (Grp {x. rcset x \<subseteq> Collect (split R)} (cimage fst))\<inverse>\<inverse> OO
   181         (Grp {x. rcset x \<subseteq> Collect (split R)} (cimage fst))\<inverse>\<inverse> OO
   182          Grp {x. rcset x \<subseteq> Collect (split R)} (cimage snd)"
   182          Grp {x. rcset x \<subseteq> Collect (split R)} (cimage snd)"
   183   unfolding cset_rel_def[abs_def] cset_rel_aux by simp
   183   unfolding rel_cset_def[abs_def] rel_cset_aux by simp
   184 qed (transfer, simp)
   184 qed (transfer, simp)
   185 
   185 
   186 end
   186 end