(* Title: OAWN_SOS.thy License: BSD 2-Clause. See LICENSE. Author: Timothy Bourke *) section "Open semantics of the Algebra of Wireless Networks" theory OAWN_SOS imports TransitionSystems AWN begin text \ These are variants of the SOS rules that work against a mixed global/local context, where the global context is represented by a function @{term \} mapping ip addresses to states. \ subsection "Open structural operational semantics for sequential process expressions " inductive_set oseqp_sos :: "('s, 'm, 'p, 'l) seqp_env \ ip \ ((ip \ 's) \ ('s, 'm, 'p, 'l) seqp, 'm seq_action) transition set" for \ :: "('s, 'm, 'p, 'l) seqp_env" and i :: ip where obroadcastT: "\' i = \ i \ ((\, {l}broadcast(s\<^sub>m\<^sub>s\<^sub>g).p), broadcast (s\<^sub>m\<^sub>s\<^sub>g (\ i)), (\', p)) \ oseqp_sos \ i" | ogroupcastT: "\' i = \ i \ ((\, {l}groupcast(s\<^sub>i\<^sub>p\<^sub>s, s\<^sub>m\<^sub>s\<^sub>g).p), groupcast (s\<^sub>i\<^sub>p\<^sub>s (\ i)) (s\<^sub>m\<^sub>s\<^sub>g (\ i)), (\', p)) \ oseqp_sos \ i" | ounicastT: "\' i = \ i \ ((\, {l}unicast(s\<^sub>i\<^sub>p, s\<^sub>m\<^sub>s\<^sub>g).p \ q), unicast (s\<^sub>i\<^sub>p (\ i)) (s\<^sub>m\<^sub>s\<^sub>g (\ i)), (\', p)) \ oseqp_sos \ i" | onotunicastT:"\' i = \ i \ ((\, {l}unicast(s\<^sub>i\<^sub>p, s\<^sub>m\<^sub>s\<^sub>g).p \ q), \unicast (s\<^sub>i\<^sub>p (\ i)), (\', q)) \ oseqp_sos \ i" | osendT: "\' i = \ i \ ((\, {l}send(s\<^sub>m\<^sub>s\<^sub>g).p), send (s\<^sub>m\<^sub>s\<^sub>g (\ i)), (\', p)) \ oseqp_sos \ i" | odeliverT: "\' i = \ i \ ((\, {l}deliver(s\<^sub>d\<^sub>a\<^sub>t\<^sub>a).p), deliver (s\<^sub>d\<^sub>a\<^sub>t\<^sub>a (\ i)), (\', p)) \ oseqp_sos \ i" | oreceiveT: "\' i = u\<^sub>m\<^sub>s\<^sub>g msg (\ i) \ ((\, {l}receive(u\<^sub>m\<^sub>s\<^sub>g).p), receive msg, (\', p)) \ oseqp_sos \ i" | oassignT: "\' i = u (\ i) \ ((\, {l}\u\ p), \, (\', p)) \ oseqp_sos \ i" | ocallT: "((\, \ pn), a, (\', p')) \ oseqp_sos \ i \ ((\, call(pn)), a, (\', p')) \ oseqp_sos \ i" (* TPB: quite different to Table 1 *) | ochoiceT1: "((\, p), a, (\', p')) \ oseqp_sos \ i \ ((\, p \ q), a, (\', p')) \ oseqp_sos \ i" | ochoiceT2: "((\, q), a, (\', q')) \ oseqp_sos \ i \ ((\, p \ q), a, (\', q')) \ oseqp_sos \ i" | oguardT: "\' i \ g (\ i) \ ((\, {l}\g\ p), \, (\', p)) \ oseqp_sos \ i" inductive_cases oseq_callTE [elim]: "((\, call(pn)), a, (\', q)) \ oseqp_sos \ i" and oseq_choiceTE [elim]: "((\, p1 \ p2), a, (\', q)) \ oseqp_sos \ i" lemma oseq_broadcastTE [elim]: "\((\, {l}broadcast(s\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i; \a = broadcast (s\<^sub>m\<^sub>s\<^sub>g (\ i)); \' i = \ i; q = p\ \ P\ \ P" by (ind_cases "((\, {l}broadcast(s\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i") simp lemma oseq_groupcastTE [elim]: "\((\, {l}groupcast(s\<^sub>i\<^sub>p\<^sub>s, s\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i; \a = groupcast (s\<^sub>i\<^sub>p\<^sub>s (\ i)) (s\<^sub>m\<^sub>s\<^sub>g (\ i)); \' i = \ i; q = p\ \ P\ \ P" by (ind_cases "((\, {l}groupcast(s\<^sub>i\<^sub>p\<^sub>s, s\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i") simp lemma oseq_unicastTE [elim]: "\((\, {l}unicast(s\<^sub>i\<^sub>p, s\<^sub>m\<^sub>s\<^sub>g). p \ q), a, (\', r)) \ oseqp_sos \ i; \a = unicast (s\<^sub>i\<^sub>p (\ i)) (s\<^sub>m\<^sub>s\<^sub>g (\ i)); \' i = \ i; r = p\ \ P; \a = \unicast (s\<^sub>i\<^sub>p (\ i)); \' i = \ i; r = q\ \ P\ \ P" by (ind_cases "((\, {l}unicast(s\<^sub>i\<^sub>p, s\<^sub>m\<^sub>s\<^sub>g). p \ q), a, (\', r)) \ oseqp_sos \ i") simp_all lemma oseq_sendTE [elim]: "\((\, {l}send(s\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i; \a = send (s\<^sub>m\<^sub>s\<^sub>g (\ i)); \' i = \ i; q = p\ \ P\ \ P" by (ind_cases "((\, {l}send(s\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i") simp lemma oseq_deliverTE [elim]: "\((\, {l}deliver(s\<^sub>d\<^sub>a\<^sub>t\<^sub>a). p), a, (\', q)) \ oseqp_sos \ i; \a = deliver (s\<^sub>d\<^sub>a\<^sub>t\<^sub>a (\ i)); \' i = \ i; q = p\ \ P\ \ P" by (ind_cases "((\, {l}deliver(s\<^sub>d\<^sub>a\<^sub>t\<^sub>a). p), a, (\', q)) \ oseqp_sos \ i") simp lemma oseq_receiveTE [elim]: "\((\, {l}receive(u\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i; \msg. \a = receive msg; \' i = u\<^sub>m\<^sub>s\<^sub>g msg (\ i); q = p\ \ P\ \ P" by (ind_cases "((\, {l}receive(u\<^sub>m\<^sub>s\<^sub>g). p), a, (\', q)) \ oseqp_sos \ i") simp lemma oseq_assignTE [elim]: "\((\, {l}\u\ p), a, (\', q)) \ oseqp_sos \ i; \a = \; \' i = u (\ i); q = p\ \ P\ \ P" by (ind_cases "((\, {l}\u\ p), a, (\', q)) \ oseqp_sos \ i") simp lemma oseq_guardTE [elim]: "\((\, {l}\g\ p), a, (\', q)) \ oseqp_sos \ i; \a = \; \' i \ g (\ i); q = p\ \ P\ \ P" by (ind_cases "((\, {l}\g\ p), a, (\', q)) \ oseqp_sos \ i") simp lemmas oseqpTEs = oseq_broadcastTE oseq_groupcastTE oseq_unicastTE oseq_sendTE oseq_deliverTE oseq_receiveTE oseq_assignTE oseq_callTE oseq_choiceTE oseq_guardTE declare oseqp_sos.intros [intro] subsection "Open structural operational semantics for parallel process expressions " inductive_set oparp_sos :: "ip \ ((ip \ 's) \ 's1, 'm seq_action) transition set \ ('s2, 'm seq_action) transition set \ ((ip \ 's) \ ('s1 \ 's2), 'm seq_action) transition set" for i :: ip and S :: "((ip \ 's) \ 's1, 'm seq_action) transition set" and T :: "('s2, 'm seq_action) transition set" where oparleft: "\ ((\, s), a, (\', s')) \ S; \m. a \ receive m \ \ ((\, (s, t)), a, (\', (s', t))) \ oparp_sos i S T" | oparright: "\ (t, a, t') \ T; \m. a \ send m; \' i = \ i \ \ ((\, (s, t)), a, (\', (s, t'))) \ oparp_sos i S T" | oparboth: "\ ((\, s), receive m, (\', s')) \ S; (t, send m, t') \ T \ \ ((\, (s, t)), \, (\', (s', t'))) \ oparp_sos i S T" lemma opar_broadcastTE [elim]: "\((\, (s, t)), broadcast m, (\', (s', t'))) \ oparp_sos i S T; \((\, s), broadcast m, (\', s')) \ S; t' = t\ \ P; \(t, broadcast m, t') \ T; s' = s; \' i = \ i\ \ P\ \ P" by (ind_cases "((\, (s, t)), broadcast m, (\', (s', t'))) \ oparp_sos i S T") simp_all lemma opar_groupcastTE [elim]: "\((\, (s, t)), groupcast ips m, (\', (s', t'))) \ oparp_sos i S T; \((\, s), groupcast ips m, (\', s')) \ S; t' = t\ \ P; \(t, groupcast ips m, t') \ T; s' = s; \' i = \ i\ \ P\ \ P" by (ind_cases "((\, (s, t)), groupcast ips m, (\', (s', t'))) \ oparp_sos i S T") simp_all lemma opar_unicastTE [elim]: "\((\, (s, t)), unicast i m, (\', (s', t'))) \ oparp_sos i S T; \((\, s), unicast i m, (\', s')) \ S; t' = t\ \ P; \(t, unicast i m, t') \ T; s' = s; \' i = \ i\ \ P\ \ P" by (ind_cases "((\, (s, t)), unicast i m, (\', (s', t'))) \ oparp_sos i S T") simp_all lemma opar_notunicastTE [elim]: "\((\, (s, t)), notunicast i, (\', (s', t'))) \ oparp_sos i S T; \((\, s), notunicast i, (\', s')) \ S; t' = t\ \ P; \(t, notunicast i, t') \ T; s' = s; \' i = \ i\ \ P\ \ P" by (ind_cases "((\, (s, t)), notunicast i, (\', (s', t'))) \ oparp_sos i S T") simp_all lemma opar_sendTE [elim]: "\((\, (s, t)), send m, (\', (s', t'))) \ oparp_sos i S T; \((\, s), send m, (\', s')) \ S; t' = t\ \ P\ \ P" by (ind_cases "((\, (s, t)), send m, (\', (s', t'))) \ oparp_sos i S T") auto lemma opar_deliverTE [elim]: "\((\, (s, t)), deliver d, (\', (s', t'))) \ oparp_sos i S T; \((\, s), deliver d, (\', s')) \ S; t' = t\ \ P; \(t, deliver d, t') \ T; s' = s; \' i = \ i\ \ P\ \ P" by (ind_cases "((\, (s, t)), deliver d, (\', (s', t'))) \ oparp_sos i S T") simp_all lemma opar_receiveTE [elim]: "\((\, (s, t)), receive m, (\', (s', t'))) \ oparp_sos i S T; \(t, receive m, t') \ T; s' = s; \' i = \ i\ \ P\ \ P" by (ind_cases "((\, (s, t)), receive m, (\', (s', t'))) \ oparp_sos i S T") auto inductive_cases opar_tauTE: "((\, (s, t)), \, (\', (s', t'))) \ oparp_sos i S T" lemmas oparpTEs = opar_broadcastTE opar_groupcastTE opar_unicastTE opar_notunicastTE opar_sendTE opar_deliverTE opar_receiveTE lemma oparp_sos_cases [elim]: assumes "((\, (s, t)), a, (\', (s', t'))) \ oparp_sos i S T" and "\ ((\, s), a, (\', s')) \ S; \m. a \ receive m; t' = t \ \ P" and "\ (t, a, t') \ T; \m. a \ send m; s' = s; \' i = \ i \ \ P" and "\m. \ a = \; ((\, s), receive m, (\', s')) \ S; (t, send m, t') \ T \ \ P" shows "P" using assms by cases auto definition extg :: "('a \ 'b) \ 'c \ 'a \ 'b \ 'c" where "extg \ \((\, l1), l2). (\, (l1, l2))" lemma extgsimp [simp]: "extg ((\, l1), l2) = (\, (l1, l2))" unfolding extg_def by simp lemma extg_range_prod: "extg ` (i1 \ i2) = {(\, (s1, s2))|\ s1 s2. (\, s1) \ i1 \ s2 \ i2}" unfolding image_def extg_def by (rule Collect_cong) (auto split: prod.split) definition opar_comp :: "((ip \ 's) \ 's1, 'm seq_action) automaton \ ip \ ('s2, 'm seq_action) automaton \ ((ip \ 's) \ 's1 \ 's2, 'm seq_action) automaton" ("(_ \\\<^bsub>_\<^esub> _)" [102, 0, 103] 102) where "s \\\<^bsub>i\<^esub> t \ \ init = extg ` (init s \ init t), trans = oparp_sos i (trans s) (trans t) \" lemma opar_comp_def': "s \\\<^bsub>i\<^esub> t = \ init = {(\, (s\<^sub>l, t\<^sub>l))|\ s\<^sub>l t\<^sub>l. (\, s\<^sub>l) \ init s \ t\<^sub>l \ init t}, trans = oparp_sos i (trans s) (trans t) \" unfolding opar_comp_def extg_def image_def by (auto split: prod.split) lemma trans_opar_comp [simp]: "trans (s \\\<^bsub>i\<^esub> t) = oparp_sos i (trans s) (trans t)" unfolding opar_comp_def by simp lemma init_opar_comp [simp]: "init (s \\\<^bsub>i\<^esub> t) = extg ` (init s \ init t)" unfolding opar_comp_def by simp subsection "Open structural operational semantics for node expressions " inductive_set onode_sos :: "((ip \ 's) \ 'l, 'm seq_action) transition set \ ((ip \ 's) \ 'l net_state, 'm node_action) transition set" for S :: "((ip \ 's) \ 'l, 'm seq_action) transition set" where onode_bcast: "((\, s), broadcast m, (\', s')) \ S \ ((\, NodeS i s R), R:*cast(m), (\', NodeS i s' R)) \ onode_sos S" | onode_gcast: "((\, s), groupcast D m, (\', s')) \ S \ ((\, NodeS i s R), (R\D):*cast(m), (\', NodeS i s' R)) \ onode_sos S" | onode_ucast: "\ ((\, s), unicast d m, (\', s')) \ S; d\R \ \ ((\, NodeS i s R), {d}:*cast(m), (\', NodeS i s' R)) \ onode_sos S" (* Such assumptions aid later proofs, but they must be justified when transferring results to closed systems. *) | onode_notucast: "\ ((\, s), \unicast d, (\', s')) \ S; d\R; \j. j\i \ \' j = \ j \ \ ((\, NodeS i s R), \, (\', NodeS i s' R)) \ onode_sos S" | onode_deliver: "\ ((\, s), deliver d, (\', s')) \ S; \j. j\i \ \' j = \ j \ \ ((\, NodeS i s R), i:deliver(d), (\', NodeS i s' R)) \ onode_sos S" | onode_tau: "\ ((\, s), \, (\', s')) \ S; \j. j\i \ \' j = \ j \ \ ((\, NodeS i s R), \, (\', NodeS i s' R)) \ onode_sos S" | onode_receive: "((\, s), receive m, (\', s')) \ S \ ((\, NodeS i s R), {i}\{}:arrive(m), (\', NodeS i s' R)) \ onode_sos S" | onode_arrive: "\' i = \ i \ ((\, NodeS i s R), {}\{i}:arrive(m), (\', NodeS i s R)) \ onode_sos S" | onode_connect1: "\' i = \ i \ ((\, NodeS i s R), connect(i, i'), (\', NodeS i s (R \ {i'}))) \ onode_sos S" | onode_connect2: "\' i = \ i \ ((\, NodeS i s R), connect(i', i), (\', NodeS i s (R \ {i'}))) \ onode_sos S" | onode_disconnect1: "\' i = \ i \ ((\, NodeS i s R), disconnect(i, i'), (\', NodeS i s (R - {i'}))) \ onode_sos S" | onode_disconnect2: "\' i = \ i \ ((\, NodeS i s R), disconnect(i', i), (\', NodeS i s (R - {i'}))) \ onode_sos S" | onode_connect_other: "\ i \ i'; i \ i''; \' i = \ i \ \ ((\, NodeS i s R), connect(i', i''), (\', NodeS i s R)) \ onode_sos S" | onode_disconnect_other: "\ i \ i'; i \ i''; \' i = \ i \ \ ((\, NodeS i s R), disconnect(i', i''), (\', NodeS i s R)) \ onode_sos S" inductive_cases onode_arriveTE [elim]: "((\, NodeS i s R), ii\ni:arrive(m), (\', NodeS i' s' R')) \ onode_sos S" and onode_castTE [elim]: "((\, NodeS i s R), RR:*cast(m), (\', NodeS i' s' R')) \ onode_sos S" and onode_deliverTE [elim]: "((\, NodeS i s R), ii:deliver(d), (\', NodeS i' s' R')) \ onode_sos S" and onode_connectTE [elim]: "((\, NodeS i s R), connect(ii, ii'), (\', NodeS i' s' R')) \ onode_sos S" and onode_disconnectTE [elim]: "((\, NodeS i s R), disconnect(ii, ii'),(\', NodeS i' s' R')) \ onode_sos S" and onode_newpktTE [elim]: "((\, NodeS i s R), ii:newpkt(d, di), (\', NodeS i' s' R')) \ onode_sos S" and onode_tauTE [elim]: "((\, NodeS i s R), \, (\', NodeS i' s' R')) \ onode_sos S" lemma oarrives_or_not: assumes "((\, NodeS i s R), ii\ni:arrive(m), (\', NodeS i' s' R')) \ onode_sos S" shows "(ii = {i} \ ni = {}) \ (ii = {} \ ni = {i})" using assms by rule simp_all definition onode_comp :: "ip \ ((ip \ 's) \ 'l, 'm seq_action) automaton \ ip set \ ((ip \ 's) \ 'l net_state, 'm node_action) automaton" ("(\_ : (_) : _\\<^sub>o)" [0, 0, 0] 104) where "\i : onp : R\<^sub>i\\<^sub>o \ \ init = {(\, NodeS i s R\<^sub>i)|\ s. (\, s) \ init onp}, trans = onode_sos (trans onp) \" lemma trans_onode_comp: "trans (\i : S : R\\<^sub>o) = onode_sos (trans S)" unfolding onode_comp_def by simp lemma init_onode_comp: "init (\i : S : R\\<^sub>o) = {(\, NodeS i s R)|\ s. (\, s) \ init S}" unfolding onode_comp_def by simp lemmas onode_comps = trans_onode_comp init_onode_comp lemma fst_par_onode_comp [simp]: "trans (\i : s \\\<^bsub>I\<^esub> t : R\\<^sub>o) = onode_sos (oparp_sos I (trans s) (trans t))" unfolding onode_comp_def by simp lemma init_par_onode_comp [simp]: "init (\i : s \\\<^bsub>I\<^esub> t : R\\<^sub>o) = {(\, NodeS i (s1, s2) R)|\ s1 s2. ((\, s1), s2) \ init s \ init t}" unfolding onode_comp_def by (simp add: extg_range_prod) lemma onode_sos_dest_is_net_state: assumes "((\, p), a, s') \ onode_sos S" shows "\\' i' \' R'. s' = (\', NodeS i' \' R')" using assms proof - assume "((\, p), a, s') \ onode_sos S" then obtain \' i' \' R' where "s' = (\', NodeS i' \' R')" by (cases s') (auto elim!: onode_sos.cases) thus ?thesis by simp qed lemma onode_sos_dest_is_net_state': assumes "((\, NodeS i p R), a, s') \ onode_sos S" shows "\\' \' R'. s' = (\', NodeS i \' R')" using assms proof - assume "((\, NodeS i p R), a, s') \ onode_sos S" then obtain \' \' R' where "s' = (\', NodeS i \' R')" by (cases s') (auto elim!: onode_sos.cases) thus ?thesis by simp qed lemma onode_sos_dest_is_net_state'': assumes "((\, NodeS i p R), a, (\', s')) \ onode_sos S" shows "\\' R'. s' = NodeS i \' R'" proof - define ns' where "ns' = (\', s')" with assms have "((\, NodeS i p R), a, ns') \ onode_sos S" by simp then obtain \'' \' R' where "ns' = (\'', NodeS i \' R')" by (metis onode_sos_dest_is_net_state') hence "s' = NodeS i \' R'" by (simp add: ns'_def) thus ?thesis by simp qed lemma onode_sos_src_is_net_state: assumes "((\, p), a, s') \ onode_sos S" shows "\i \ R. p = NodeS i \ R" using assms proof - assume "((\, p), a, s') \ onode_sos S" then obtain i \ R where "p = NodeS i \ R" by (cases s') (auto elim!: onode_sos.cases) thus ?thesis by simp qed lemma onode_sos_net_states: assumes "((\, s), a, (\', s')) \ onode_sos S" shows "\i \ R \' R'. s = NodeS i \ R \ s' = NodeS i \' R'" proof - from assms obtain i \ R where "s = NodeS i \ R" by (metis onode_sos_src_is_net_state) moreover with assms obtain \' R' where "s' = NodeS i \' R'" by (auto dest!: onode_sos_dest_is_net_state') ultimately show ?thesis by simp qed lemma node_sos_cases [elim]: "((\, NodeS i p R), a, (\', NodeS i p' R')) \ onode_sos S \ (\m . \ a = R:*cast(m); R' = R; ((\, p), broadcast m, (\', p')) \ S \ \ P) \ (\m D. \ a = (R \ D):*cast(m); R' = R; ((\, p), groupcast D m, (\', p')) \ S \ \ P) \ (\d m. \ a = {d}:*cast(m); R' = R; ((\, p), unicast d m, (\', p')) \ S; d \ R \ \ P) \ (\d. \ a = \; R' = R; ((\, p), \unicast d, (\', p')) \ S; d \ R \ \ P) \ (\d. \ a = i:deliver(d); R' = R; ((\, p), deliver d, (\', p')) \ S \ \ P) \ (\m. \ a = {i}\{}:arrive(m); R' = R; ((\, p), receive m, (\', p')) \ S \ \ P) \ ( \ a = \; R' = R; ((\, p), \, (\', p')) \ S \ \ P) \ (\m. \ a = {}\{i}:arrive(m); R' = R; p = p'; \' i = \ i \ \ P) \ (\i i'. \ a = connect(i, i'); R' = R \ {i'}; p = p'; \' i = \ i \ \ P) \ (\i i'. \ a = connect(i', i); R' = R \ {i'}; p = p'; \' i = \ i \ \ P) \ (\i i'. \ a = disconnect(i, i'); R' = R - {i'}; p = p'; \' i = \ i \ \ P) \ (\i i'. \ a = disconnect(i', i); R' = R - {i'}; p = p'; \' i = \ i \ \ P) \ (\i i' i''. \ a = connect(i', i''); R' = R; p = p'; i \ i'; i \ i''; \' i = \ i \ \ P) \ (\i i' i''. \ a = disconnect(i', i''); R' = R; p = p'; i \ i'; i \ i''; \' i = \ i \ \ P) \ P" by (erule onode_sos.cases) (simp | metis)+ subsection "Open structural operational semantics for partial network expressions " inductive_set opnet_sos :: "((ip \ 's) \ 'l net_state, 'm node_action) transition set \ ((ip \ 's) \ 'l net_state, 'm node_action) transition set \ ((ip \ 's) \ 'l net_state, 'm node_action) transition set" for S :: "((ip \ 's) \ 'l net_state, 'm node_action) transition set" and T :: "((ip \ 's) \ 'l net_state, 'm node_action) transition set" where opnet_cast1: "\ ((\, s), R:*cast(m), (\', s')) \ S; ((\, t), H\K:arrive(m), (\', t')) \ T; H \ R; K \ R = {} \ \ ((\, SubnetS s t), R:*cast(m), (\', SubnetS s' t')) \ opnet_sos S T" | opnet_cast2: "\ ((\, s), H\K:arrive(m), (\', s')) \ S; ((\, t), R:*cast(m), (\', t')) \ T; H \ R; K \ R = {} \ \ ((\, SubnetS s t), R:*cast(m), (\', SubnetS s' t')) \ opnet_sos S T" | opnet_arrive: "\ ((\, s), H\K:arrive(m), (\', s')) \ S; ((\, t), H'\K':arrive(m), (\', t')) \ T \ \ ((\, SubnetS s t), (H \ H')\(K \ K'):arrive(m), (\', SubnetS s' t')) \ opnet_sos S T" | opnet_deliver1: "((\, s), i:deliver(d), (\', s')) \ S \ ((\, SubnetS s t), i:deliver(d), (\', SubnetS s' t)) \ opnet_sos S T" | opnet_deliver2: "\ ((\, t), i:deliver(d), (\', t')) \ T \ \ ((\, SubnetS s t), i:deliver(d), (\', SubnetS s t')) \ opnet_sos S T" | opnet_tau1: "((\, s), \, (\', s')) \ S \ ((\, SubnetS s t), \, (\', SubnetS s' t)) \ opnet_sos S T" | opnet_tau2: "((\, t), \, (\', t')) \ T \ ((\, SubnetS s t), \, (\', SubnetS s t')) \ opnet_sos S T" | opnet_connect: "\ ((\, s), connect(i, i'), (\', s')) \ S; ((\, t), connect(i, i'), (\', t')) \ T \ \ ((\, SubnetS s t), connect(i, i'), (\', SubnetS s' t')) \ opnet_sos S T" | opnet_disconnect: "\ ((\, s), disconnect(i, i'), (\', s')) \ S; ((\, t), disconnect(i, i'), (\', t')) \ T \ \ ((\, SubnetS s t), disconnect(i, i'), (\', SubnetS s' t')) \ opnet_sos S T" inductive_cases opartial_castTE [elim]: "((\, s), R:*cast(m), (\', s')) \ opnet_sos S T" and opartial_arriveTE [elim]: "((\, s), H\K:arrive(m), (\', s')) \ opnet_sos S T" and opartial_deliverTE [elim]: "((\, s), i:deliver(d), (\', s')) \ opnet_sos S T" and opartial_tauTE [elim]: "((\, s), \, (\', s')) \ opnet_sos S T" and opartial_connectTE [elim]: "((\, s), connect(i, i'), (\', s')) \ opnet_sos S T" and opartial_disconnectTE [elim]: "((\, s), disconnect(i, i'), (\', s')) \ opnet_sos S T" and opartial_newpktTE [elim]: "((\, s), i:newpkt(d, di), (\', s')) \ opnet_sos S T" fun opnet :: "(ip \ ((ip \ 's) \ 'l, 'm seq_action) automaton) \ net_tree \ ((ip \ 's) \ 'l net_state, 'm node_action) automaton" where "opnet onp (\i; R\<^sub>i\) = \i : onp i : R\<^sub>i\\<^sub>o" | "opnet onp (p\<^sub>1 \ p\<^sub>2) = \ init = {(\, SubnetS s\<^sub>1 s\<^sub>2) |\ s\<^sub>1 s\<^sub>2. (\, s\<^sub>1) \ init (opnet onp p\<^sub>1) \ (\, s\<^sub>2) \ init (opnet onp p\<^sub>2) \ net_ips s\<^sub>1 \ net_ips s\<^sub>2 = {}}, trans = opnet_sos (trans (opnet onp p\<^sub>1)) (trans (opnet onp p\<^sub>2)) \" lemma opnet_node_init [elim, simp]: assumes "(\, s) \ init (opnet onp \i; R\)" shows "(\, s) \ { (\, NodeS i ns R) |\ ns. (\, ns) \ init (onp i)}" using assms by (simp add: onode_comp_def) lemma opnet_node_init' [elim]: assumes "(\, s) \ init (opnet onp \i; R\)" obtains ns where "s = NodeS i ns R" and "(\, ns) \ init (onp i)" using assms by (auto simp add: onode_comp_def) lemma opnet_node_trans [elim, simp]: assumes "(s, a, s') \ trans (opnet onp \i; R\)" shows "(s, a, s') \ onode_sos (trans (onp i))" using assms by (simp add: trans_onode_comp) subsection "Open structural operational semantics for complete network expressions " inductive_set ocnet_sos :: "((ip \ 's) \ 'l net_state, 'm::msg node_action) transition set \ ((ip \ 's) \ 'l net_state, 'm node_action) transition set" for S :: "((ip \ 's) \ 'l net_state, 'm node_action) transition set" where ocnet_connect: "\ ((\, s), connect(i, i'), (\', s')) \ S; \j. j \ net_ips s \ (\' j = \ j) \ \ ((\, s), connect(i, i'), (\', s')) \ ocnet_sos S" | ocnet_disconnect: "\ ((\, s), disconnect(i, i'), (\', s')) \ S; \j. j \ net_ips s \ (\' j = \ j) \ \ ((\, s), disconnect(i, i'), (\', s')) \ ocnet_sos S" | ocnet_cast: "\ ((\, s), R:*cast(m), (\', s')) \ S; \j. j \ net_ips s \ (\' j = \ j) \ \ ((\, s), \, (\', s')) \ ocnet_sos S" | ocnet_tau: "\ ((\, s), \, (\', s')) \ S; \j. j \ net_ips s \ (\' j = \ j) \ \ ((\, s), \, (\', s')) \ ocnet_sos S" | ocnet_deliver: "\ ((\, s), i:deliver(d), (\', s')) \ S; \j. j \ net_ips s \ (\' j = \ j) \ \ ((\, s), i:deliver(d), (\', s')) \ ocnet_sos S" | ocnet_newpkt: "\ ((\, s), {i}\K:arrive(newpkt(d, di)), (\', s')) \ S; \j. j \ net_ips s \ (\' j = \ j) \ \ ((\, s), i:newpkt(d, di), (\', s')) \ ocnet_sos S" inductive_cases oconnect_completeTE: "((\, s), connect(i, i'), (\', s')) \ ocnet_sos S" and odisconnect_completeTE: "((\, s), disconnect(i, i'), (\', s')) \ ocnet_sos S" and otau_completeTE: "((\, s), \, (\', s')) \ ocnet_sos S" and odeliver_completeTE: "((\, s), i:deliver(d), (\', s')) \ ocnet_sos S" and onewpkt_completeTE: "((\, s), i:newpkt(d, di), (\', s')) \ ocnet_sos S" lemmas ocompleteTEs = oconnect_completeTE odisconnect_completeTE otau_completeTE odeliver_completeTE onewpkt_completeTE lemma ocomplete_no_cast [simp]: "((\, s), R:*cast(m), (\', s')) \ ocnet_sos T" proof assume "((\, s), R:*cast(m), (\', s')) \ ocnet_sos T" hence "R:*cast(m) \ R:*cast(m)" by (rule ocnet_sos.cases) auto thus False by simp qed lemma ocomplete_no_arrive [simp]: "((\, s), ii\ni:arrive(m), (\', s')) \ ocnet_sos T" proof assume "((\, s), ii\ni:arrive(m), (\', s')) \ ocnet_sos T" hence "ii\ni:arrive(m) \ ii\ni:arrive(m)" by (rule ocnet_sos.cases) auto thus False by simp qed lemma ocomplete_no_change [elim]: assumes "((\, s), a, (\', s')) \ ocnet_sos T" and "j \ net_ips s" shows "\' j = \ j" using assms by cases simp_all lemma ocomplete_transE [elim]: assumes "((\, \), a, (\', \')) \ ocnet_sos (trans (opnet onp n))" obtains a' where "((\, \), a', (\', \')) \ trans (opnet onp n)" using assms by (cases a) (auto elim!: ocompleteTEs [simplified]) abbreviation oclosed :: "((ip \ 's) \ 'l net_state, ('m::msg) node_action) automaton \ ((ip \ 's) \ 'l net_state, 'm node_action) automaton" where "oclosed \ (\A. A \ trans := ocnet_sos (trans A) \)" end