src/HOL/Limited_Sequence.thy
changeset 55466 786edc984c98
parent 51143 0a2371e7ced3
child 58889 5b7a9633cfa8
equal deleted inserted replaced
55465:0d31c0546286 55466:786edc984c98
    25 
    25 
    26 definition yield :: "'a dseq \<Rightarrow> natural \<Rightarrow> bool \<Rightarrow> ('a \<times> 'a dseq) option" 
    26 definition yield :: "'a dseq \<Rightarrow> natural \<Rightarrow> bool \<Rightarrow> ('a \<times> 'a dseq) option" 
    27 where
    27 where
    28   "yield f i pol = (case eval f i pol of
    28   "yield f i pol = (case eval f i pol of
    29     None \<Rightarrow> None
    29     None \<Rightarrow> None
    30   | Some s \<Rightarrow> (Option.map \<circ> apsnd) (\<lambda>r _ _. Some r) (Lazy_Sequence.yield s))"
    30   | Some s \<Rightarrow> (map_option \<circ> apsnd) (\<lambda>r _ _. Some r) (Lazy_Sequence.yield s))"
    31 
    31 
    32 definition map_seq :: "('a \<Rightarrow> 'b dseq) \<Rightarrow> 'a lazy_sequence \<Rightarrow> 'b dseq"
    32 definition map_seq :: "('a \<Rightarrow> 'b dseq) \<Rightarrow> 'a lazy_sequence \<Rightarrow> 'b dseq"
    33 where
    33 where
    34   "map_seq f xq i pol = Option.map Lazy_Sequence.flat
    34   "map_seq f xq i pol = map_option Lazy_Sequence.flat
    35     (Lazy_Sequence.those (Lazy_Sequence.map (\<lambda>x. f x i pol) xq))"
    35     (Lazy_Sequence.those (Lazy_Sequence.map (\<lambda>x. f x i pol) xq))"
    36 
    36 
    37 lemma map_seq_code [code]:
    37 lemma map_seq_code [code]:
    38   "map_seq f xq i pol = (case Lazy_Sequence.yield xq of
    38   "map_seq f xq i pol = (case Lazy_Sequence.yield xq of
    39     None \<Rightarrow> Some Lazy_Sequence.empty
    39     None \<Rightarrow> Some Lazy_Sequence.empty