src/HOLCF/Library/List_Cpo.thy
changeset 39442 3989b2b44dba
parent 39429 720112792ba0
child 39535 d7728f65b353
equal deleted inserted replaced
39441:202618462644 39442:3989b2b44dba
   205 
   205 
   206 text {* There are probably lots of other list operations that also
   206 text {* There are probably lots of other list operations that also
   207 deserve to have continuity lemmas.  I'll add more as they are
   207 deserve to have continuity lemmas.  I'll add more as they are
   208 needed. *}
   208 needed. *}
   209 
   209 
       
   210 subsection {* Using lists with fixrec *}
       
   211 
       
   212 definition
       
   213   match_Nil :: "'a::cpo list \<rightarrow> 'b match \<rightarrow> 'b match"
       
   214 where
       
   215   "match_Nil = (\<Lambda> xs k. case xs of [] \<Rightarrow> k | y # ys \<Rightarrow> Fixrec.fail)"
       
   216 
       
   217 definition
       
   218   match_Cons :: "'a::cpo list \<rightarrow> ('a \<rightarrow> 'a list \<rightarrow> 'b match) \<rightarrow> 'b match"
       
   219 where
       
   220   "match_Cons = (\<Lambda> xs k. case xs of [] \<Rightarrow> Fixrec.fail | y # ys \<Rightarrow> k\<cdot>y\<cdot>ys)"
       
   221 
       
   222 lemma match_Nil_simps [simp]:
       
   223   "match_Nil\<cdot>[]\<cdot>k = k"
       
   224   "match_Nil\<cdot>(x # xs)\<cdot>k = Fixrec.fail"
       
   225 unfolding match_Nil_def by simp_all
       
   226 
       
   227 lemma match_Cons_simps [simp]:
       
   228   "match_Cons\<cdot>[]\<cdot>k = Fixrec.fail"
       
   229   "match_Cons\<cdot>(x # xs)\<cdot>k = k\<cdot>x\<cdot>xs"
       
   230 unfolding match_Cons_def by simp_all
       
   231 
       
   232 setup {*
       
   233   Fixrec.add_matchers
       
   234     [ (@{const_name Nil}, @{const_name match_Nil}),
       
   235       (@{const_name Cons}, @{const_name match_Cons}) ]
       
   236 *}
       
   237 
   210 end
   238 end