src/HOL/HOLCF/Library/List_Predomain.thy
changeset 62175 8ffc4d0e652d
parent 61169 4de9ff3ea29a
child 69597 ff784d5a5bfb
equal deleted inserted replaced
62174:fae6233c5f37 62175:8ffc4d0e652d
     1 (*  Title:      HOL/HOLCF/Library/List_Predomain.thy
     1 (*  Title:      HOL/HOLCF/Library/List_Predomain.thy
     2     Author:     Brian Huffman
     2     Author:     Brian Huffman
     3 *)
     3 *)
     4 
     4 
     5 section {* Predomain class instance for HOL list type *}
     5 section \<open>Predomain class instance for HOL list type\<close>
     6 
     6 
     7 theory List_Predomain
     7 theory List_Predomain
     8 imports List_Cpo Sum_Cpo
     8 imports List_Cpo Sum_Cpo
     9 begin
     9 begin
    10 
    10 
    11 subsection {* Strict list type *}
    11 subsection \<open>Strict list type\<close>
    12 
    12 
    13 domain 'a slist = SNil | SCons "'a" "'a slist"
    13 domain 'a slist = SNil | SCons "'a" "'a slist"
    14 
    14 
    15 text {* Polymorphic map function for strict lists. *}
    15 text \<open>Polymorphic map function for strict lists.\<close>
    16 
    16 
    17 text {* FIXME: The domain package should generate this! *}
    17 text \<open>FIXME: The domain package should generate this!\<close>
    18 
    18 
    19 fixrec slist_map' :: "('a \<rightarrow> 'b) \<rightarrow> 'a slist \<rightarrow> 'b slist"
    19 fixrec slist_map' :: "('a \<rightarrow> 'b) \<rightarrow> 'a slist \<rightarrow> 'b slist"
    20   where "slist_map'\<cdot>f\<cdot>SNil = SNil"
    20   where "slist_map'\<cdot>f\<cdot>SNil = SNil"
    21   | "\<lbrakk>x \<noteq> \<bottom>; xs \<noteq> \<bottom>\<rbrakk> \<Longrightarrow>
    21   | "\<lbrakk>x \<noteq> \<bottom>; xs \<noteq> \<bottom>\<rbrakk> \<Longrightarrow>
    22       slist_map'\<cdot>f\<cdot>(SCons\<cdot>x\<cdot>xs) = SCons\<cdot>(f\<cdot>x)\<cdot>(slist_map'\<cdot>f\<cdot>xs)"
    22       slist_map'\<cdot>f\<cdot>(SCons\<cdot>x\<cdot>xs) = SCons\<cdot>(f\<cdot>x)\<cdot>(slist_map'\<cdot>f\<cdot>xs)"
    58 apply (subst slist_map'_ID [symmetric])
    58 apply (subst slist_map'_ID [symmetric])
    59 apply (intro monofun_cfun below_refl)
    59 apply (intro monofun_cfun below_refl)
    60 apply (simp add: cfun_below_iff ep_pair.e_p_below)
    60 apply (simp add: cfun_below_iff ep_pair.e_p_below)
    61 done
    61 done
    62 
    62 
    63 text {*
    63 text \<open>
    64   Types @{typ "'a list u"}. and @{typ "'a u slist"} are isomorphic.
    64   Types @{typ "'a list u"}. and @{typ "'a u slist"} are isomorphic.
    65 *}
    65 \<close>
    66 
    66 
    67 fixrec encode_list_u where
    67 fixrec encode_list_u where
    68   "encode_list_u\<cdot>(up\<cdot>[]) = SNil" |
    68   "encode_list_u\<cdot>(up\<cdot>[]) = SNil" |
    69   "encode_list_u\<cdot>(up\<cdot>(x # xs)) = SCons\<cdot>(up\<cdot>x)\<cdot>(encode_list_u\<cdot>(up\<cdot>xs))"
    69   "encode_list_u\<cdot>(up\<cdot>(x # xs)) = SCons\<cdot>(up\<cdot>x)\<cdot>(encode_list_u\<cdot>(up\<cdot>xs))"
    70 
    70 
    92 apply (induct y, simp, simp)
    92 apply (induct y, simp, simp)
    93 apply (case_tac a, simp)
    93 apply (case_tac a, simp)
    94 apply (case_tac "decode_list_u\<cdot>y", simp, simp)
    94 apply (case_tac "decode_list_u\<cdot>y", simp, simp)
    95 done
    95 done
    96 
    96 
    97 subsection {* Lists are a predomain *}
    97 subsection \<open>Lists are a predomain\<close>
    98 
    98 
    99 definition list_liftdefl :: "udom u defl \<rightarrow> udom u defl"
    99 definition list_liftdefl :: "udom u defl \<rightarrow> udom u defl"
   100   where "list_liftdefl = (\<Lambda> a. udefl\<cdot>(slist_defl\<cdot>(u_liftdefl\<cdot>a)))"
   100   where "list_liftdefl = (\<Lambda> a. udefl\<cdot>(slist_defl\<cdot>(u_liftdefl\<cdot>a)))"
   101 
   101 
   102 lemma cast_slist_defl: "cast\<cdot>(slist_defl\<cdot>a) = emb oo slist_map\<cdot>(cast\<cdot>a) oo prj"
   102 lemma cast_slist_defl: "cast\<cdot>(slist_defl\<cdot>a) = emb oo slist_map\<cdot>(cast\<cdot>a) oo prj"
   127     done
   127     done
   128 qed
   128 qed
   129 
   129 
   130 end
   130 end
   131 
   131 
   132 subsection {* Configuring domain package to work with list type *}
   132 subsection \<open>Configuring domain package to work with list type\<close>
   133 
   133 
   134 lemma liftdefl_list [domain_defl_simps]:
   134 lemma liftdefl_list [domain_defl_simps]:
   135   "LIFTDEFL('a::predomain list) = list_liftdefl\<cdot>LIFTDEFL('a)"
   135   "LIFTDEFL('a::predomain list) = list_liftdefl\<cdot>LIFTDEFL('a)"
   136 by (rule liftdefl_list_def)
   136 by (rule liftdefl_list_def)
   137 
   137 
   165 apply (simp add: list_liftdefl_def cast_udefl cast_slist_defl cast_u_liftdefl)
   165 apply (simp add: list_liftdefl_def cast_udefl cast_slist_defl cast_u_liftdefl)
   166 apply (simp add: cfcomp1 encode_list_u_map)
   166 apply (simp add: cfcomp1 encode_list_u_map)
   167 apply (simp add: slist_map'_slist_map' u_emb_bottom)
   167 apply (simp add: slist_map'_slist_map' u_emb_bottom)
   168 done
   168 done
   169 
   169 
   170 setup {*
   170 setup \<open>
   171   Domain_Take_Proofs.add_rec_type (@{type_name "list"}, [true])
   171   Domain_Take_Proofs.add_rec_type (@{type_name "list"}, [true])
   172 *}
   172 \<close>
   173 
   173 
   174 end
   174 end