src/HOL/BNF/Examples/Stream.thy
author traytel
Thu, 13 Dec 2012 15:39:07 +0100
changeset 50518 d4fdda801e19
child 51023 550f265864e3
permissions -rw-r--r--
short library for streams
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50518
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     1
(*  Title:      HOL/BNF/Examples/Stream.thy
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     2
    Author:     Dmitriy Traytel, TU Muenchen
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     3
    Author:     Andrei Popescu, TU Muenchen
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     4
    Copyright   2012
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     5
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     6
Infinite streams.
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     7
*)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     8
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
     9
header {* Infinite Streams *}
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    10
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    11
theory Stream
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    12
imports "../BNF"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    13
begin
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    14
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    15
codata 'a stream = Stream (shd: 'a) (stl: "'a stream")
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    16
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    17
(* TODO: Provide by the package*)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    18
theorem stream_set_induct:
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    19
   "\<lbrakk>\<And>s. P (shd s) s; \<And>s y. \<lbrakk>y \<in> stream_set (stl s); P y (stl s)\<rbrakk> \<Longrightarrow> P y s\<rbrakk> \<Longrightarrow>
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    20
   \<forall>y \<in> stream_set s. P y s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    21
by (rule stream.dtor_set_induct)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    22
   (auto simp add:  shd_def stl_def stream_case_def fsts_def snds_def split_beta)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    23
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    24
theorem shd_stream_set: "shd s \<in> stream_set s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    25
by (auto simp add: shd_def stl_def stream_case_def fsts_def snds_def split_beta)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    26
   (metis UnCI fsts_def insertI1 stream.dtor_set)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    27
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    28
theorem stl_stream_set: "y \<in> stream_set (stl s) \<Longrightarrow> y \<in> stream_set s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    29
by (auto simp add: shd_def stl_def stream_case_def fsts_def snds_def split_beta)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    30
   (metis insertI1 set_mp snds_def stream.dtor_set_set_incl)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    31
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    32
(* only for the non-mutual case: *)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    33
theorem stream_set_induct1[consumes 1, case_names shd stl, induct set: "stream_set"]:
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    34
  assumes "y \<in> stream_set s" and "\<And>s. P (shd s) s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    35
  and "\<And>s y. \<lbrakk>y \<in> stream_set (stl s); P y (stl s)\<rbrakk> \<Longrightarrow> P y s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    36
  shows "P y s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    37
using assms stream_set_induct by blast
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    38
(* end TODO *)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    39
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    40
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    41
subsection {* prepend list to stream *}
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    42
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    43
primrec shift :: "'a list \<Rightarrow> 'a stream \<Rightarrow> 'a stream" (infixr "@-" 65) where
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    44
  "shift [] s = s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    45
| "shift (x # xs) s = Stream x (shift xs s)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    46
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    47
lemma shift_append[simp]: "(xs @ ys) @- s = xs @- ys @- s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    48
by (induct xs) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    49
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    50
lemma shift_simps[simp]:
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    51
   "shd (xs @- s) = (if xs = [] then shd s else hd xs)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    52
   "stl (xs @- s) = (if xs = [] then stl s else tl xs @- s)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    53
by (induct xs) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    54
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    55
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    56
subsection {* recurring stream out of a list *}
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    57
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    58
definition cycle :: "'a list \<Rightarrow> 'a stream" where
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    59
  "cycle = stream_unfold hd (\<lambda>xs. tl xs @ [hd xs])"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    60
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    61
lemma cycle_simps[simp]:
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    62
  "shd (cycle u) = hd u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    63
  "stl (cycle u) = cycle (tl u @ [hd u])"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    64
by (auto simp: cycle_def)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    65
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    66
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    67
lemma cycle_decomp: "u \<noteq> [] \<Longrightarrow> cycle u = u @- cycle u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    68
proof (coinduct rule: stream.coinduct[of "\<lambda>s1 s2. \<exists>u. s1 = cycle u \<and> s2 = u @- cycle u \<and> u \<noteq> []"])
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    69
  case (2 s1 s2)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    70
  then obtain u where "s1 = cycle u \<and> s2 = u @- cycle u \<and> u \<noteq> []" by blast
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    71
  thus ?case using stream.unfold[of hd "\<lambda>xs. tl xs @ [hd xs]" u] by (auto simp: cycle_def)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    72
