src/HOL/Library/Cardinality.thy
changeset 62597 b3f2b8c906a6
parent 62390 842917225d56
child 67091 1393c2340eec
equal deleted inserted replaced
62596:cf79f8866bc3 62597:b3f2b8c906a6
   147     by(simp add: card_fun)
   147     by(simp add: card_fun)
   148   also have "\<dots> = ?rhs" by(simp add: card_gt_0_iff)
   148   also have "\<dots> = ?rhs" by(simp add: card_gt_0_iff)
   149   finally show ?thesis .
   149   finally show ?thesis .
   150 qed
   150 qed
   151 
   151 
   152 lemma card_nibble: "CARD(nibble) = 16"
       
   153 unfolding UNIV_nibble by simp
       
   154 
       
   155 lemma card_UNIV_char: "CARD(char) = 256"
       
   156 proof -
       
   157   have "inj (\<lambda>(x, y). Char x y)" by(auto intro: injI)
       
   158   thus ?thesis unfolding UNIV_char by(simp add: card_image card_nibble)
       
   159 qed
       
   160 
       
   161 lemma card_literal: "CARD(String.literal) = 0"
   152 lemma card_literal: "CARD(String.literal) = 0"
   162 by(simp add: card_eq_0_iff infinite_literal)
   153 by(simp add: card_eq_0_iff infinite_literal)
   163 
   154 
   164 subsection \<open>Classes with at least 1 and 2\<close>
   155 subsection \<open>Classes with at least 1 and 2\<close>
   165 
   156 
   259 
   250 
   260 instantiation bool :: card_UNIV begin
   251 instantiation bool :: card_UNIV begin
   261 definition "finite_UNIV = Phantom(bool) True"
   252 definition "finite_UNIV = Phantom(bool) True"
   262 definition "card_UNIV = Phantom(bool) 2"
   253 definition "card_UNIV = Phantom(bool) 2"
   263 instance by(intro_classes)(simp_all add: card_UNIV_bool_def finite_UNIV_bool_def)
   254 instance by(intro_classes)(simp_all add: card_UNIV_bool_def finite_UNIV_bool_def)
   264 end
       
   265 
       
   266 instantiation nibble :: card_UNIV begin
       
   267 definition "finite_UNIV = Phantom(nibble) True"
       
   268 definition "card_UNIV = Phantom(nibble) 16"
       
   269 instance by(intro_classes)(simp_all add: card_UNIV_nibble_def card_nibble finite_UNIV_nibble_def)
       
   270 end
   255 end
   271 
   256 
   272 instantiation char :: card_UNIV begin
   257 instantiation char :: card_UNIV begin
   273 definition "finite_UNIV = Phantom(char) True"
   258 definition "finite_UNIV = Phantom(char) True"
   274 definition "card_UNIV = Phantom(char) 256"
   259 definition "card_UNIV = Phantom(char) 256"