# HG changeset patch # User huffman # Date 1283900193 25200 # Node ID 3989b2b44dbaf0e38cbee3a08d6e26d2936a6542 # Parent 202618462644951dffcbb719ab10dde20c4ad90e set up Nil and Cons to work as fixrec patterns diff -r 202618462644 -r 3989b2b44dba src/HOLCF/Library/List_Cpo.thy --- a/src/HOLCF/Library/List_Cpo.thy Tue Sep 07 17:36:33 2010 +0200 +++ b/src/HOLCF/Library/List_Cpo.thy Tue Sep 07 15:56:33 2010 -0700 @@ -207,4 +207,32 @@ deserve to have continuity lemmas. I'll add more as they are needed. *} +subsection {* Using lists with fixrec *} + +definition + match_Nil :: "'a::cpo list \ 'b match \ 'b match" +where + "match_Nil = (\ xs k. case xs of [] \ k | y # ys \ Fixrec.fail)" + +definition + match_Cons :: "'a::cpo list \ ('a \ 'a list \ 'b match) \ 'b match" +where + "match_Cons = (\ xs k. case xs of [] \ Fixrec.fail | y # ys \ k\y\ys)" + +lemma match_Nil_simps [simp]: + "match_Nil\[]\k = k" + "match_Nil\(x # xs)\k = Fixrec.fail" +unfolding match_Nil_def by simp_all + +lemma match_Cons_simps [simp]: + "match_Cons\[]\k = Fixrec.fail" + "match_Cons\(x # xs)\k = k\x\xs" +unfolding match_Cons_def by simp_all + +setup {* + Fixrec.add_matchers + [ (@{const_name Nil}, @{const_name match_Nil}), + (@{const_name Cons}, @{const_name match_Cons}) ] +*} + end