(* * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) * * SPDX-License-Identifier: GPL-2.0-only *) (*<*) (* THIS FILE IS AUTOMATICALLY GENERATED. YOUR EDITS WILL BE OVERWRITTEN. *) theory GenDataportSystem imports UserDataport begin (*>*) subsection \\label{ssec:dataportsys}Generated System Theory\ subsubsection \\label{sssec:dataportsystypes}Types\ text \ At the system level we have the now familiar generated types. \ type_synonym component = "(channel, component_state) comp" type_synonym lstate = "component_state local_state" type_synonym gstate = "(inst, channel, component_state) global_state" subsubsection \\label{sssec:dataportsysuntrusted}Untrusted Components\ text \ A definition is generated for the untrusted execution of the component, @{term DataportTest}. In this definition there are two interfaces the component can send and receive on, but the other details of the definition are identical to the previous examples. \ definition DataportTest_untrusted :: "(DataportTest_channel \ channel) \ component" where "DataportTest_untrusted ch \ LOOP ( UserStep \ ArbitraryRequest (ch DataportTest_d2) \ ArbitraryResponse (ch DataportTest_d2) \ ArbitraryRequest (ch DataportTest_d1) \ ArbitraryResponse (ch DataportTest_d1))" subsubsection \\label{sssec:dataportsysinst}Component Instances\ text \ The definitions for untrusted execution of the two component instances are generated by partially applying the untrusted definition of @{term DataportTest} with different functions mapping its interfaces to connections. In this way, two processes are formed that have identical local behaviour, but have different effects when they perform communication actions. \ definition comp2_untrusted :: component where "comp2_untrusted \ DataportTest_untrusted (\c. case c of DataportTest_d1 \ simple2 | DataportTest_d2 \ simple1)" definition comp1_untrusted :: component where "comp1_untrusted \ DataportTest_untrusted (\c. case c of DataportTest_d2 \ simple2 | DataportTest_d1 \ simple1)" subsubsection \\label{ssecdataportsysmem}Shared Memory Components\ text \ A component instance is generated for each connection involving a dataport, as mentioned previously. As for events, the user is given no opportunity to provide trusted definitions for these instances because we can automatically generate their precise behaviour without ambiguity. \ definition simple2\<^sub>d_instance :: component where "simple2\<^sub>d_instance \ Buf\<^sub>d (\_. simple2)" definition simple1\<^sub>d_instance :: component where "simple1\<^sub>d_instance \ Buf\<^sub>d (\_. simple1)" subsubsection \\label{sssec:dataportsysgs}Initial State\ text \ The initial state for this system includes cases for the introduced shared memory components, using the definitions presented above. Both begin in the common initial memory state containing the empty map. \ definition gs\<^sub>0 :: gstate where "gs\<^sub>0 p \ case trusted p of Some s \ Some s | _ \ (case p of comp2 \ Some (comp2_untrusted, Component init_component_state) | comp1 \ Some (comp1_untrusted, Component init_component_state) | simple2\<^sub>d \ Some (simple2\<^sub>d_instance, init_memory_state) | simple1\<^sub>d \ Some (simple1\<^sub>d_instance, init_memory_state))" (*<*) end (*>*)