diff -r a33bbac43359 -r ba194424b895 src/HOL/Library/Stream.thy --- a/src/HOL/Library/Stream.thy Thu Oct 20 18:41:58 2016 +0200 +++ b/src/HOL/Library/Stream.thy Thu Oct 20 18:41:59 2016 +0200 @@ -242,7 +242,7 @@ lemma sdrop_snth: "sdrop n s !! m = s !! (n + m)" by (induct n arbitrary: m s) auto -partial_function (tailrec) sdrop_while :: "('a \ bool) \ 'a stream \ 'a stream" where +partial_function (tailrec) sdrop_while :: "('a \ bool) \ 'a stream \ 'a stream" where "sdrop_while P s = (if P (shd s) then sdrop_while P (stl s) else s)" lemma sdrop_while_SCons[code]: @@ -342,7 +342,7 @@ by (induct n arbitrary: u) (auto simp: rotate1_rotate_swap rotate1_hd_tl rotate_conv_mod[symmetric]) lemma sset_cycle[simp]: - assumes "xs \ []" + assumes "xs \ []" shows "sset (cycle xs) = set xs" proof (intro set_eqI iffI) fix x @@ -408,6 +408,14 @@ lemma sconst_streams: "x \ A \ sconst x \ streams A" by (simp add: streams_iff_sset) +lemma streams_empty_iff: "streams S = {} \ S = {}" +proof safe + fix x assume "x \ S" "streams S = {}" + then have "sconst x \ streams S" + by (intro sconst_streams) + then show "x \ {}" + unfolding \streams S = {}\ by simp +qed (auto simp: streams_empty) subsection \stream of natural numbers\ @@ -442,11 +450,11 @@ lemma flat_unfold: "shd ws \ [] \ flat ws = shd ws @- flat (stl ws)" by (cases ws) auto -lemma flat_snth: "\xs \ sset s. xs \ [] \ flat s !! n = (if n < length (shd s) then +lemma flat_snth: "\xs \ sset s. xs \ [] \ flat s !! n = (if n < length (shd s) then shd s ! n else flat (stl s) !! (n - length (shd s)))" by (metis flat_unfold not_less shd_sset shift_snth_ge shift_snth_less) -lemma sset_flat[simp]: "\xs \ sset s. xs \ [] \ +lemma sset_flat[simp]: "\xs \ sset s. xs \ [] \ sset (flat s) = (\xs \ sset s. set xs)" (is "?P \ ?L = ?R") proof safe fix x assume ?P "x : ?L"