qed auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    73
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    74
lemma cycle_Cons: "cycle (x # xs) = Stream x (cycle (xs @ [x]))"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    75
proof (coinduct rule: stream.coinduct[of "\<lambda>s1 s2. \<exists>x xs. s1 = cycle (x # xs) \<and> s2 = Stream x (cycle (xs @ [x]))"])
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    76
  case (2 s1 s2)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    77
  then obtain x xs where "s1 = cycle (x # xs) \<and> s2 = Stream x (cycle (xs @ [x]))" by blast
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    78
  thus ?case
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    79
    by (auto simp: cycle_def intro!: exI[of _ "hd (xs @ [x])"] exI[of _ "tl (xs @ [x])"] stream.unfold)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    80
qed auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    81
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    82
coinductive_set
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    83
  streams :: "'a set => 'a stream set"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    84
  for A :: "'a set"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    85
where
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    86
  Stream[intro!, simp, no_atp]: "\<lbrakk>a \<in> A; s \<in> streams A\<rbrakk> \<Longrightarrow> Stream a s \<in> streams A"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    87
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    88
lemma shift_streams: "\<lbrakk>w \<in> lists A; s \<in> streams A\<rbrakk> \<Longrightarrow> w @- s \<in> streams A"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    89
by (induct w) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    90
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    91
lemma stream_set_streams:
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    92
  assumes "stream_set s \<subseteq> A"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    93
  shows "s \<in> streams A"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    94
proof (coinduct rule: streams.coinduct[of "\<lambda>s'. \<exists>a s. s' = Stream a s \<and> a \<in> A \<and> stream_set s \<subseteq> A"])
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    95
  case streams from assms show ?case by (cases s) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    96
next
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    97
  fix s' assume "\<exists>a s. s' = Stream a s \<and> a \<in> A \<and> stream_set s \<subseteq> A"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    98
  then guess a s by (elim exE)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
    99
  with assms show "\<exists>a l. s' = Stream a l \<and>
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   100
    a \<in> A \<and> ((\<exists>a s. l = Stream a s \<and> a \<in> A \<and> stream_set s \<subseteq> A) \<or> l \<in> streams A)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   101
    by (cases s) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   102
qed
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   103
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   104
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   105
subsection {* flatten a stream of lists *}
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   106
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   107
definition flat where
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   108
  "flat \<equiv> stream_unfold (hd o shd) (\<lambda>s. if tl (shd s) = [] then stl s else Stream (tl (shd s)) (stl s))"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   109
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   110
lemma flat_simps[simp]:
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   111
  "shd (flat ws) = hd (shd ws)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   112
  "stl (flat ws) = flat (if tl (shd ws) = [] then stl ws else Stream (tl (shd ws)) (stl ws))"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   113
unfolding flat_def by auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   114
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   115
lemma flat_Cons[simp]: "flat (Stream (x#xs) w) = Stream x (flat (if xs = [] then w else Stream xs w))"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   116
unfolding flat_def using stream.unfold[of "hd o shd" _ "Stream (x#xs) w"] by auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   117
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   118
lemma flat_Stream[simp]: "xs \<noteq> [] \<Longrightarrow> flat (Stream xs ws) = xs @- flat ws"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   119
by (induct xs) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   120
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   121
lemma flat_unfold: "shd ws \<noteq> [] \<Longrightarrow> flat ws = shd ws @- flat (stl ws)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   122
by (cases ws) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   123
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   124
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   125
subsection {* take, drop, nth for streams *}
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   126
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   127
primrec stake :: "nat \<Rightarrow> 'a stream \<Rightarrow> 'a list" where
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   128
  "stake 0 s = []"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   129
| "stake (Suc n) s = shd s # stake n (stl s)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   130
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   131
primrec sdrop :: "nat \<Rightarrow> 'a stream \<Rightarrow> 'a stream" where
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   132
  "sdrop 0 s = s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   133
