diff -r 03c5c2db3a47 -r 7a994dc08cea src/Doc/Datatypes/Datatypes.thy --- a/src/Doc/Datatypes/Datatypes.thy Fri Sep 20 14:50:06 2013 +0200 +++ b/src/Doc/Datatypes/Datatypes.thy Fri Sep 20 15:05:47 2013 +0200 @@ -1410,7 +1410,7 @@ codatatype 'a tree\<^sub>i\<^sub>s = Node\<^sub>i\<^sub>s (lbl\<^sub>i\<^sub>s: 'a) (sub\<^sub>i\<^sub>s: "'a tree\<^sub>i\<^sub>s fset") codatatype 'a state_machine = - State_Machine bool "'a \ 'a state_machine" + State_Machine (accept: bool) (trans: "'a \ 'a state_machine") subsection {* Command Syntax @@ -1764,6 +1764,30 @@ "of_dfa \ F q = State_Machine (q \ F) (of_dfa \ F o \ q)" . +text {* +\noindent +The map function for the function type (@{text \}) is composition +(@{text "op \"}). + +\noindent +For convenience, corecursion through functions can be expressed using +@{text \}-expressions and function application rather than composition. +For example: +*} + + primcorec empty_machine :: "'a state_machine" where + "empty_machine = State_Machine False (\_. empty_machine)" + . + + primcorec not_machine :: "'a state_machine \ 'a state_machine" where + "not_machine M = State_Machine (\ accept M) (\a. not_machine (trans M a))" + . + + primcorec_notyet plus_machine :: "'a state_machine \ 'a state_machine" where + "or_machine M N = + State_Machine (accept M \ accept N) + (\a. or_machine (trans M a) (trans N a))" + subsubsection {* Nested-as-Mutual Corecursion \label{sssec:primcorec-nested-as-mutual-corecursion} *}