diff --git a/src/ROOT b/src/ROOT index ef3df40..0c5a333 100644 --- a/src/ROOT +++ b/src/ROOT @@ -15,5 +15,6 @@ session Thorn_Calculus = HOL + "Thorn_Calculus-Semantics-Asynchronous" "Thorn_Calculus-Core_Bisimilarities" "Thorn_Calculus-Derived-Channels-Synchronous" + "Thorn_Calculus-FIFO_Transmission" document_files "root.tex" diff --git a/src/Thorn_Calculus-FIFO_Transmission.thy b/src/Thorn_Calculus-FIFO_Transmission.thy new file mode 100644 index 0000000..c074b6c --- /dev/null +++ b/src/Thorn_Calculus-FIFO_Transmission.thy @@ -0,0 +1,50 @@ +theory "Thorn_Calculus-FIFO_Transmission" + imports + "Thorn_Calculus-Processes" +begin + +record 'a node = + value_in_node :: 'a + next_nodes :: chan + +typedef 'a cursor = "UNIV :: 'a node channel set" morphisms cursor_to_channel cursor_from_channel .. + +text \ + The morally correct way to define \<^type>\node\ and \<^type>\cursor\ would be defining them as + mutually recursive datatypes with \<^const>\next_nodes\ being of type \<^typ>\'a cursor\. However, + this would require \<^type>\channel\ to be a bounded natural functor, which is impossible to + achieve (in particular, it is impossible to define an appropriate \set\ function for + \<^type>\channel\). +\ + +setup_lifting type_definition_cursor + +instance cursor :: (type) embeddable + by standard (meson cursor_to_channel_inject ex_inj inj_def) + +lift_definition + fifo_send :: "'a cursor \ 'a::embeddable \ ('a cursor \ process) \ process" + is "\a x P. \ c'. (a \ \value_in_node = x, next_nodes = untyped c'\ \ P c')" . + +lift_definition fifo_receive :: "'a cursor \ ('a::embeddable \ 'a cursor \ process) \ process" + is "\a P. a \ (n :: 'a node). (a \ n \ P (value_in_node n) (typed (next_nodes n)))" . + +syntax + "_fifo_send" :: "'a cursor \ pttrn \ 'a::embeddable \ process \ process" + (\(_ \ _ \\<^bsub>f\<^esub> _;/ _)\ [53, 0, 0, 52] 52) +translations + "c \ c' \\<^bsub>f\<^esub> x; p" \ "CONST fifo_send c x (\c'. p)" +print_translation \ + [preserve_binder_abs_receive_tr' @{const_syntax fifo_send} @{syntax_const "_fifo_send"}] +\ + +syntax + "_fifo_receive" :: "'a::embeddable cursor \ pttrn \ pttrn \ process \ process" + (\(3_ \ _ \\<^bsub>f\<^esub> _./ _)\ [53, 0, 0, 52] 52) +translations + "c \ c' \\<^bsub>f\<^esub> x. p" \ "CONST fifo_receive c (\x c'. p)" +print_translation \ + [preserve_binder_abs_receive_tr' @{const_syntax fifo_receive} @{syntax_const "_fifo_receive"}] +\ + +end