src/Doc/Datatypes/Datatypes.thy
changeset 54278 c830ead80c91
parent 54211 2c024c23d67f
child 54287 7f096d8eb3d0
equal deleted inserted replaced
54277:8dd0e0316881 54278:c830ead80c91
  1845       "tree\<^sub>i\<^sub>i_of_stream s =
  1845       "tree\<^sub>i\<^sub>i_of_stream s =
  1846          Node\<^sub>i\<^sub>i (shd s) (lmap tree\<^sub>i\<^sub>i_of_stream (LCons (stl s) LNil))"
  1846          Node\<^sub>i\<^sub>i (shd s) (lmap tree\<^sub>i\<^sub>i_of_stream (LCons (stl s) LNil))"
  1847 
  1847 
  1848 text {*
  1848 text {*
  1849 \noindent
  1849 \noindent
  1850 A more natural syntax, also supported by Isabelle, is to move corecursive calls
  1850 Fortunately, it is easy to prove the following lemma, where the corecursive call
  1851 under constructors:
  1851 is moved inside the lazy list constructor, thereby eliminating the need for
  1852 *}
  1852 @{const lmap}:
  1853 
  1853 *}
  1854     primcorec (*<*)(in late) (*>*)tree\<^sub>i\<^sub>i_of_stream :: "'a stream \<Rightarrow> 'a tree\<^sub>i\<^sub>i" where
  1854 
       
  1855     lemma tree\<^sub>i\<^sub>i_of_stream_alt:
  1855       "tree\<^sub>i\<^sub>i_of_stream s = Node\<^sub>i\<^sub>i (shd s) (LCons (tree\<^sub>i\<^sub>i_of_stream (stl s)) LNil)"
  1856       "tree\<^sub>i\<^sub>i_of_stream s = Node\<^sub>i\<^sub>i (shd s) (LCons (tree\<^sub>i\<^sub>i_of_stream (stl s)) LNil)"
       
  1857     by (subst tree\<^sub>i\<^sub>i_of_stream.code) simp
  1856 
  1858 
  1857 text {*
  1859 text {*
  1858 The next example illustrates corecursion through functions, which is a bit
  1860 The next example illustrates corecursion through functions, which is a bit
  1859 special. Deterministic finite automata (DFAs) are traditionally defined as
  1861 special. Deterministic finite automata (DFAs) are traditionally defined as
  1860 5-tuples @{text "(Q, \<Sigma>, \<delta>, q\<^sub>0, F)"}, where @{text Q} is a finite set of states,
  1862 5-tuples @{text "(Q, \<Sigma>, \<delta>, q\<^sub>0, F)"}, where @{text Q} is a finite set of states,