src/HOL/Library/Cardinality.thy
changeset 48060 1f4d00a7f59f
parent 48059 f6ce99d3719b
child 48062 9014e78ccde2
     1.1 --- a/src/HOL/Library/Cardinality.thy	Fri Jun 01 14:34:46 2012 +0200
     1.2 +++ b/src/HOL/Library/Cardinality.thy	Fri Jun 01 15:33:31 2012 +0200
     1.3 @@ -27,6 +27,9 @@
     1.4  lemma (in type_definition) card: "card (UNIV :: 'b set) = card A"
     1.5    by (simp add: univ card_image inj_on_def Abs_inject)
     1.6  
     1.7 +lemma finite_range_Some: "finite (range (Some :: 'a \<Rightarrow> 'a option)) = finite (UNIV :: 'a set)"
     1.8 +by(auto dest: finite_imageD intro: inj_Some)
     1.9 +
    1.10  
    1.11  subsection {* Cardinalities of types *}
    1.12  
    1.13 @@ -47,23 +50,104 @@
    1.14  lemma card_prod [simp]: "CARD('a \<times> 'b) = CARD('a) * CARD('b)"
    1.15    unfolding UNIV_Times_UNIV [symmetric] by (simp only: card_cartesian_product)
    1.16  
    1.17 +lemma card_UNIV_sum: "CARD('a + 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 then CARD('a) + CARD('b) else 0)"
    1.18 +unfolding UNIV_Plus_UNIV[symmetric]
    1.19 +by(auto simp add: card_eq_0_iff card_Plus simp del: UNIV_Plus_UNIV)
    1.20 +
    1.21  lemma card_sum [simp]: "CARD('a + 'b) = CARD('a::finite) + CARD('b::finite)"
    1.22 -  unfolding UNIV_Plus_UNIV [symmetric] by (simp only: finite card_Plus)
    1.23 +by(simp add: card_UNIV_sum)
    1.24 +
    1.25 +lemma card_UNIV_option: "CARD('a option) = (if CARD('a) = 0 then 0 else CARD('a) + 1)"
    1.26 +proof -
    1.27 +  have "(None :: 'a option) \<notin> range Some" by clarsimp
    1.28 +  thus ?thesis
    1.29 +    by(simp add: UNIV_option_conv card_eq_0_iff finite_range_Some card_insert_disjoint card_image)
    1.30 +qed
    1.31  
    1.32  lemma card_option [simp]: "CARD('a option) = Suc CARD('a::finite)"
    1.33 -  unfolding UNIV_option_conv
    1.34 -  apply (subgoal_tac "(None::'a option) \<notin> range Some")
    1.35 -  apply (simp add: card_image)
    1.36 -  apply fast
    1.37 -  done
    1.38 +by(simp add: card_UNIV_option)
    1.39 +
    1.40 +lemma card_UNIV_set: "CARD('a set) = (if CARD('a) = 0 then 0 else 2 ^ CARD('a))"
    1.41 +by(simp add: Pow_UNIV[symmetric] card_eq_0_iff card_Pow del: Pow_UNIV)
    1.42  
    1.43  lemma card_set [simp]: "CARD('a set) = 2 ^ CARD('a::finite)"
    1.44 -  unfolding Pow_UNIV [symmetric]
    1.45 -  by (simp only: card_Pow finite)
    1.46 +by(simp add: card_UNIV_set)
    1.47  
    1.48  lemma card_nat [simp]: "CARD(nat) = 0"
    1.49    by (simp add: card_eq_0_iff)
    1.50  
    1.51 +lemma card_fun: "CARD('a \<Rightarrow> 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)"
    1.52 +proof -
    1.53 +  {  assume "0 < CARD('a)" and "0 < CARD('b)"
    1.54 +    hence fina: "finite (UNIV :: 'a set)" and finb: "finite (UNIV :: 'b set)"
    1.55 +      by(simp_all only: card_ge_0_finite)
    1.56 +    from finite_distinct_list[OF finb] obtain bs 
    1.57 +      where bs: "set bs = (UNIV :: 'b set)" and distb: "distinct bs" by blast
    1.58 +    from finite_distinct_list[OF fina] obtain as
    1.59 +      where as: "set as = (UNIV :: 'a set)" and dista: "distinct as" by blast
    1.60 +    have cb: "CARD('b) = length bs"
    1.61 +      unfolding bs[symmetric] distinct_card[OF distb] ..
    1.62 +    have ca: "CARD('a) = length as"
    1.63 +      unfolding as[symmetric] distinct_card[OF dista] ..
    1.64 +    let ?xs = "map (\<lambda>ys. the o map_of (zip as ys)) (Enum.n_lists (length as) bs)"
    1.65 +    have "UNIV = set ?xs"
    1.66 +    proof(rule UNIV_eq_I)
    1.67 +      fix f :: "'a \<Rightarrow> 'b"
    1.68 +      from as have "f = the \<circ> map_of (zip as (map f as))"
    1.69 +        by(auto simp add: map_of_zip_map)
    1.70 +      thus "f \<in> set ?xs" using bs by(auto simp add: set_n_lists)
    1.71 +    qed
    1.72 +    moreover have "distinct ?xs" unfolding distinct_map
    1.73 +    proof(intro conjI distinct_n_lists distb inj_onI)
    1.74 +      fix xs ys :: "'b list"
    1.75 +      assume xs: "xs \<in> set (Enum.n_lists (length as) bs)"
    1.76 +        and ys: "ys \<in> set (Enum.n_lists (length as) bs)"
    1.77 +        and eq: "the \<circ> map_of (zip as xs) = the \<circ> map_of (zip as ys)"
    1.78 +      from xs ys have [simp]: "length xs = length as" "length ys = length as"
    1.79 +        by(simp_all add: length_n_lists_elem)
    1.80 +      have "map_of (zip as xs) = map_of (zip as ys)"
    1.81 +      proof
    1.82 +        fix x
    1.83 +        from as bs have "\<exists>y. map_of (zip as xs) x = Some y" "\<exists>y. map_of (zip as ys) x = Some y"
    1.84 +          by(simp_all add: map_of_zip_is_Some[symmetric])
    1.85 +        with eq show "map_of (zip as xs) x = map_of (zip as ys) x"
    1.86 +          by(auto dest: fun_cong[where x=x])
    1.87 +      qed
    1.88 +      with dista show "xs = ys" by(simp add: map_of_zip_inject)
    1.89 +    qed
    1.90 +    hence "card (set ?xs) = length ?xs" by(simp only: distinct_card)
    1.91 +    moreover have "length ?xs = length bs ^ length as" by(simp add: length_n_lists)
    1.92 +    ultimately have "CARD('a \<Rightarrow> 'b) = CARD('b) ^ CARD('a)" using cb ca by simp }
    1.93 +  moreover {
    1.94 +    assume cb: "CARD('b) = 1"
    1.95 +    then obtain b where b: "UNIV = {b :: 'b}" by(auto simp add: card_Suc_eq)
    1.96 +    have eq: "UNIV = {\<lambda>x :: 'a. b ::'b}"
    1.97 +    proof(rule UNIV_eq_I)
    1.98 +      fix x :: "'a \<Rightarrow> 'b"
    1.99 +      { fix y
   1.100 +        have "x y \<in> UNIV" ..
   1.101 +        hence "x y = b" unfolding b by simp }
   1.102 +      thus "x \<in> {\<lambda>x. b}" by(auto)
   1.103 +    qed
   1.104 +    have "CARD('a \<Rightarrow> 'b) = 1" unfolding eq by simp }
   1.105 +  ultimately show ?thesis
   1.106 +    by(auto simp del: One_nat_def)(auto simp add: card_eq_0_iff dest: finite_fun_UNIVD2 finite_fun_UNIVD1)
   1.107 +qed
   1.108 +
   1.109 +lemma card_nibble: "CARD(nibble) = 16"
   1.110 +unfolding UNIV_nibble by simp
   1.111 +
   1.112 +lemma card_UNIV_char: "CARD(char) = 256"
   1.113 +proof -
   1.114 +  have "inj (\<lambda>(x, y). Char x y)" by(auto intro: injI)
   1.115 +  thus ?thesis unfolding UNIV_char by(simp add: card_image card_nibble)
   1.116 +qed
   1.117 +
   1.118 +lemma card_literal: "CARD(String.literal) = 0"
   1.119 +proof -
   1.120 +  have "inj STR" by(auto intro: injI)
   1.121 +  thus ?thesis by(simp add: type_definition.univ[OF type_definition_literal] card_image infinite_UNIV_listI)
   1.122 +qed
   1.123  
   1.124  subsection {* Classes with at least 1 and 2  *}
   1.125  
   1.126 @@ -97,10 +181,6 @@
   1.127  by(auto simp add: is_list_UNIV_def Let_def card_eq_0_iff List.card_set[symmetric] 
   1.128     dest: subst[where P="finite", OF _ finite_set] card_eq_UNIV_imp_eq_UNIV)
   1.129  
   1.130 -lemma card_UNIV_eq_0_is_list_UNIV_False:
   1.131 -  "CARD('a) = 0 \<Longrightarrow> is_list_UNIV = (\<lambda>xs :: 'a list. False)"
   1.132 -by(simp add: is_list_UNIV_def[abs_def])
   1.133 -
   1.134  class card_UNIV = 
   1.135    fixes card_UNIV :: "'a itself \<Rightarrow> nat"
   1.136    assumes card_UNIV: "card_UNIV x = CARD('a)"
   1.137 @@ -108,164 +188,119 @@
   1.138  lemma card_UNIV_code [code_unfold]: "CARD('a :: card_UNIV) = card_UNIV TYPE('a)"
   1.139  by(simp add: card_UNIV)
   1.140  
   1.141 -subsection {* Instantiations for @{text "card_UNIV"} *}
   1.142 +lemma finite_UNIV_conv_card_UNIV [code_unfold]:
   1.143 +  "finite (UNIV :: 'a :: card_UNIV set) \<longleftrightarrow> card_UNIV TYPE('a) > 0"
   1.144 +by(simp add: card_UNIV card_gt_0_iff)
   1.145  
   1.146 -subsubsection {* @{typ "nat"} *}
   1.147 +subsection {* Instantiations for @{text "card_UNIV"} *}
   1.148  
   1.149  instantiation nat :: card_UNIV begin
   1.150  definition "card_UNIV_class.card_UNIV = (\<lambda>a :: nat itself. 0)"
   1.151  instance by intro_classes (simp add: card_UNIV_nat_def)
   1.152  end
   1.153  
   1.154 -subsubsection {* @{typ "int"} *}
   1.155 -
   1.156  instantiation int :: card_UNIV begin
   1.157  definition "card_UNIV = (\<lambda>a :: int itself. 0)"
   1.158  instance by intro_classes (simp add: card_UNIV_int_def infinite_UNIV_int)
   1.159  end
   1.160  
   1.161 -subsubsection {* @{typ "'a list"} *}
   1.162 -
   1.163 +print_classes
   1.164  instantiation list :: (type) card_UNIV begin
   1.165  definition "card_UNIV = (\<lambda>a :: 'a list itself. 0)"
   1.166  instance by intro_classes (simp add: card_UNIV_list_def infinite_UNIV_listI)
   1.167  end
   1.168  
   1.169 -subsubsection {* @{typ "unit"} *}
   1.170 -
   1.171  instantiation unit :: card_UNIV begin
   1.172  definition "card_UNIV = (\<lambda>a :: unit itself. 1)"
   1.173  instance by intro_classes (simp add: card_UNIV_unit_def card_UNIV_unit)
   1.174  end
   1.175  
   1.176 -subsubsection {* @{typ "bool"} *}
   1.177 -
   1.178  instantiation bool :: card_UNIV begin
   1.179  definition "card_UNIV = (\<lambda>a :: bool itself. 2)"
   1.180  instance by(intro_classes)(simp add: card_UNIV_bool_def card_UNIV_bool)
   1.181  end
   1.182  
   1.183 -subsubsection {* @{typ "char"} *}
   1.184 -
   1.185 -lemma card_UNIV_char: "card (UNIV :: char set) = 256"
   1.186 -proof -
   1.187 -  from enum_distinct
   1.188 -  have "card (set (Enum.enum :: char list)) = length (Enum.enum :: char list)"
   1.189 -    by (rule distinct_card)
   1.190 -  also have "set Enum.enum = (UNIV :: char set)" by (auto intro: in_enum)
   1.191 -  also note enum_chars
   1.192 -  finally show ?thesis by (simp add: chars_def)
   1.193 -qed
   1.194 -
   1.195  instantiation char :: card_UNIV begin
   1.196  definition "card_UNIV_class.card_UNIV = (\<lambda>a :: char itself. 256)"
   1.197  instance by intro_classes (simp add: card_UNIV_char_def card_UNIV_char)
   1.198  end
   1.199  
   1.200 -subsubsection {* @{typ "'a \<times> 'b"} *}
   1.201 -
   1.202  instantiation prod :: (card_UNIV, card_UNIV) card_UNIV begin
   1.203  definition "card_UNIV = (\<lambda>a :: ('a \<times> 'b) itself. card_UNIV (TYPE('a)) * card_UNIV (TYPE('b)))"
   1.204 -instance 
   1.205 -  by intro_classes (simp add: card_UNIV_prod_def card_UNIV UNIV_Times_UNIV[symmetric] card_cartesian_product del: UNIV_Times_UNIV)
   1.206 +instance by intro_classes (simp add: card_UNIV_prod_def card_UNIV)
   1.207  end
   1.208  
   1.209 -subsubsection {* @{typ "'a + 'b"} *}
   1.210 -
   1.211  instantiation sum :: (card_UNIV, card_UNIV) card_UNIV begin
   1.212 -definition "card_UNIV_class.card_UNIV = (\<lambda>a :: ('a + 'b) itself. 
   1.213 +definition "card_UNIV = (\<lambda>a :: ('a + 'b) itself. 
   1.214    let ca = card_UNIV (TYPE('a)); cb = card_UNIV (TYPE('b))
   1.215    in if ca \<noteq> 0 \<and> cb \<noteq> 0 then ca + cb else 0)"
   1.216 -instance
   1.217 -  by intro_classes (auto simp add: card_UNIV_sum_def card_UNIV card_eq_0_iff UNIV_Plus_UNIV[symmetric] finite_Plus_iff Let_def card_Plus simp del: UNIV_Plus_UNIV dest!: card_ge_0_finite)
   1.218 +instance by intro_classes (auto simp add: card_UNIV_sum_def card_UNIV card_UNIV_sum)
   1.219  end
   1.220  
   1.221 -subsubsection {* @{typ "'a \<Rightarrow> 'b"} *}
   1.222 -
   1.223  instantiation "fun" :: (card_UNIV, card_UNIV) card_UNIV begin
   1.224 -
   1.225 -definition "card_UNIV = 
   1.226 -  (\<lambda>a :: ('a \<Rightarrow> 'b) itself. let ca = card_UNIV (TYPE('a)); cb = card_UNIV (TYPE('b))
   1.227 -                            in if ca \<noteq> 0 \<and> cb \<noteq> 0 \<or> cb = 1 then cb ^ ca else 0)"
   1.228 -
   1.229 -instance proof
   1.230 -  fix x :: "('a \<Rightarrow> 'b) itself"
   1.231 +definition "card_UNIV = (\<lambda>a :: ('a \<Rightarrow> 'b) itself. 
   1.232 +  let ca = card_UNIV (TYPE('a)); cb = card_UNIV (TYPE('b))
   1.233 +  in if ca \<noteq> 0 \<and> cb \<noteq> 0 \<or> cb = 1 then cb ^ ca else 0)"
   1.234 +instance by intro_classes (simp add: card_UNIV_fun_def card_UNIV Let_def card_fun)
   1.235 +end
   1.236  
   1.237 -  { assume "0 < card (UNIV :: 'a set)"
   1.238 -    and "0 < card (UNIV :: 'b set)"
   1.239 -    hence fina: "finite (UNIV :: 'a set)" and finb: "finite (UNIV :: 'b set)"
   1.240 -      by(simp_all only: card_ge_0_finite)
   1.241 -    from finite_distinct_list[OF finb] obtain bs 
   1.242 -      where bs: "set bs = (UNIV :: 'b set)" and distb: "distinct bs" by blast
   1.243 -    from finite_distinct_list[OF fina] obtain as
   1.244 -      where as: "set as = (UNIV :: 'a set)" and dista: "distinct as" by blast
   1.245 -    have cb: "card (UNIV :: 'b set) = length bs"
   1.246 -      unfolding bs[symmetric] distinct_card[OF distb] ..
   1.247 -    have ca: "card (UNIV :: 'a set) = length as"
   1.248 -      unfolding as[symmetric] distinct_card[OF dista] ..
   1.249 -    let ?xs = "map (\<lambda>ys. the o map_of (zip as ys)) (Enum.n_lists (length as) bs)"
   1.250 -    have "UNIV = set ?xs"
   1.251 -    proof(rule UNIV_eq_I)
   1.252 -      fix f :: "'a \<Rightarrow> 'b"
   1.253 -      from as have "f = the \<circ> map_of (zip as (map f as))"
   1.254 -        by(auto simp add: map_of_zip_map)
   1.255 -      thus "f \<in> set ?xs" using bs by(auto simp add: set_n_lists)
   1.256 -    qed
   1.257 -    moreover have "distinct ?xs" unfolding distinct_map
   1.258 -    proof(intro conjI distinct_n_lists distb inj_onI)
   1.259 -      fix xs ys :: "'b list"
   1.260 -      assume xs: "xs \<in> set (Enum.n_lists (length as) bs)"
   1.261 -        and ys: "ys \<in> set (Enum.n_lists (length as) bs)"
   1.262 -        and eq: "the \<circ> map_of (zip as xs) = the \<circ> map_of (zip as ys)"
   1.263 -      from xs ys have [simp]: "length xs = length as" "length ys = length as"
   1.264 -        by(simp_all add: length_n_lists_elem)
   1.265 -      have "map_of (zip as xs) = map_of (zip as ys)"
   1.266 -      proof
   1.267 -        fix x
   1.268 -        from as bs have "\<exists>y. map_of (zip as xs) x = Some y" "\<exists>y. map_of (zip as ys) x = Some y"
   1.269 -          by(simp_all add: map_of_zip_is_Some[symmetric])
   1.270 -        with eq show "map_of (zip as xs) x = map_of (zip as ys) x"
   1.271 -          by(auto dest: fun_cong[where x=x])
   1.272 -      qed
   1.273 -      with dista show "xs = ys" by(simp add: map_of_zip_inject)
   1.274 -    qed
   1.275 -    hence "card (set ?xs) = length ?xs" by(simp only: distinct_card)
   1.276 -    moreover have "length ?xs = length bs ^ length as" by(simp add: length_n_lists)
   1.277 -    ultimately have "card (UNIV :: ('a \<Rightarrow> 'b) set) = card (UNIV :: 'b set) ^ card (UNIV :: 'a set)"
   1.278 -      using cb ca by simp }
   1.279 -  moreover {
   1.280 -    assume cb: "card (UNIV :: 'b set) = Suc 0"
   1.281 -    then obtain b where b: "UNIV = {b :: 'b}" by(auto simp add: card_Suc_eq)
   1.282 -    have eq: "UNIV = {\<lambda>x :: 'a. b ::'b}"
   1.283 -    proof(rule UNIV_eq_I)
   1.284 -      fix x :: "'a \<Rightarrow> 'b"
   1.285 -      { fix y
   1.286 -        have "x y \<in> UNIV" ..
   1.287 -        hence "x y = b" unfolding b by simp }
   1.288 -      thus "x \<in> {\<lambda>x. b}" by(auto)
   1.289 -    qed
   1.290 -    have "card (UNIV :: ('a \<Rightarrow> 'b) set) = Suc 0" unfolding eq by simp }
   1.291 -  ultimately show "card_UNIV x = card (UNIV :: ('a \<Rightarrow> 'b) set)"
   1.292 -    unfolding card_UNIV_fun_def card_UNIV Let_def
   1.293 -    by(auto simp del: One_nat_def)(auto simp add: card_eq_0_iff dest: finite_fun_UNIVD2 finite_fun_UNIVD1)
   1.294 -qed
   1.295 +instantiation option :: (card_UNIV) card_UNIV begin
   1.296 +definition "card_UNIV = (\<lambda>a :: 'a option itself. 
   1.297 +  let c = card_UNIV (TYPE('a)) in if c \<noteq> 0 then Suc c else 0)"
   1.298 +instance by intro_classes (simp add: card_UNIV_option_def card_UNIV card_UNIV_option)
   1.299 +end
   1.300  
   1.301 +instantiation String.literal :: card_UNIV begin
   1.302 +definition "card_UNIV = (\<lambda>a :: String.literal itself. 0)"
   1.303 +instance by intro_classes (simp add: card_UNIV_literal_def card_literal)
   1.304 +end
   1.305 +
   1.306 +instantiation set :: (card_UNIV) card_UNIV begin
   1.307 +definition "card_UNIV = (\<lambda>a :: 'a set itself.
   1.308 +  let c = card_UNIV (TYPE('a)) in if c = 0 then 0 else 2 ^ c)"
   1.309 +instance by intro_classes (simp add: card_UNIV_set_def card_UNIV_set card_UNIV)
   1.310  end
   1.311  
   1.312 -subsubsection {* @{typ "'a option"} *}
   1.313 +
   1.314 +lemma UNIV_finite_1: "UNIV = set [finite_1.a\<^isub>1]"
   1.315 +by(auto intro: finite_1.exhaust)
   1.316 +
   1.317 +lemma UNIV_finite_2: "UNIV = set [finite_2.a\<^isub>1, finite_2.a\<^isub>2]"
   1.318 +by(auto intro: finite_2.exhaust)
   1.319  
   1.320 -instantiation option :: (card_UNIV) card_UNIV
   1.321 -begin
   1.322 +lemma UNIV_finite_3: "UNIV = set [finite_3.a\<^isub>1, finite_3.a\<^isub>2, finite_3.a\<^isub>3]"
   1.323 +by(auto intro: finite_3.exhaust)
   1.324  
   1.325 -definition "card_UNIV = (\<lambda>a :: 'a option itself. let c = card_UNIV (TYPE('a)) in if c \<noteq> 0 then Suc c else 0)"
   1.326 +lemma UNIV_finite_4: "UNIV = set [finite_4.a\<^isub>1, finite_4.a\<^isub>2, finite_4.a\<^isub>3, finite_4.a\<^isub>4]"
   1.327 +by(auto intro: finite_4.exhaust)
   1.328 +
   1.329 +lemma UNIV_finite_5:
   1.330 +  "UNIV = set [finite_5.a\<^isub>1, finite_5.a\<^isub>2, finite_5.a\<^isub>3, finite_5.a\<^isub>4, finite_5.a\<^isub>5]"
   1.331 +by(auto intro: finite_5.exhaust)
   1.332  
   1.333 -instance proof
   1.334 -  fix x :: "'a option itself"
   1.335 -  show "card_UNIV x = card (UNIV :: 'a option set)"
   1.336 -    by(auto simp add: UNIV_option_conv card_UNIV_option_def card_UNIV card_eq_0_iff Let_def intro: inj_Some dest: finite_imageD)
   1.337 -      (subst card_insert_disjoint, auto simp add: card_eq_0_iff card_image inj_Some intro: finite_imageI card_ge_0_finite)
   1.338 -qed
   1.339 +instantiation Enum.finite_1 :: card_UNIV begin
   1.340 +definition "card_UNIV = (\<lambda>a :: Enum.finite_1 itself. 1)"
   1.341 +instance by intro_classes (simp add: UNIV_finite_1 card_UNIV_finite_1_def)
   1.342 +end
   1.343 +
   1.344 +instantiation Enum.finite_2 :: card_UNIV begin
   1.345 +definition "card_UNIV = (\<lambda>a :: Enum.finite_2 itself. 2)"
   1.346 +instance by intro_classes (simp add: UNIV_finite_2 card_UNIV_finite_2_def)
   1.347 +end
   1.348  
   1.349 +instantiation Enum.finite_3 :: card_UNIV begin
   1.350 +definition "card_UNIV = (\<lambda>a :: Enum.finite_3 itself. 3)"
   1.351 +instance by intro_classes (simp add: UNIV_finite_3 card_UNIV_finite_3_def)
   1.352 +end
   1.353 +
   1.354 +instantiation Enum.finite_4 :: card_UNIV begin
   1.355 +definition "card_UNIV = (\<lambda>a :: Enum.finite_4 itself. 4)"
   1.356 +instance by intro_classes (simp add: UNIV_finite_4 card_UNIV_finite_4_def)
   1.357 +end
   1.358 +
   1.359 +instantiation Enum.finite_5 :: card_UNIV begin
   1.360 +definition "card_UNIV = (\<lambda>a :: Enum.finite_5 itself. 5)"
   1.361 +instance by intro_classes (simp add: UNIV_finite_5 card_UNIV_finite_5_def)
   1.362  end
   1.363  
   1.364  subsection {* Code setup for equality on sets *}