src/HOLCF/ex/Stream.thy
author wenzelm
Thu Apr 26 14:24:08 2007 +0200 (2007-04-26)
changeset 22808 a7daa74e2980
parent 21404 eb85850d3eb7
child 25161 aa8474398030
permissions -rw-r--r--
eliminated unnamed infixes, tuned syntax;
     1 (*  Title:      HOLCF/ex/Stream.thy
     2     ID:         $Id$
     3     Author:     Franz Regensburger, David von Oheimb, Borislav Gajanovic
     4 *)
     5 
     6 header {* General Stream domain *}
     7 
     8 theory Stream
     9 imports HOLCF Nat_Infinity
    10 begin
    11 
    12 domain 'a stream = scons (ft::'a) (lazy rt::"'a stream") (infixr "&&" 65)
    13 
    14 definition
    15   smap :: "('a \<rightarrow> 'b) \<rightarrow> 'a stream \<rightarrow> 'b stream" where
    16   "smap = fix\<cdot>(\<Lambda> h f s. case s of x && xs \<Rightarrow> f\<cdot>x && h\<cdot>f\<cdot>xs)"
    17 
    18 definition
    19   sfilter :: "('a \<rightarrow> tr) \<rightarrow> 'a stream \<rightarrow> 'a stream" where
    20   "sfilter = fix\<cdot>(\<Lambda> h p s. case s of x && xs \<Rightarrow>
    21                                      If p\<cdot>x then x && h\<cdot>p\<cdot>xs else h\<cdot>p\<cdot>xs fi)"
    22 
    23 definition
    24   slen :: "'a stream \<Rightarrow> inat"  ("#_" [1000] 1000) where
    25   "#s = (if stream_finite s then Fin (LEAST n. stream_take n\<cdot>s = s) else \<infinity>)"
    26 
    27 
    28 (* concatenation *)
    29 
    30 definition
    31   i_rt :: "nat => 'a stream => 'a stream" where (* chops the first i elements *)
    32   "i_rt = (%i s. iterate i$rt$s)"
    33 
    34 definition
    35   i_th :: "nat => 'a stream => 'a" where (* the i-th element *)
    36   "i_th = (%i s. ft$(i_rt i s))"
    37 
    38 definition
    39   sconc :: "'a stream => 'a stream => 'a stream"  (infixr "ooo" 65) where
    40   "s1 ooo s2 = (case #s1 of
    41                   Fin n \<Rightarrow> (SOME s. (stream_take n$s=s1) & (i_rt n s = s2))
    42                | \<infinity>     \<Rightarrow> s1)"
    43 
    44 consts
    45   constr_sconc' :: "nat => 'a stream => 'a stream => 'a stream"
    46 primrec
    47   constr_sconc'_0:   "constr_sconc' 0 s1 s2 = s2"
    48   constr_sconc'_Suc: "constr_sconc' (Suc n) s1 s2 = ft$s1 &&
    49                                                     constr_sconc' n (rt$s1) s2"
    50 
    51 definition
    52   constr_sconc  :: "'a stream => 'a stream => 'a stream" where (* constructive *)
    53   "constr_sconc s1 s2 = (case #s1 of
    54                           Fin n \<Rightarrow> constr_sconc' n s1 s2
    55                         | \<infinity>    \<Rightarrow> s1)"
    56 
    57 
    58 declare stream.rews [simp add]
    59 
    60 (* ----------------------------------------------------------------------- *)
    61 (* theorems about scons                                                    *)
    62 (* ----------------------------------------------------------------------- *)
    63 
    64 
    65 section "scons"
    66 
    67 lemma scons_eq_UU: "(a && s = UU) = (a = UU)"
    68 by (auto, erule contrapos_pp, simp)
    69 
    70 lemma scons_not_empty: "[| a && x = UU; a ~= UU |] ==> R"
    71 by auto
    72 
    73 lemma stream_exhaust_eq: "(x ~= UU) = (EX a y. a ~= UU &  x = a && y)"
    74 by (auto,insert stream.exhaust [of x],auto)
    75 
    76 lemma stream_neq_UU: "x~=UU ==> EX a a_s. x=a&&a_s & a~=UU"
    77 by (simp add: stream_exhaust_eq,auto)
    78 
    79 lemma stream_inject_eq [simp]:
    80   "[| a ~= UU; b ~= UU |] ==> (a && s = b && t) = (a = b &  s = t)"
    81 by (insert stream.injects [of a s b t], auto)
    82 
    83 lemma stream_prefix:
    84   "[| a && s << t; a ~= UU  |] ==> EX b tt. t = b && tt &  b ~= UU &  s << tt"
    85 apply (insert stream.exhaust [of t], auto)
    86 by (auto simp add: stream.inverts)
    87 
    88 lemma stream_prefix':
    89   "b ~= UU ==> x << b && z =
    90    (x = UU |  (EX a y. x = a && y &  a ~= UU &  a << b &  y << z))"
    91 apply (case_tac "x=UU",auto)
    92 apply (drule stream_exhaust_eq [THEN iffD1],auto)
    93 by (auto simp add: stream.inverts)
    94 
    95 
    96 (*
    97 lemma stream_prefix1: "[| x<<y; xs<<ys |] ==> x&&xs << y&&ys"
    98 by (insert stream_prefix' [of y "x&&xs" ys],force)
    99 *)
   100 
   101 lemma stream_flat_prefix:
   102   "[| x && xs << y && ys; (x::'a::flat) ~= UU|] ==> x = y & xs << ys"
   103 apply (case_tac "y=UU",auto)
   104 apply (auto simp add: stream.inverts)
   105 by (drule ax_flat [rule_format],simp)
   106 
   107 
   108 
   109 
   110 (* ----------------------------------------------------------------------- *)
   111 (* theorems about stream_when                                              *)
   112 (* ----------------------------------------------------------------------- *)
   113 
   114 section "stream_when"
   115 
   116 
   117 lemma stream_when_strictf: "stream_when$UU$s=UU"
   118 by (rule stream.casedist [of s], auto)
   119 
   120 
   121 
   122 (* ----------------------------------------------------------------------- *)
   123 (* theorems about ft and rt                                                *)
   124 (* ----------------------------------------------------------------------- *)
   125 
   126 
   127 section "ft & rt"
   128 
   129 
   130 lemma ft_defin: "s~=UU ==> ft$s~=UU"
   131 by (drule stream_exhaust_eq [THEN iffD1],auto)
   132 
   133 lemma rt_strict_rev: "rt$s~=UU ==> s~=UU"
   134 by auto
   135 
   136 lemma surjectiv_scons: "(ft$s)&&(rt$s)=s"
   137 by (rule stream.casedist [of s], auto)
   138 
   139 lemma monofun_rt_mult: "x << s ==> iterate i$rt$x << iterate i$rt$s"
   140 by (rule monofun_cfun_arg)
   141 
   142 
   143 
   144 (* ----------------------------------------------------------------------- *)
   145 (* theorems about stream_take                                              *)
   146 (* ----------------------------------------------------------------------- *)
   147 
   148 
   149 section "stream_take"
   150 
   151 
   152 lemma stream_reach2: "(LUB i. stream_take i$s) = s"
   153 apply (insert stream.reach [of s], erule subst) back
   154 apply (simp add: fix_def2 stream.take_def)
   155 apply (insert contlub_cfun_fun [of "%i. iterate i$stream_copy$UU" s,THEN sym])
   156 by (simp add: chain_iterate)
   157 
   158 lemma chain_stream_take: "chain (%i. stream_take i$s)"
   159 apply (rule chainI)
   160 apply (rule monofun_cfun_fun)
   161 apply (simp add: stream.take_def del: iterate_Suc)
   162 by (rule chainE, simp add: chain_iterate)
   163 
   164 lemma stream_take_prefix [simp]: "stream_take n$s << s"
   165 apply (insert stream_reach2 [of s])
   166 apply (erule subst) back
   167 apply (rule is_ub_thelub)
   168 by (simp only: chain_stream_take)
   169 
   170 lemma stream_take_more [rule_format]:
   171   "ALL x. stream_take n$x = x --> stream_take (Suc n)$x = x"
   172 apply (induct_tac n,auto)
   173 apply (case_tac "x=UU",auto)
   174 by (drule stream_exhaust_eq [THEN iffD1],auto)
   175 
   176 lemma stream_take_lemma3 [rule_format]:
   177   "ALL x xs. x~=UU --> stream_take n$(x && xs) = x && xs --> stream_take n$xs=xs"
   178 apply (induct_tac n,clarsimp)
   179 (*apply (drule sym, erule scons_not_empty, simp)*)
   180 apply (clarify, rule stream_take_more)
   181 apply (erule_tac x="x" in allE)
   182 by (erule_tac x="xs" in allE,simp)
   183 
   184 lemma stream_take_lemma4:
   185   "ALL x xs. stream_take n$xs=xs --> stream_take (Suc n)$(x && xs) = x && xs"
   186 by auto
   187 
   188 lemma stream_take_idempotent [rule_format, simp]:
   189  "ALL s. stream_take n$(stream_take n$s) = stream_take n$s"
   190 apply (induct_tac n, auto)
   191 apply (case_tac "s=UU", auto)
   192 by (drule stream_exhaust_eq [THEN iffD1], auto)
   193 
   194 lemma stream_take_take_Suc [rule_format, simp]:
   195   "ALL s. stream_take n$(stream_take (Suc n)$s) =
   196                                     stream_take n$s"
   197 apply (induct_tac n, auto)
   198 apply (case_tac "s=UU", auto)
   199 by (drule stream_exhaust_eq [THEN iffD1], auto)
   200 
   201 lemma mono_stream_take_pred:
   202   "stream_take (Suc n)$s1 << stream_take (Suc n)$s2 ==>
   203                        stream_take n$s1 << stream_take n$s2"
   204 by (insert monofun_cfun_arg [of "stream_take (Suc n)$s1"
   205   "stream_take (Suc n)$s2" "stream_take n"], auto)
   206 (*
   207 lemma mono_stream_take_pred:
   208   "stream_take (Suc n)$s1 << stream_take (Suc n)$s2 ==>
   209                        stream_take n$s1 << stream_take n$s2"
   210 by (drule mono_stream_take [of _ _ n],simp)
   211 *)
   212 
   213 lemma stream_take_lemma10 [rule_format]:
   214   "ALL k<=n. stream_take n$s1 << stream_take n$s2
   215                              --> stream_take k$s1 << stream_take k$s2"
   216 apply (induct_tac n,simp,clarsimp)
   217 apply (case_tac "k=Suc n",blast)
   218 apply (erule_tac x="k" in allE)
   219 by (drule mono_stream_take_pred,simp)
   220 
   221 lemma stream_take_le_mono : "k<=n ==> stream_take k$s1 << stream_take n$s1"
   222 apply (insert chain_stream_take [of s1])
   223 by (drule chain_mono3,auto)
   224 
   225 lemma mono_stream_take: "s1 << s2 ==> stream_take n$s1 << stream_take n$s2"
   226 by (simp add: monofun_cfun_arg)
   227 
   228 (*
   229 lemma stream_take_prefix [simp]: "stream_take n$s << s"
   230 apply (subgoal_tac "s=(LUB n. stream_take n$s)")
   231  apply (erule ssubst, rule is_ub_thelub)
   232  apply (simp only: chain_stream_take)
   233 by (simp only: stream_reach2)
   234 *)
   235 
   236 lemma stream_take_take_less:"stream_take k$(stream_take n$s) << stream_take k$s"
   237 by (rule monofun_cfun_arg,auto)
   238 
   239 
   240 (* ------------------------------------------------------------------------- *)
   241 (* special induction rules                                                   *)
   242 (* ------------------------------------------------------------------------- *)
   243 
   244 
   245 section "induction"
   246 
   247 lemma stream_finite_ind:
   248  "[| stream_finite x; P UU; !!a s. [| a ~= UU; P s |] ==> P (a && s) |] ==> P x"
   249 apply (simp add: stream.finite_def,auto)
   250 apply (erule subst)
   251 by (drule stream.finite_ind [of P _ x], auto)
   252 
   253 lemma stream_finite_ind2:
   254 "[| P UU; !! x. x ~= UU ==> P (x && UU); !! y z s. [| y ~= UU; z ~= UU; P s |] ==> P (y && z && s )|] ==>
   255                                  !s. P (stream_take n$s)"
   256 apply (rule nat_induct2 [of _ n],auto)
   257 apply (case_tac "s=UU",clarsimp)
   258 apply (drule stream_exhaust_eq [THEN iffD1],clarsimp)
   259 apply (case_tac "s=UU",clarsimp)
   260 apply (drule stream_exhaust_eq [THEN iffD1],clarsimp)
   261 apply (case_tac "y=UU",clarsimp)
   262 by (drule stream_exhaust_eq [THEN iffD1],clarsimp)
   263 
   264 lemma stream_ind2:
   265 "[| adm P; P UU; !!a. a ~= UU ==> P (a && UU); !!a b s. [| a ~= UU; b ~= UU; P s |] ==> P (a && b && s) |] ==> P x"
   266 apply (insert stream.reach [of x],erule subst)
   267 apply (frule adm_impl_admw, rule wfix_ind, auto)
   268 apply (rule adm_subst [THEN adm_impl_admw],auto)
   269 apply (insert stream_finite_ind2 [of P])
   270 by (simp add: stream.take_def)
   271 
   272 
   273 
   274 (* ----------------------------------------------------------------------- *)
   275 (* simplify use of coinduction                                             *)
   276 (* ----------------------------------------------------------------------- *)
   277 
   278 
   279 section "coinduction"
   280 
   281 lemma stream_coind_lemma2: "!s1 s2. R s1 s2 --> ft$s1 = ft$s2 &  R (rt$s1) (rt$s2) ==> stream_bisim R"
   282 apply (simp add: stream.bisim_def,clarsimp)
   283 apply (case_tac "x=UU",clarsimp)
   284 apply (erule_tac x="UU" in allE,simp)
   285 apply (case_tac "x'=UU",simp)
   286 apply (drule stream_exhaust_eq [THEN iffD1],auto)+
   287 apply (case_tac "x'=UU",auto)
   288 apply (erule_tac x="a && y" in allE)
   289 apply (erule_tac x="UU" in allE)+
   290 apply (auto,drule stream_exhaust_eq [THEN iffD1],clarsimp)
   291 apply (erule_tac x="a && y" in allE)
   292 apply (erule_tac x="aa && ya" in allE)
   293 by auto
   294 
   295 
   296 
   297 (* ----------------------------------------------------------------------- *)
   298 (* theorems about stream_finite                                            *)
   299 (* ----------------------------------------------------------------------- *)
   300 
   301 
   302 section "stream_finite"
   303 
   304 lemma stream_finite_UU [simp]: "stream_finite UU"
   305 by (simp add: stream.finite_def)
   306 
   307 lemma stream_finite_UU_rev: "~  stream_finite s ==> s ~= UU"
   308 by (auto simp add: stream.finite_def)
   309 
   310 lemma stream_finite_lemma1: "stream_finite xs ==> stream_finite (x && xs)"
   311 apply (simp add: stream.finite_def,auto)
   312 apply (rule_tac x="Suc n" in exI)
   313 by (simp add: stream_take_lemma4)
   314 
   315 lemma stream_finite_lemma2: "[| x ~= UU; stream_finite (x && xs) |] ==> stream_finite xs"
   316 apply (simp add: stream.finite_def, auto)
   317 apply (rule_tac x="n" in exI)
   318 by (erule stream_take_lemma3,simp)
   319 
   320 lemma stream_finite_rt_eq: "stream_finite (rt$s) = stream_finite s"
   321 apply (rule stream.casedist [of s], auto)
   322 apply (rule stream_finite_lemma1, simp)
   323 by (rule stream_finite_lemma2,simp)
   324 
   325 lemma stream_finite_less: "stream_finite s ==> !t. t<<s --> stream_finite t"
   326 apply (erule stream_finite_ind [of s], auto)
   327 apply (case_tac "t=UU", auto)
   328 apply (drule stream_exhaust_eq [THEN iffD1],auto)
   329 apply (auto simp add: stream.inverts)
   330 apply (erule_tac x="y" in allE, simp)
   331 by (rule stream_finite_lemma1, simp)
   332 
   333 lemma stream_take_finite [simp]: "stream_finite (stream_take n$s)"
   334 apply (simp add: stream.finite_def)
   335 by (rule_tac x="n" in exI,simp)
   336 
   337 lemma adm_not_stream_finite: "adm (%x. ~ stream_finite x)"
   338 apply (rule admI2, auto)
   339 apply (drule stream_finite_less,drule is_ub_thelub)
   340 by auto
   341 
   342 
   343 
   344 (* ----------------------------------------------------------------------- *)
   345 (* theorems about stream length                                            *)
   346 (* ----------------------------------------------------------------------- *)
   347 
   348 
   349 section "slen"
   350 
   351 lemma slen_empty [simp]: "#\<bottom> = 0"
   352 apply (simp add: slen_def stream.finite_def)
   353 by (simp add: inat_defs Least_equality)
   354 
   355 lemma slen_scons [simp]: "x ~= \<bottom> ==> #(x&&xs) = iSuc (#xs)"
   356 apply (case_tac "stream_finite (x && xs)")
   357 apply (simp add: slen_def, auto)
   358 apply (simp add: stream.finite_def, auto)
   359 apply (rule Least_Suc2,auto)
   360 (*apply (drule sym)*)
   361 (*apply (drule sym scons_eq_UU [THEN iffD1],simp)*)
   362 apply (erule stream_finite_lemma2, simp)
   363 apply (simp add: slen_def, auto)
   364 by (drule stream_finite_lemma1,auto)
   365 
   366 lemma slen_less_1_eq: "(#x < Fin (Suc 0)) = (x = \<bottom>)"
   367 by (rule stream.casedist [of x], auto simp del: iSuc_Fin
   368     simp add: Fin_0 iSuc_Fin[THEN sym] i0_iless_iSuc iSuc_mono)
   369 
   370 lemma slen_empty_eq: "(#x = 0) = (x = \<bottom>)"
   371 by (rule stream.casedist [of x], auto)
   372 
   373 lemma slen_scons_eq: "(Fin (Suc n) < #x) = (? a y. x = a && y &  a ~= \<bottom> &  Fin n < #y)"
   374 apply (auto, case_tac "x=UU",auto)
   375 apply (drule stream_exhaust_eq [THEN iffD1], auto)
   376 apply (rule_tac x="a" in exI)
   377 apply (rule_tac x="y" in exI, simp)
   378 by (simp add: inat_defs split:inat_splits)+
   379 
   380 lemma slen_iSuc: "#x = iSuc n --> (? a y. x = a&&y &  a ~= \<bottom> &  #y = n)"
   381 by (rule stream.casedist [of x], auto)
   382 
   383 lemma slen_stream_take_finite [simp]: "#(stream_take n$s) ~= \<infinity>"
   384 by (simp add: slen_def)
   385 
   386 lemma slen_scons_eq_rev: "(#x < Fin (Suc (Suc n))) = (!a y. x ~= a && y |  a = \<bottom> |  #y < Fin (Suc n))"
   387 apply (rule stream.casedist [of x], auto)
   388 apply ((*drule sym,*) drule scons_eq_UU [THEN iffD1],auto)
   389 apply (simp add: inat_defs split:inat_splits)
   390 apply (subgoal_tac "s=y & aa=a",simp)
   391 apply (simp add: inat_defs split:inat_splits)
   392 apply (case_tac "aa=UU",auto)
   393 apply (erule_tac x="a" in allE, simp)
   394 by (simp add: inat_defs split:inat_splits)
   395 
   396 lemma slen_take_lemma4 [rule_format]:
   397   "!s. stream_take n$s ~= s --> #(stream_take n$s) = Fin n"
   398 apply (induct_tac n,auto simp add: Fin_0)
   399 apply (case_tac "s=UU",simp)
   400 by (drule stream_exhaust_eq [THEN iffD1], auto)
   401 
   402 (*
   403 lemma stream_take_idempotent [simp]:
   404  "stream_take n$(stream_take n$s) = stream_take n$s"
   405 apply (case_tac "stream_take n$s = s")
   406 apply (auto,insert slen_take_lemma4 [of n s]);
   407 by (auto,insert slen_take_lemma1 [of "stream_take n$s" n],simp)
   408 
   409 lemma stream_take_take_Suc [simp]: "stream_take n$(stream_take (Suc n)$s) =
   410                                     stream_take n$s"
   411 apply (simp add: po_eq_conv,auto)
   412  apply (simp add: stream_take_take_less)
   413 apply (subgoal_tac "stream_take n$s = stream_take n$(stream_take n$s)")
   414  apply (erule ssubst)
   415  apply (rule_tac monofun_cfun_arg)
   416  apply (insert chain_stream_take [of s])
   417 by (simp add: chain_def,simp)
   418 *)
   419 
   420 lemma slen_take_eq: "ALL x. (Fin n < #x) = (stream_take n\<cdot>x ~= x)"
   421 apply (induct_tac n, auto)
   422 apply (simp add: Fin_0, clarsimp)
   423 apply (drule not_sym)
   424 apply (drule slen_empty_eq [THEN iffD1], simp)
   425 apply (case_tac "x=UU", simp)
   426 apply (drule stream_exhaust_eq [THEN iffD1], clarsimp)
   427 apply (erule_tac x="y" in allE, auto)
   428 apply (simp add: inat_defs split:inat_splits)
   429 apply (case_tac "x=UU", simp)
   430 apply (drule stream_exhaust_eq [THEN iffD1], clarsimp)
   431 apply (erule_tac x="y" in allE, simp)
   432 by (simp add: inat_defs split:inat_splits)
   433 
   434 lemma slen_take_eq_rev: "(#x <= Fin n) = (stream_take n\<cdot>x = x)"
   435 by (simp add: ile_def slen_take_eq)
   436 
   437 lemma slen_take_lemma1: "#x = Fin n ==> stream_take n\<cdot>x = x"
   438 by (rule slen_take_eq_rev [THEN iffD1], auto)
   439 
   440 lemma slen_rt_mono: "#s2 <= #s1 ==> #(rt$s2) <= #(rt$s1)"
   441 apply (rule stream.casedist [of s1])
   442  by (rule stream.casedist [of s2],simp+)+
   443 
   444 lemma slen_take_lemma5: "#(stream_take n$s) <= Fin n"
   445 apply (case_tac "stream_take n$s = s")
   446  apply (simp add: slen_take_eq_rev)
   447 by (simp add: slen_take_lemma4)
   448 
   449 lemma slen_take_lemma2: "!x. ~stream_finite x --> #(stream_take i\<cdot>x) = Fin i"
   450 apply (simp add: stream.finite_def, auto)
   451 by (simp add: slen_take_lemma4)
   452 
   453 lemma slen_infinite: "stream_finite x = (#x ~= Infty)"
   454 by (simp add: slen_def)
   455 
   456 lemma slen_mono_lemma: "stream_finite s ==> ALL t. s << t --> #s <= #t"
   457 apply (erule stream_finite_ind [of s], auto)
   458 apply (case_tac "t=UU", auto)
   459 apply (drule stream_exhaust_eq [THEN iffD1], auto)
   460 apply (erule_tac x="y" in allE, auto)
   461 by (auto simp add: stream.inverts)
   462 
   463 lemma slen_mono: "s << t ==> #s <= #t"
   464 apply (case_tac "stream_finite t")
   465 apply (frule stream_finite_less)
   466 apply (erule_tac x="s" in allE, simp)
   467 apply (drule slen_mono_lemma, auto)
   468 by (simp add: slen_def)
   469 
   470 lemma iterate_lemma: "F$(iterate n$F$x) = iterate n$F$(F$x)"
   471 by (insert iterate_Suc2 [of n F x], auto)
   472 
   473 lemma slen_rt_mult [rule_format]: "!x. Fin (i + j) <= #x --> Fin j <= #(iterate i$rt$x)"
   474 apply (induct_tac i, auto)
   475 apply (case_tac "x=UU", auto)
   476 apply (simp add: inat_defs)
   477 apply (drule stream_exhaust_eq [THEN iffD1], auto)
   478 apply (erule_tac x="y" in allE, auto)
   479 apply (simp add: inat_defs split:inat_splits)
   480 by (simp add: iterate_lemma)
   481 
   482 lemma slen_take_lemma3 [rule_format]:
   483   "!(x::'a::flat stream) y. Fin n <= #x --> x << y --> stream_take n\<cdot>x = stream_take n\<cdot>y"
   484 apply (induct_tac n, auto)
   485 apply (case_tac "x=UU", auto)
   486 apply (simp add: inat_defs)
   487 apply (simp add: Suc_ile_eq)
   488 apply (case_tac "y=UU", clarsimp)
   489 apply (drule stream_exhaust_eq [THEN iffD1], clarsimp)+
   490 apply (erule_tac x="ya" in allE, simp)
   491 apply (auto simp add: stream.inverts)
   492 by (drule ax_flat [rule_format], simp)
   493 
   494 lemma slen_strict_mono_lemma:
   495   "stream_finite t ==> !s. #(s::'a::flat stream) = #t &  s << t --> s = t"
   496 apply (erule stream_finite_ind, auto)
   497 apply (case_tac "sa=UU", auto)
   498 apply (drule stream_exhaust_eq [THEN iffD1], clarsimp)
   499 apply (simp add: stream.inverts, clarsimp)
   500 by (drule ax_flat [rule_format], simp)
   501 
   502 lemma slen_strict_mono: "[|stream_finite t; s ~= t; s << (t::'a::flat stream) |] ==> #s < #t"
   503 apply (intro ilessI1, auto)
   504 apply (simp add: slen_mono)
   505 by (drule slen_strict_mono_lemma, auto)
   506 
   507 lemma stream_take_Suc_neq: "stream_take (Suc n)$s ~=s ==>
   508                      stream_take n$s ~= stream_take (Suc n)$s"
   509 apply auto
   510 apply (subgoal_tac "stream_take n$s ~=s")
   511  apply (insert slen_take_lemma4 [of n s],auto)
   512 apply (rule stream.casedist [of s],simp)
   513 apply (simp add: inat_defs split:inat_splits)
   514 by (simp add: slen_take_lemma4)
   515 
   516 (* ----------------------------------------------------------------------- *)
   517 (* theorems about smap                                                     *)
   518 (* ----------------------------------------------------------------------- *)
   519 
   520 
   521 section "smap"
   522 
   523 lemma smap_unfold: "smap = (\<Lambda> f t. case t of x&&xs \<Rightarrow> f$x && smap$f$xs)"
   524 by (insert smap_def [THEN eq_reflection, THEN fix_eq2], auto)
   525 
   526 lemma smap_empty [simp]: "smap\<cdot>f\<cdot>\<bottom> = \<bottom>"
   527 by (subst smap_unfold, simp)
   528 
   529 lemma smap_scons [simp]: "x~=\<bottom> ==> smap\<cdot>f\<cdot>(x&&xs) = (f\<cdot>x)&&(smap\<cdot>f\<cdot>xs)"
   530 by (subst smap_unfold, force)
   531 
   532 
   533 
   534 (* ----------------------------------------------------------------------- *)
   535 (* theorems about sfilter                                                  *)
   536 (* ----------------------------------------------------------------------- *)
   537 
   538 section "sfilter"
   539 
   540 lemma sfilter_unfold:
   541  "sfilter = (\<Lambda> p s. case s of x && xs \<Rightarrow>
   542   If p\<cdot>x then x && sfilter\<cdot>p\<cdot>xs else sfilter\<cdot>p\<cdot>xs fi)"
   543 by (insert sfilter_def [THEN eq_reflection, THEN fix_eq2], auto)
   544 
   545 lemma strict_sfilter: "sfilter\<cdot>\<bottom> = \<bottom>"
   546 apply (rule ext_cfun)
   547 apply (subst sfilter_unfold, auto)
   548 apply (case_tac "x=UU", auto)
   549 by (drule stream_exhaust_eq [THEN iffD1], auto)
   550 
   551 lemma sfilter_empty [simp]: "sfilter\<cdot>f\<cdot>\<bottom> = \<bottom>"
   552 by (subst sfilter_unfold, force)
   553 
   554 lemma sfilter_scons [simp]:
   555   "x ~= \<bottom> ==> sfilter\<cdot>f\<cdot>(x && xs) =
   556                            If f\<cdot>x then x && sfilter\<cdot>f\<cdot>xs else sfilter\<cdot>f\<cdot>xs fi"
   557 by (subst sfilter_unfold, force)
   558 
   559 
   560 (* ----------------------------------------------------------------------- *)
   561    section "i_rt"
   562 (* ----------------------------------------------------------------------- *)
   563 
   564 lemma i_rt_UU [simp]: "i_rt n UU = UU"
   565 apply (simp add: i_rt_def)
   566 by (rule iterate.induct,auto)
   567 
   568 lemma i_rt_0 [simp]: "i_rt 0 s = s"
   569 by (simp add: i_rt_def)
   570 
   571 lemma i_rt_Suc [simp]: "a ~= UU ==> i_rt (Suc n) (a&&s) = i_rt n s"
   572 by (simp add: i_rt_def iterate_Suc2 del: iterate_Suc)
   573 
   574 lemma i_rt_Suc_forw: "i_rt (Suc n) s = i_rt n (rt$s)"
   575 by (simp only: i_rt_def iterate_Suc2)
   576 
   577 lemma i_rt_Suc_back:"i_rt (Suc n) s = rt$(i_rt n s)"
   578 by (simp only: i_rt_def,auto)
   579 
   580 lemma i_rt_mono: "x << s ==> i_rt n x  << i_rt n s"
   581 by (simp add: i_rt_def monofun_rt_mult)
   582 
   583 lemma i_rt_ij_lemma: "Fin (i + j) <= #x ==> Fin j <= #(i_rt i x)"
   584 by (simp add: i_rt_def slen_rt_mult)
   585 
   586 lemma slen_i_rt_mono: "#s2 <= #s1 ==> #(i_rt n s2) <= #(i_rt n s1)"
   587 apply (induct_tac n,auto)
   588 apply (simp add: i_rt_Suc_back)
   589 by (drule slen_rt_mono,simp)
   590 
   591 lemma i_rt_take_lemma1 [rule_format]: "ALL s. i_rt n (stream_take n$s) = UU"
   592 apply (induct_tac n)
   593  apply (simp add: i_rt_Suc_back,auto)
   594 apply (case_tac "s=UU",auto)
   595 by (drule stream_exhaust_eq [THEN iffD1],auto)
   596 
   597 lemma i_rt_slen: "(i_rt n s = UU) = (stream_take n$s = s)"
   598 apply auto
   599  apply (insert i_rt_ij_lemma [of n "Suc 0" s])
   600  apply (subgoal_tac "#(i_rt n s)=0")
   601   apply (case_tac "stream_take n$s = s",simp+)
   602   apply (insert slen_take_eq [rule_format,of n s],simp)
   603   apply (simp add: inat_defs split:inat_splits)
   604  apply (simp add: slen_take_eq )
   605 by (simp, insert i_rt_take_lemma1 [of n s],simp)
   606 
   607 lemma i_rt_lemma_slen: "#s=Fin n ==> i_rt n s = UU"
   608 by (simp add: i_rt_slen slen_take_lemma1)
   609 
   610 lemma stream_finite_i_rt [simp]: "stream_finite (i_rt n s) = stream_finite s"
   611 apply (induct_tac n, auto)
   612  apply (rule stream.casedist [of "s"], auto simp del: i_rt_Suc)
   613 by (simp add: i_rt_Suc_back stream_finite_rt_eq)+
   614 
   615 lemma take_i_rt_len_lemma: "ALL sl x j t. Fin sl = #x & n <= sl &
   616                             #(stream_take n$x) = Fin t & #(i_rt n x)= Fin j
   617                                               --> Fin (j + t) = #x"
   618 apply (induct_tac n,auto)
   619  apply (simp add: inat_defs)
   620 apply (case_tac "x=UU",auto)
   621  apply (simp add: inat_defs)
   622 apply (drule stream_exhaust_eq [THEN iffD1],clarsimp)
   623 apply (subgoal_tac "EX k. Fin k = #y",clarify)
   624  apply (erule_tac x="k" in allE)
   625  apply (erule_tac x="y" in allE,auto)
   626  apply (erule_tac x="THE p. Suc p = t" in allE,auto)
   627    apply (simp add: inat_defs split:inat_splits)
   628   apply (simp add: inat_defs split:inat_splits)
   629   apply (simp only: the_equality)
   630  apply (simp add: inat_defs split:inat_splits)
   631  apply force
   632 by (simp add: inat_defs split:inat_splits)
   633 
   634 lemma take_i_rt_len:
   635 "[| Fin sl = #x; n <= sl; #(stream_take n$x) = Fin t; #(i_rt n x) = Fin j |] ==>
   636     Fin (j + t) = #x"
   637 by (blast intro: take_i_rt_len_lemma [rule_format])
   638 
   639 
   640 (* ----------------------------------------------------------------------- *)
   641    section "i_th"
   642 (* ----------------------------------------------------------------------- *)
   643 
   644 lemma i_th_i_rt_step:
   645 "[| i_th n s1 << i_th n s2; i_rt (Suc n) s1 << i_rt (Suc n) s2 |] ==>
   646    i_rt n s1 << i_rt n s2"
   647 apply (simp add: i_th_def i_rt_Suc_back)
   648 apply (rule stream.casedist [of "i_rt n s1"],simp)
   649 apply (rule stream.casedist [of "i_rt n s2"],auto)
   650 by (intro monofun_cfun, auto)
   651 
   652 lemma i_th_stream_take_Suc [rule_format]:
   653  "ALL s. i_th n (stream_take (Suc n)$s) = i_th n s"
   654 apply (induct_tac n,auto)
   655  apply (simp add: i_th_def)
   656  apply (case_tac "s=UU",auto)
   657  apply (drule stream_exhaust_eq [THEN iffD1],auto)
   658 apply (case_tac "s=UU",simp add: i_th_def)
   659 apply (drule stream_exhaust_eq [THEN iffD1],auto)
   660 by (simp add: i_th_def i_rt_Suc_forw)
   661 
   662 lemma i_th_last: "i_th n s && UU = i_rt n (stream_take (Suc n)$s)"
   663 apply (insert surjectiv_scons [of "i_rt n (stream_take (Suc n)$s)"])
   664 apply (rule i_th_stream_take_Suc [THEN subst])
   665 apply (simp add: i_th_def  i_rt_Suc_back [symmetric])
   666 by (simp add: i_rt_take_lemma1)
   667 
   668 lemma i_th_last_eq:
   669 "i_th n s1 = i_th n s2 ==> i_rt n (stream_take (Suc n)$s1) = i_rt n (stream_take (Suc n)$s2)"
   670 apply (insert i_th_last [of n s1])
   671 apply (insert i_th_last [of n s2])
   672 by auto
   673 
   674 lemma i_th_prefix_lemma:
   675 "[| k <= n; stream_take (Suc n)$s1 << stream_take (Suc n)$s2 |] ==>
   676     i_th k s1 << i_th k s2"
   677 apply (insert i_th_stream_take_Suc [of k s1, THEN sym])
   678 apply (insert i_th_stream_take_Suc [of k s2, THEN sym],auto)
   679 apply (simp add: i_th_def)
   680 apply (rule monofun_cfun, auto)
   681 apply (rule i_rt_mono)
   682 by (blast intro: stream_take_lemma10)
   683 
   684 lemma take_i_rt_prefix_lemma1:
   685   "stream_take (Suc n)$s1 << stream_take (Suc n)$s2 ==>
   686    i_rt (Suc n) s1 << i_rt (Suc n) s2 ==>
   687    i_rt n s1 << i_rt n s2 & stream_take n$s1 << stream_take n$s2"
   688 apply auto
   689  apply (insert i_th_prefix_lemma [of n n s1 s2])
   690  apply (rule i_th_i_rt_step,auto)
   691 by (drule mono_stream_take_pred,simp)
   692 
   693 lemma take_i_rt_prefix_lemma:
   694 "[| stream_take n$s1 << stream_take n$s2; i_rt n s1 << i_rt n s2 |] ==> s1 << s2"
   695 apply (case_tac "n=0",simp)
   696 apply (insert neq0_conv [of n])
   697 apply (insert not0_implies_Suc [of n],auto)
   698 apply (subgoal_tac "stream_take 0$s1 << stream_take 0$s2 &
   699                     i_rt 0 s1 << i_rt 0 s2")
   700  defer 1
   701  apply (rule zero_induct,blast)
   702  apply (blast dest: take_i_rt_prefix_lemma1)
   703 by simp
   704 
   705 lemma streams_prefix_lemma: "(s1 << s2) =
   706   (stream_take n$s1 << stream_take n$s2 & i_rt n s1 << i_rt n s2)"
   707 apply auto
   708   apply (simp add: monofun_cfun_arg)
   709  apply (simp add: i_rt_mono)
   710 by (erule take_i_rt_prefix_lemma,simp)
   711 
   712 lemma streams_prefix_lemma1:
   713  "[| stream_take n$s1 = stream_take n$s2; i_rt n s1 = i_rt n s2 |] ==> s1 = s2"
   714 apply (simp add: po_eq_conv,auto)
   715  apply (insert streams_prefix_lemma)
   716  by blast+
   717 
   718 
   719 (* ----------------------------------------------------------------------- *)
   720    section "sconc"
   721 (* ----------------------------------------------------------------------- *)
   722 
   723 lemma UU_sconc [simp]: " UU ooo s = s "
   724 by (simp add: sconc_def inat_defs)
   725 
   726 lemma scons_neq_UU: "a~=UU ==> a && s ~=UU"
   727 by auto
   728 
   729 lemma singleton_sconc [rule_format, simp]: "x~=UU --> (x && UU) ooo y = x && y"
   730 apply (simp add: sconc_def inat_defs split:inat_splits,auto)
   731 apply (rule someI2_ex,auto)
   732  apply (rule_tac x="x && y" in exI,auto)
   733 apply (simp add: i_rt_Suc_forw)
   734 apply (case_tac "xa=UU",simp)
   735 by (drule stream_exhaust_eq [THEN iffD1],auto)
   736 
   737 lemma ex_sconc [rule_format]:
   738   "ALL k y. #x = Fin k --> (EX w. stream_take k$w = x & i_rt k w = y)"
   739 apply (case_tac "#x")
   740  apply (rule stream_finite_ind [of x],auto)
   741   apply (simp add: stream.finite_def)
   742   apply (drule slen_take_lemma1,blast)
   743  apply (simp add: inat_defs split:inat_splits)+
   744 apply (erule_tac x="y" in allE,auto)
   745 by (rule_tac x="a && w" in exI,auto)
   746 
   747 lemma rt_sconc1: "Fin n = #x ==> i_rt n (x ooo y) = y"
   748 apply (simp add: sconc_def inat_defs split:inat_splits, arith?,auto)
   749 apply (rule someI2_ex,auto)
   750 by (drule ex_sconc,simp)
   751 
   752 lemma sconc_inj2: "\<lbrakk>Fin n = #x; x ooo y = x ooo z\<rbrakk> \<Longrightarrow> y = z"
   753 apply (frule_tac y=y in rt_sconc1)
   754 by (auto elim: rt_sconc1)
   755 
   756 lemma sconc_UU [simp]:"s ooo UU = s"
   757 apply (case_tac "#s")
   758  apply (simp add: sconc_def inat_defs)
   759  apply (rule someI2_ex)
   760   apply (rule_tac x="s" in exI)
   761   apply auto
   762    apply (drule slen_take_lemma1,auto)
   763   apply (simp add: i_rt_lemma_slen)
   764  apply (drule slen_take_lemma1,auto)
   765  apply (simp add: i_rt_slen)
   766 by (simp add: sconc_def inat_defs)
   767 
   768 lemma stream_take_sconc [simp]: "Fin n = #x ==> stream_take n$(x ooo y) = x"
   769 apply (simp add: sconc_def)
   770 apply (simp add: inat_defs split:inat_splits,auto)
   771 apply (rule someI2_ex,auto)
   772 by (drule ex_sconc,simp)
   773 
   774 lemma scons_sconc [rule_format,simp]: "a~=UU --> (a && x) ooo y = a && x ooo y"
   775 apply (case_tac "#x",auto)
   776  apply (simp add: sconc_def)
   777  apply (rule someI2_ex)
   778   apply (drule ex_sconc,simp)
   779  apply (rule someI2_ex,auto)
   780   apply (simp add: i_rt_Suc_forw)
   781   apply (rule_tac x="a && x" in exI,auto)
   782  apply (case_tac "xa=UU",auto)
   783 (*apply (drule_tac s="stream_take nat$x" in scons_neq_UU)
   784   apply (simp add: i_rt_Suc_forw)*)
   785  apply (drule stream_exhaust_eq [THEN iffD1],auto)
   786  apply (drule streams_prefix_lemma1,simp+)
   787 by (simp add: sconc_def)
   788 
   789 lemma ft_sconc: "x ~= UU ==> ft$(x ooo y) = ft$x"
   790 by (rule stream.casedist [of x],auto)
   791 
   792 lemma sconc_assoc: "(x ooo y) ooo z = x ooo y ooo z"
   793 apply (case_tac "#x")
   794  apply (rule stream_finite_ind [of x],auto simp del: scons_sconc)
   795   apply (simp add: stream.finite_def del: scons_sconc)
   796   apply (drule slen_take_lemma1,auto simp del: scons_sconc)
   797  apply (case_tac "a = UU", auto)
   798 by (simp add: sconc_def)
   799 
   800 
   801 (* ----------------------------------------------------------------------- *)
   802 
   803 lemma sconc_mono: "y << y' ==> x ooo y << x ooo y'"
   804 apply (case_tac "#x")
   805  apply (rule stream_finite_ind [of "x"])
   806    apply (auto simp add: stream.finite_def)
   807   apply (drule slen_take_lemma1,blast)
   808  by (simp add: stream_prefix',auto simp add: sconc_def)
   809 
   810 lemma sconc_mono1 [simp]: "x << x ooo y"
   811 by (rule sconc_mono [of UU, simplified])
   812 
   813 (* ----------------------------------------------------------------------- *)
   814 
   815 lemma empty_sconc [simp]: "(x ooo y = UU) = (x = UU & y = UU)"
   816 apply (case_tac "#x",auto)
   817    apply (insert sconc_mono1 [of x y])
   818    by auto
   819 
   820 (* ----------------------------------------------------------------------- *)
   821 
   822 lemma rt_sconc [rule_format, simp]: "s~=UU --> rt$(s ooo x) = rt$s ooo x"
   823 by (rule stream.casedist,auto)
   824 
   825 lemma i_th_sconc_lemma [rule_format]:
   826   "ALL x y. Fin n < #x --> i_th n (x ooo y) = i_th n x"
   827 apply (induct_tac n, auto)
   828 apply (simp add: Fin_0 i_th_def)
   829 apply (simp add: slen_empty_eq ft_sconc)
   830 apply (simp add: i_th_def)
   831 apply (case_tac "x=UU",auto)
   832 apply (drule stream_exhaust_eq [THEN iffD1], auto)
   833 apply (erule_tac x="ya" in allE)
   834 by (simp add: inat_defs split:inat_splits)
   835 
   836 
   837 
   838 (* ----------------------------------------------------------------------- *)
   839 
   840 lemma sconc_lemma [rule_format, simp]: "ALL s. stream_take n$s ooo i_rt n s = s"
   841 apply (induct_tac n,auto)
   842 apply (case_tac "s=UU",auto)
   843 by (drule stream_exhaust_eq [THEN iffD1],auto)
   844 
   845 (* ----------------------------------------------------------------------- *)
   846    subsection "pointwise equality"
   847 (* ----------------------------------------------------------------------- *)
   848 
   849 lemma ex_last_stream_take_scons: "stream_take (Suc n)$s =
   850                      stream_take n$s ooo i_rt n (stream_take (Suc n)$s)"
   851 by (insert sconc_lemma [of n "stream_take (Suc n)$s"],simp)
   852 
   853 lemma i_th_stream_take_eq:
   854 "!!n. ALL n. i_th n s1 = i_th n s2 ==> stream_take n$s1 = stream_take n$s2"
   855 apply (induct_tac n,auto)
   856 apply (subgoal_tac "stream_take (Suc na)$s1 =
   857                     stream_take na$s1 ooo i_rt na (stream_take (Suc na)$s1)")
   858  apply (subgoal_tac "i_rt na (stream_take (Suc na)$s1) =
   859                     i_rt na (stream_take (Suc na)$s2)")
   860   apply (subgoal_tac "stream_take (Suc na)$s2 =
   861                     stream_take na$s2 ooo i_rt na (stream_take (Suc na)$s2)")
   862    apply (insert ex_last_stream_take_scons,simp)
   863   apply blast
   864  apply (erule_tac x="na" in allE)
   865  apply (insert i_th_last_eq [of _ s1 s2])
   866 by blast+
   867 
   868 lemma pointwise_eq_lemma[rule_format]: "ALL n. i_th n s1 = i_th n s2 ==> s1 = s2"
   869 by (insert i_th_stream_take_eq [THEN stream.take_lemmas],blast)
   870 
   871 (* ----------------------------------------------------------------------- *)
   872    subsection "finiteness"
   873 (* ----------------------------------------------------------------------- *)
   874 
   875 lemma slen_sconc_finite1:
   876   "[| #(x ooo y) = Infty; Fin n = #x |] ==> #y = Infty"
   877 apply (case_tac "#y ~= Infty",auto)
   878 apply (simp only: slen_infinite [symmetric])
   879 apply (drule_tac y=y in rt_sconc1)
   880 apply (insert stream_finite_i_rt [of n "x ooo y"])
   881 by (simp add: slen_infinite)
   882 
   883 lemma slen_sconc_infinite1: "#x=Infty ==> #(x ooo y) = Infty"
   884 by (simp add: sconc_def)
   885 
   886 lemma slen_sconc_infinite2: "#y=Infty ==> #(x ooo y) = Infty"
   887 apply (case_tac "#x")
   888  apply (simp add: sconc_def)
   889  apply (rule someI2_ex)
   890   apply (drule ex_sconc,auto)
   891  apply (erule contrapos_pp)
   892  apply (insert stream_finite_i_rt)
   893  apply (simp add: slen_infinite,auto)
   894 by (simp add: sconc_def)
   895 
   896 lemma sconc_finite: "(#x~=Infty & #y~=Infty) = (#(x ooo y)~=Infty)"
   897 apply auto
   898   apply (case_tac "#x",auto)
   899   apply (erule contrapos_pp,simp)
   900   apply (erule slen_sconc_finite1,simp)
   901  apply (drule slen_sconc_infinite1 [of _ y],simp)
   902 by (drule slen_sconc_infinite2 [of _ x],simp)
   903 
   904 (* ----------------------------------------------------------------------- *)
   905 
   906 lemma slen_sconc_mono3: "[| Fin n = #x; Fin k = #(x ooo y) |] ==> n <= k"
   907 apply (insert slen_mono [of "x" "x ooo y"])
   908 by (simp add: inat_defs split: inat_splits)
   909 
   910 (* ----------------------------------------------------------------------- *)
   911    subsection "finite slen"
   912 (* ----------------------------------------------------------------------- *)
   913 
   914 lemma slen_sconc: "[| Fin n = #x; Fin m = #y |] ==> #(x ooo y) = Fin (n + m)"
   915 apply (case_tac "#(x ooo y)")
   916  apply (frule_tac y=y in rt_sconc1)
   917  apply (insert take_i_rt_len [of "THE j. Fin j = #(x ooo y)" "x ooo y" n n m],simp)
   918  apply (insert slen_sconc_mono3 [of n x _ y],simp)
   919 by (insert sconc_finite [of x y],auto)
   920 
   921 (* ----------------------------------------------------------------------- *)
   922    subsection "flat prefix"
   923 (* ----------------------------------------------------------------------- *)
   924 
   925 lemma sconc_prefix: "(s1::'a::flat stream) << s2 ==> EX t. s1 ooo t = s2"
   926 apply (case_tac "#s1")
   927  apply (subgoal_tac "stream_take nat$s1 = stream_take nat$s2")
   928   apply (rule_tac x="i_rt nat s2" in exI)
   929   apply (simp add: sconc_def)
   930   apply (rule someI2_ex)
   931    apply (drule ex_sconc)
   932    apply (simp,clarsimp,drule streams_prefix_lemma1)
   933    apply (simp+,rule slen_take_lemma3 [of _ s1 s2])
   934   apply (simp+,rule_tac x="UU" in exI)
   935 apply (insert slen_take_lemma3 [of _ s1 s2])
   936 by (rule stream.take_lemmas,simp)
   937 
   938 (* ----------------------------------------------------------------------- *)
   939    subsection "continuity"
   940 (* ----------------------------------------------------------------------- *)
   941 
   942 lemma chain_sconc: "chain S ==> chain (%i. (x ooo S i))"
   943 by (simp add: chain_def,auto simp add: sconc_mono)
   944 
   945 lemma chain_scons: "chain S ==> chain (%i. a && S i)"
   946 apply (simp add: chain_def,auto)
   947 by (rule monofun_cfun_arg,simp)
   948 
   949 lemma contlub_scons: "contlub (%x. a && x)"
   950 by (simp add: contlub_Rep_CFun2)
   951 
   952 lemma contlub_scons_lemma: "chain S ==> (LUB i. a && S i) = a && (LUB i. S i)"
   953 apply (insert contlub_scons [of a])
   954 by (simp only: contlub_def)
   955 
   956 lemma finite_lub_sconc: "chain Y ==> (stream_finite x) ==>
   957                         (LUB i. x ooo Y i) = (x ooo (LUB i. Y i))"
   958 apply (rule stream_finite_ind [of x])
   959  apply (auto)
   960 apply (subgoal_tac "(LUB i. a && (s ooo Y i)) = a && (LUB i. s ooo Y i)")
   961  by (force,blast dest: contlub_scons_lemma chain_sconc)
   962 
   963 lemma contlub_sconc_lemma:
   964   "chain Y ==> (LUB i. x ooo Y i) = (x ooo (LUB i. Y i))"
   965 apply (case_tac "#x=Infty")
   966  apply (simp add: sconc_def)
   967 apply (drule finite_lub_sconc,auto simp add: slen_infinite)
   968 done
   969 
   970 lemma contlub_sconc: "contlub (%y. x ooo y)"
   971 by (rule contlubI, insert contlub_sconc_lemma [of _ x], simp)
   972 
   973 lemma monofun_sconc: "monofun (%y. x ooo y)"
   974 by (simp add: monofun_def sconc_mono)
   975 
   976 lemma cont_sconc: "cont (%y. x ooo y)"
   977 apply (rule  monocontlub2cont)
   978  apply (rule monofunI, simp add: sconc_mono)
   979 by (rule contlub_sconc)
   980 
   981 
   982 (* ----------------------------------------------------------------------- *)
   983    section "constr_sconc"
   984 (* ----------------------------------------------------------------------- *)
   985 
   986 lemma constr_sconc_UUs [simp]: "constr_sconc UU s = s"
   987 by (simp add: constr_sconc_def inat_defs)
   988 
   989 lemma "x ooo y = constr_sconc x y"
   990 apply (case_tac "#x")
   991  apply (rule stream_finite_ind [of x],auto simp del: scons_sconc)
   992   defer 1
   993   apply (simp add: constr_sconc_def del: scons_sconc)
   994   apply (case_tac "#s")
   995    apply (simp add: inat_defs)
   996    apply (case_tac "a=UU",auto simp del: scons_sconc)
   997    apply (simp)
   998   apply (simp add: sconc_def)
   999  apply (simp add: constr_sconc_def)
  1000 apply (simp add: stream.finite_def)
  1001 by (drule slen_take_lemma1,auto)
  1002 
  1003 end