7 |
7 |
8 theory Solve |
8 theory Solve |
9 imports IOA |
9 imports IOA |
10 begin |
10 begin |
11 |
11 |
12 definition is_weak_pmap :: "['c => 'a, ('action,'c)ioa,('action,'a)ioa] => bool" where |
12 definition is_weak_pmap :: "['c \<Rightarrow> 'a, ('action,'c)ioa,('action,'a)ioa] \<Rightarrow> bool" where |
13 "is_weak_pmap f C A == |
13 "is_weak_pmap f C A \<equiv> |
14 (!s:starts_of(C). f(s):starts_of(A)) & |
14 (\<forall>s\<in>starts_of(C). f(s)\<in>starts_of(A)) \<and> |
15 (!s t a. reachable C s & |
15 (\<forall>s t a. reachable C s \<and> |
16 (s,a,t):trans_of(C) |
16 (s,a,t)\<in>trans_of(C) |
17 --> (if a:externals(asig_of(C)) then |
17 \<longrightarrow> (if a\<in>externals(asig_of(C)) then |
18 (f(s),a,f(t)):trans_of(A) |
18 (f(s),a,f(t))\<in>trans_of(A) |
19 else f(s)=f(t)))" |
19 else f(s)=f(t)))" |
20 |
20 |
21 declare mk_trace_thm [simp] trans_in_actions [simp] |
21 declare mk_trace_thm [simp] trans_in_actions [simp] |
22 |
22 |
23 lemma trace_inclusion: |
23 lemma trace_inclusion: |
24 "[| IOA(C); IOA(A); externals(asig_of(C)) = externals(asig_of(A)); |
24 "[| IOA(C); IOA(A); externals(asig_of(C)) = externals(asig_of(A)); |
25 is_weak_pmap f C A |] ==> traces(C) <= traces(A)" |
25 is_weak_pmap f C A |] ==> traces(C) \<subseteq> traces(A)" |
26 apply (unfold is_weak_pmap_def traces_def) |
26 apply (unfold is_weak_pmap_def traces_def) |
27 |
27 |
28 apply (simp (no_asm) add: has_trace_def) |
28 apply (simp (no_asm) add: has_trace_def) |
29 apply safe |
29 apply safe |
30 apply (rename_tac ex1 ex2) |
30 apply (rename_tac ex1 ex2) |
32 (* choose same trace, therefore same NF *) |
32 (* choose same trace, therefore same NF *) |
33 apply (rule_tac x = "mk_trace C ex1" in exI) |
33 apply (rule_tac x = "mk_trace C ex1" in exI) |
34 apply simp |
34 apply simp |
35 |
35 |
36 (* give execution of abstract automata *) |
36 (* give execution of abstract automata *) |
37 apply (rule_tac x = "(mk_trace A ex1,%i. f (ex2 i))" in bexI) |
37 apply (rule_tac x = "(mk_trace A ex1,\<lambda>i. f (ex2 i))" in bexI) |
38 |
38 |
39 (* Traces coincide *) |
39 (* Traces coincide *) |
40 apply (simp (no_asm_simp) add: mk_trace_def filter_oseq_idemp) |
40 apply (simp (no_asm_simp) add: mk_trace_def filter_oseq_idemp) |
41 |
41 |
42 (* Use lemma *) |
42 (* Use lemma *) |
60 apply simp |
60 apply simp |
61 done |
61 done |
62 |
62 |
63 (* Lemmata *) |
63 (* Lemmata *) |
64 |
64 |
65 lemma imp_conj_lemma: "(P ==> Q-->R) ==> P&Q --> R" |
65 lemma imp_conj_lemma: "(P \<Longrightarrow> Q\<longrightarrow>R) \<Longrightarrow> P\<and>Q \<longrightarrow> R" |
66 by blast |
66 by blast |
67 |
67 |
68 |
68 |
69 (* fist_order_tautology of externals_of_par *) |
69 (* fist_order_tautology of externals_of_par *) |
70 lemma externals_of_par_extra: |
70 lemma externals_of_par_extra: |
71 "a:externals(asig_of(A1||A2)) = |
71 "a\<in>externals(asig_of(A1||A2)) = |
72 (a:externals(asig_of(A1)) & a:externals(asig_of(A2)) | |
72 (a\<in>externals(asig_of(A1)) \<and> a\<in>externals(asig_of(A2)) \<or> |
73 a:externals(asig_of(A1)) & a~:externals(asig_of(A2)) | |
73 a\<in>externals(asig_of(A1)) \<and> a\<notin>externals(asig_of(A2)) \<or> |
74 a~:externals(asig_of(A1)) & a:externals(asig_of(A2)))" |
74 a\<notin>externals(asig_of(A1)) \<and> a\<in>externals(asig_of(A2)))" |
75 apply (auto simp add: externals_def asig_of_par asig_comp_def asig_inputs_def asig_outputs_def) |
75 apply (auto simp add: externals_def asig_of_par asig_comp_def asig_inputs_def asig_outputs_def) |
76 done |
76 done |
77 |
77 |
78 lemma comp1_reachable: "[| reachable (C1||C2) s |] ==> reachable C1 (fst s)" |
78 lemma comp1_reachable: "[| reachable (C1||C2) s |] ==> reachable C1 (fst s)" |
79 apply (simp add: reachable_def) |
79 apply (simp add: reachable_def) |
80 apply (erule bexE) |
80 apply (erule bexE) |
81 apply (rule_tac x = |
81 apply (rule_tac x = |
82 "(filter_oseq (%a. a:actions (asig_of (C1))) (fst ex) , %i. fst (snd ex i))" in bexI) |
82 "(filter_oseq (\<lambda>a. a\<in>actions (asig_of (C1))) (fst ex) , \<lambda>i. fst (snd ex i))" in bexI) |
83 (* fst(s) is in projected execution *) |
83 (* fst(s) is in projected execution *) |
84 apply force |
84 apply force |
85 (* projected execution is indeed an execution *) |
85 (* projected execution is indeed an execution *) |
86 apply (simp cong del: if_weak_cong |
86 apply (simp cong del: if_weak_cong |
87 add: executions_def is_execution_fragment_def par_def starts_of_def |
87 add: executions_def is_execution_fragment_def par_def starts_of_def |
94 component of a parallel composition. *) |
94 component of a parallel composition. *) |
95 lemma comp2_reachable: "[| reachable (C1||C2) s|] ==> reachable C2 (snd s)" |
95 lemma comp2_reachable: "[| reachable (C1||C2) s|] ==> reachable C2 (snd s)" |
96 apply (simp add: reachable_def) |
96 apply (simp add: reachable_def) |
97 apply (erule bexE) |
97 apply (erule bexE) |
98 apply (rule_tac x = |
98 apply (rule_tac x = |
99 "(filter_oseq (%a. a:actions (asig_of (C2))) (fst ex) , %i. snd (snd ex i))" in bexI) |
99 "(filter_oseq (\<lambda>a. a\<in>actions (asig_of (C2))) (fst ex) , \<lambda>i. snd (snd ex i))" in bexI) |
100 (* fst(s) is in projected execution *) |
100 (* fst(s) is in projected execution *) |
101 apply force |
101 apply force |
102 (* projected execution is indeed an execution *) |
102 (* projected execution is indeed an execution *) |
103 apply (simp cong del: if_weak_cong |
103 apply (simp cong del: if_weak_cong |
104 add: executions_def is_execution_fragment_def par_def starts_of_def |
104 add: executions_def is_execution_fragment_def par_def starts_of_def |
113 "[| is_weak_pmap f C1 A1; |
113 "[| is_weak_pmap f C1 A1; |
114 externals(asig_of(A1))=externals(asig_of(C1)); |
114 externals(asig_of(A1))=externals(asig_of(C1)); |
115 is_weak_pmap g C2 A2; |
115 is_weak_pmap g C2 A2; |
116 externals(asig_of(A2))=externals(asig_of(C2)); |
116 externals(asig_of(A2))=externals(asig_of(C2)); |
117 compat_ioas C1 C2; compat_ioas A1 A2 |] |
117 compat_ioas C1 C2; compat_ioas A1 A2 |] |
118 ==> is_weak_pmap (%p.(f(fst(p)),g(snd(p)))) (C1||C2) (A1||A2)" |
118 ==> is_weak_pmap (\<lambda>p.(f(fst(p)),g(snd(p)))) (C1||C2) (A1||A2)" |
119 apply (unfold is_weak_pmap_def) |
119 apply (unfold is_weak_pmap_def) |
120 apply (rule conjI) |
120 apply (rule conjI) |
121 (* start_states *) |
121 (* start_states *) |
122 apply (simp add: par_def starts_of_def) |
122 apply (simp add: par_def starts_of_def) |
123 (* transitions *) |
123 (* transitions *) |
137 apply (simp add: comp1_reachable comp2_reachable ext_is_act ext1_ext2_is_not_act2) |
137 apply (simp add: comp1_reachable comp2_reachable ext_is_act ext1_ext2_is_not_act2) |
138 (* case 3 a:~e(A1) | a:e(A2) *) |
138 (* case 3 a:~e(A1) | a:e(A2) *) |
139 apply (simp add: comp1_reachable comp2_reachable ext_is_act ext1_ext2_is_not_act1) |
139 apply (simp add: comp1_reachable comp2_reachable ext_is_act ext1_ext2_is_not_act1) |
140 (* case 4 a:~e(A1) | a~:e(A2) *) |
140 (* case 4 a:~e(A1) | a~:e(A2) *) |
141 apply (rule impI) |
141 apply (rule impI) |
142 apply (subgoal_tac "a~:externals (asig_of (A1)) & a~:externals (asig_of (A2))") |
142 apply (subgoal_tac "a\<notin>externals (asig_of (A1)) & a\<notin>externals (asig_of (A2))") |
143 (* delete auxiliary subgoal *) |
143 (* delete auxiliary subgoal *) |
144 prefer 2 |
144 prefer 2 |
145 apply force |
145 apply force |
146 apply (simp (no_asm) add: conj_disj_distribR cong add: conj_cong split: if_split) |
146 apply (simp (no_asm) add: conj_disj_distribR cong add: conj_cong split: if_split) |
147 apply (tactic \<open> |
147 apply (tactic \<open> |
151 |
151 |
152 |
152 |
153 lemma reachable_rename_ioa: "[| reachable (rename C g) s |] ==> reachable C s" |
153 lemma reachable_rename_ioa: "[| reachable (rename C g) s |] ==> reachable C s" |
154 apply (simp add: reachable_def) |
154 apply (simp add: reachable_def) |
155 apply (erule bexE) |
155 apply (erule bexE) |
156 apply (rule_tac x = "((%i. case (fst ex i) of None => None | Some (x) => g x) ,snd ex)" in bexI) |
156 apply (rule_tac x = "((\<lambda>i. case (fst ex i) of None \<Rightarrow> None | Some (x) => g x) ,snd ex)" in bexI) |
157 apply (simp (no_asm)) |
157 apply (simp (no_asm)) |
158 (* execution is indeed an execution of C *) |
158 (* execution is indeed an execution of C *) |
159 apply (simp add: executions_def is_execution_fragment_def par_def |
159 apply (simp add: executions_def is_execution_fragment_def par_def |
160 starts_of_def trans_of_def rename_def split: option.split) |
160 starts_of_def trans_of_def rename_def split: option.split) |
161 apply force |
161 apply force |