| "sdrop (Suc n) s = sdrop n (stl s)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   134
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   135
primrec snth :: "nat \<Rightarrow> 'a stream \<Rightarrow> 'a" where
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   136
  "snth 0 s = shd s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   137
| "snth (Suc n) s = snth n (stl s)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   138
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   139
lemma stake_sdrop: "stake n s @- sdrop n s = s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   140
by (induct n arbitrary: s) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   141
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   142
lemma stake_empty: "stake n s = [] \<longleftrightarrow> n = 0"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   143
by (cases n) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   144
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   145
lemma sdrop_shift: "\<lbrakk>s = w @- s'; length w = n\<rbrakk> \<Longrightarrow> sdrop n s = s'"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   146
by (induct n arbitrary: w s) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   147
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   148
lemma stake_shift: "\<lbrakk>s = w @- s'; length w = n\<rbrakk> \<Longrightarrow> stake n s = w"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   149
by (induct n arbitrary: w s) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   150
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   151
lemma stake_add[simp]: "stake m s @ stake n (sdrop m s) = stake (m + n) s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   152
by (induct m arbitrary: s) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   153
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   154
lemma sdrop_add[simp]: "sdrop n (sdrop m s) = sdrop (m + n) s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   155
by (induct m arbitrary: s) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   156
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   157
lemma cycle_rotated: "\<lbrakk>v \<noteq> []; cycle u = v @- s\<rbrakk> \<Longrightarrow> cycle (tl u @ [hd u]) = tl v @- s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   158
by (auto dest: arg_cong[of _ _ stl])
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   159
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   160
lemma stake_append: "stake n (u @- s) = take (min (length u) n) u @ stake (n - length u) s"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   161
proof (induct n arbitrary: u)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   162
  case (Suc n) thus ?case by (cases u) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   163
qed auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   164
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   165
lemma stake_cycle_le[simp]:
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   166
  assumes "u \<noteq> []" "n < length u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   167
  shows "stake n (cycle u) = take n u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   168
using min_absorb2[OF less_imp_le_nat[OF assms(2)]]
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   169
by (subst cycle_decomp[OF assms(1)], subst stake_append) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   170
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   171
lemma stake_cycle_eq[simp]: "u \<noteq> [] \<Longrightarrow> stake (length u) (cycle u) = u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   172
by (metis cycle_decomp stake_shift)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   173
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   174
lemma sdrop_cycle_eq[simp]: "u \<noteq> [] \<Longrightarrow> sdrop (length u) (cycle u) = cycle u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   175
by (metis cycle_decomp sdrop_shift)
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   176
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   177
lemma stake_cycle_eq_mod_0[simp]: "\<lbrakk>u \<noteq> []; n mod length u = 0\<rbrakk> \<Longrightarrow>
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   178
   stake n (cycle u) = concat (replicate (n div length u) u)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   179
by (induct "n div length u" arbitrary: n u) (auto simp: stake_add[symmetric])
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   180
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   181
lemma sdrop_cycle_eq_mod_0[simp]: "\<lbrakk>u \<noteq> []; n mod length u = 0\<rbrakk> \<Longrightarrow>
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   182
   sdrop n (cycle u) = cycle u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   183
by (induct "n div length u" arbitrary: n u) (auto simp: sdrop_add[symmetric])
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   184
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   185
lemma stake_cycle: "u \<noteq> [] \<Longrightarrow>
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   186
   stake n (cycle u) = concat (replicate (n div length u) u) @ take (n mod length u) u"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   187
by (subst mod_div_equality[of n "length u", symmetric], unfold stake_add[symmetric]) auto
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   188
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   189
lemma sdrop_cycle: "u \<noteq> [] \<Longrightarrow> sdrop n (cycle u) = cycle (rotate (n mod length u) u)"
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   190
by (induct n arbitrary: u) (auto simp: rotate1_rotate_swap rotate1_hd_tl rotate_conv_mod[symmetric])
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   191
d4fdda801e19 short library for streams
traytel
parents:
diff changeset
   192
end