src/HOL/HOLCF/IOA/meta_theory/Seq.thy
changeset 62002 f1599e98c4d0
parent 58880 0baae4311a9f
equal deleted inserted replaced
62001:1f2788fb0b8b 62002:f1599e98c4d0
     1 (*  Title:      HOL/HOLCF/IOA/meta_theory/Seq.thy
     1 (*  Title:      HOL/HOLCF/IOA/meta_theory/Seq.thy
     2     Author:     Olaf Müller
     2     Author:     Olaf Müller
     3 *)
     3 *)
     4 
     4 
     5 section {* Partial, Finite and Infinite Sequences (lazy lists), modeled as domain *}
     5 section \<open>Partial, Finite and Infinite Sequences (lazy lists), modeled as domain\<close>
     6 
     6 
     7 theory Seq
     7 theory Seq
     8 imports "../../HOLCF"
     8 imports "../../HOLCF"
     9 begin
     9 begin
    10 
    10 
    49   Infinite :: "'a seq => bool"
    49   Infinite :: "'a seq => bool"
    50 where
    50 where
    51   "Infinite x == ~(seq_finite x)"
    51   "Infinite x == ~(seq_finite x)"
    52 
    52 
    53 
    53 
    54 subsection {* recursive equations of operators *}
    54 subsection \<open>recursive equations of operators\<close>
    55 
    55 
    56 subsubsection {* smap *}
    56 subsubsection \<open>smap\<close>
    57 
    57 
    58 fixrec
    58 fixrec
    59   smap :: "('a -> 'b) -> 'a seq -> 'b seq"
    59   smap :: "('a -> 'b) -> 'a seq -> 'b seq"
    60 where
    60 where
    61   smap_nil: "smap$f$nil=nil"
    61   smap_nil: "smap$f$nil=nil"
    62 | smap_cons: "[|x~=UU|] ==> smap$f$(x##xs)= (f$x)##smap$f$xs"
    62 | smap_cons: "[|x~=UU|] ==> smap$f$(x##xs)= (f$x)##smap$f$xs"
    63 
    63 
    64 lemma smap_UU [simp]: "smap$f$UU=UU"
    64 lemma smap_UU [simp]: "smap$f$UU=UU"
    65 by fixrec_simp
    65 by fixrec_simp
    66 
    66 
    67 subsubsection {* sfilter *}
    67 subsubsection \<open>sfilter\<close>
    68 
    68 
    69 fixrec
    69 fixrec
    70    sfilter :: "('a -> tr) -> 'a seq -> 'a seq"
    70    sfilter :: "('a -> tr) -> 'a seq -> 'a seq"
    71 where
    71 where
    72   sfilter_nil: "sfilter$P$nil=nil"
    72   sfilter_nil: "sfilter$P$nil=nil"
    75               (If P$x then x##(sfilter$P$xs) else sfilter$P$xs)"
    75               (If P$x then x##(sfilter$P$xs) else sfilter$P$xs)"
    76 
    76 
    77 lemma sfilter_UU [simp]: "sfilter$P$UU=UU"
    77 lemma sfilter_UU [simp]: "sfilter$P$UU=UU"
    78 by fixrec_simp
    78 by fixrec_simp
    79 
    79 
    80 subsubsection {* sforall2 *}
    80 subsubsection \<open>sforall2\<close>
    81 
    81 
    82 fixrec
    82 fixrec
    83   sforall2 :: "('a -> tr) -> 'a seq -> tr"
    83   sforall2 :: "('a -> tr) -> 'a seq -> tr"
    84 where
    84 where
    85   sforall2_nil: "sforall2$P$nil=TT"
    85   sforall2_nil: "sforall2$P$nil=TT"
    90 by fixrec_simp
    90 by fixrec_simp
    91 
    91 
    92 definition
    92 definition
    93   sforall_def: "sforall P t == (sforall2$P$t ~=FF)"
    93   sforall_def: "sforall P t == (sforall2$P$t ~=FF)"
    94 
    94 
    95 subsubsection {* stakewhile *}
    95 subsubsection \<open>stakewhile\<close>
    96 
    96 
    97 fixrec
    97 fixrec
    98   stakewhile :: "('a -> tr)  -> 'a seq -> 'a seq"
    98   stakewhile :: "('a -> tr)  -> 'a seq -> 'a seq"
    99 where
    99 where
   100   stakewhile_nil: "stakewhile$P$nil=nil"
   100   stakewhile_nil: "stakewhile$P$nil=nil"
   103               (If P$x then x##(stakewhile$P$xs) else nil)"
   103               (If P$x then x##(stakewhile$P$xs) else nil)"
   104 
   104 
   105 lemma stakewhile_UU [simp]: "stakewhile$P$UU=UU"
   105 lemma stakewhile_UU [simp]: "stakewhile$P$UU=UU"
   106 by fixrec_simp
   106 by fixrec_simp
   107 
   107 
   108 subsubsection {* sdropwhile *}
   108 subsubsection \<open>sdropwhile\<close>
   109 
   109 
   110 fixrec
   110 fixrec
   111   sdropwhile :: "('a -> tr) -> 'a seq -> 'a seq"
   111   sdropwhile :: "('a -> tr) -> 'a seq -> 'a seq"
   112 where
   112 where
   113   sdropwhile_nil: "sdropwhile$P$nil=nil"
   113   sdropwhile_nil: "sdropwhile$P$nil=nil"
   116               (If P$x then sdropwhile$P$xs else x##xs)"
   116               (If P$x then sdropwhile$P$xs else x##xs)"
   117 
   117 
   118 lemma sdropwhile_UU [simp]: "sdropwhile$P$UU=UU"
   118 lemma sdropwhile_UU [simp]: "sdropwhile$P$UU=UU"
   119 by fixrec_simp
   119 by fixrec_simp
   120 
   120 
   121 subsubsection {* slast *}
   121 subsubsection \<open>slast\<close>
   122 
   122 
   123 fixrec
   123 fixrec
   124   slast :: "'a seq -> 'a"
   124   slast :: "'a seq -> 'a"
   125 where
   125 where
   126   slast_nil: "slast$nil=UU"
   126   slast_nil: "slast$nil=UU"
   128     "x~=UU ==> slast$(x##xs)= (If is_nil$xs then x else slast$xs)"
   128     "x~=UU ==> slast$(x##xs)= (If is_nil$xs then x else slast$xs)"
   129 
   129 
   130 lemma slast_UU [simp]: "slast$UU=UU"
   130 lemma slast_UU [simp]: "slast$UU=UU"
   131 by fixrec_simp
   131 by fixrec_simp
   132 
   132 
   133 subsubsection {* sconc *}
   133 subsubsection \<open>sconc\<close>
   134 
   134 
   135 fixrec
   135 fixrec
   136   sconc :: "'a seq -> 'a seq -> 'a seq"
   136   sconc :: "'a seq -> 'a seq -> 'a seq"
   137 where
   137 where
   138   sconc_nil: "sconc$nil$y = y"
   138   sconc_nil: "sconc$nil$y = y"
   151 apply simp_all
   151 apply simp_all
   152 done
   152 done
   153 
   153 
   154 declare sconc_cons' [simp del]
   154 declare sconc_cons' [simp del]
   155 
   155 
   156 subsubsection {* sflat *}
   156 subsubsection \<open>sflat\<close>
   157 
   157 
   158 fixrec
   158 fixrec
   159   sflat :: "('a seq) seq -> 'a seq"
   159   sflat :: "('a seq) seq -> 'a seq"
   160 where
   160 where
   161   sflat_nil: "sflat$nil=nil"
   161   sflat_nil: "sflat$nil=nil"
   167 lemma sflat_cons [simp]: "sflat$(x##xs)= x@@(sflat$xs)"
   167 lemma sflat_cons [simp]: "sflat$(x##xs)= x@@(sflat$xs)"
   168 by (cases "x=UU", simp_all)
   168 by (cases "x=UU", simp_all)
   169 
   169 
   170 declare sflat_cons' [simp del]
   170 declare sflat_cons' [simp del]
   171 
   171 
   172 subsubsection {* szip *}
   172 subsubsection \<open>szip\<close>
   173 
   173 
   174 fixrec
   174 fixrec
   175   szip :: "'a seq -> 'b seq -> ('a*'b) seq"
   175   szip :: "'a seq -> 'b seq -> ('a*'b) seq"
   176 where
   176 where
   177   szip_nil: "szip$nil$y=nil"
   177   szip_nil: "szip$nil$y=nil"