src/HOL/Datatype.thy
changeset 26146 61cb176d0385
parent 26072 f65a7fa2da6c
child 26339 7825c83c9eff
equal deleted inserted replaced
26145:95670b6e1fa3 26146:61cb176d0385
   613   using c by (cases x) simp_all
   613   using c by (cases x) simp_all
   614 
   614 
   615 lemma insert_None_conv_UNIV: "insert None (range Some) = UNIV"
   615 lemma insert_None_conv_UNIV: "insert None (range Some) = UNIV"
   616   by (rule set_ext, case_tac x) auto
   616   by (rule set_ext, case_tac x) auto
   617 
   617 
   618 instantiation option :: (finite) finite
   618 instance option :: (finite) finite
   619 begin
   619   by default (simp add: insert_None_conv_UNIV [symmetric])
   620 
       
   621 definition
       
   622   "Finite_Set.itself = TYPE('a option)"
       
   623 
       
   624 instance proof
       
   625   have "finite (UNIV :: 'a set)" by (rule finite)
       
   626   hence "finite (insert None (Some ` (UNIV :: 'a set)))" by simp
       
   627   also have "insert None (Some ` (UNIV :: 'a set)) = UNIV"
       
   628     by (rule insert_None_conv_UNIV)
       
   629   finally show "finite (UNIV :: 'a option set)" .
       
   630 qed
       
   631 
       
   632 end
       
   633 
       
   634 lemma univ_option [noatp, code func]:
       
   635   "UNIV = insert (None \<Colon> 'a\<Colon>finite option) (image Some UNIV)"
       
   636   unfolding insert_None_conv_UNIV ..
       
   637 
   620 
   638 
   621 
   639 subsubsection {* Operations *}
   622 subsubsection {* Operations *}
   640 
   623 
   641 consts
   624 consts