equal
deleted
inserted
replaced
1408 codatatype 'a tree\<^sub>i\<^sub>i = Node\<^sub>i\<^sub>i (lbl\<^sub>i\<^sub>i: 'a) (sub\<^sub>i\<^sub>i: "'a tree\<^sub>i\<^sub>i llist") |
1408 codatatype 'a tree\<^sub>i\<^sub>i = Node\<^sub>i\<^sub>i (lbl\<^sub>i\<^sub>i: 'a) (sub\<^sub>i\<^sub>i: "'a tree\<^sub>i\<^sub>i llist") |
1409 |
1409 |
1410 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") |
1410 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") |
1411 |
1411 |
1412 codatatype 'a state_machine = |
1412 codatatype 'a state_machine = |
1413 State_Machine bool "'a \<Rightarrow> 'a state_machine" |
1413 State_Machine (accept: bool) (trans: "'a \<Rightarrow> 'a state_machine") |
1414 |
1414 |
1415 |
1415 |
1416 subsection {* Command Syntax |
1416 subsection {* Command Syntax |
1417 \label{ssec:codatatype-command-syntax} *} |
1417 \label{ssec:codatatype-command-syntax} *} |
1418 |
1418 |
1761 *} |
1761 *} |
1762 |
1762 |
1763 primcorec of_dfa :: "('q \<Rightarrow> 'a \<Rightarrow> 'q) \<Rightarrow> 'q set \<Rightarrow> 'q \<Rightarrow> 'a state_machine" where |
1763 primcorec of_dfa :: "('q \<Rightarrow> 'a \<Rightarrow> 'q) \<Rightarrow> 'q set \<Rightarrow> 'q \<Rightarrow> 'a state_machine" where |
1764 "of_dfa \<delta> F q = State_Machine (q \<in> F) (of_dfa \<delta> F o \<delta> q)" |
1764 "of_dfa \<delta> F q = State_Machine (q \<in> F) (of_dfa \<delta> F o \<delta> q)" |
1765 . |
1765 . |
|
1766 |
|
1767 text {* |
|
1768 \noindent |
|
1769 The map function for the function type (@{text \<Rightarrow>}) is composition |
|
1770 (@{text "op \<circ>"}). |
|
1771 |
|
1772 \noindent |
|
1773 For convenience, corecursion through functions can be expressed using |
|
1774 @{text \<lambda>}-expressions and function application rather than composition. |
|
1775 For example: |
|
1776 *} |
|
1777 |
|
1778 primcorec empty_machine :: "'a state_machine" where |
|
1779 "empty_machine = State_Machine False (\<lambda>_. empty_machine)" |
|
1780 . |
|
1781 |
|
1782 primcorec not_machine :: "'a state_machine \<Rightarrow> 'a state_machine" where |
|
1783 "not_machine M = State_Machine (\<not> accept M) (\<lambda>a. not_machine (trans M a))" |
|
1784 . |
|
1785 |
|
1786 primcorec_notyet plus_machine :: "'a state_machine \<Rightarrow> 'a state_machine" where |
|
1787 "or_machine M N = |
|
1788 State_Machine (accept M \<or> accept N) |
|
1789 (\<lambda>a. or_machine (trans M a) (trans N a))" |
1766 |
1790 |
1767 |
1791 |
1768 subsubsection {* Nested-as-Mutual Corecursion |
1792 subsubsection {* Nested-as-Mutual Corecursion |
1769 \label{sssec:primcorec-nested-as-mutual-corecursion} *} |
1793 \label{sssec:primcorec-nested-as-mutual-corecursion} *} |
1770 |
1794 |