author | huffman |
Thu, 18 Feb 2010 13:29:59 -0800 | |
changeset 35215 | a03462cbf86f |
parent 35174 | e15040ae75d7 |
child 39120 | dd0431961507 |
permissions | -rw-r--r-- |
3072
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
1 |
(* Title: HOLCF/IOA/ABP/Correctness.thy |
12218 | 2 |
Author: Olaf Müller |
3072
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
3 |
*) |
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
4 |
|
17244 | 5 |
header {* The main correctness proof: System_fin implements System *} |
6 |
||
7 |
theory Correctness |
|
8 |
imports IOA Env Impl Impl_finite |
|
9 |
begin |
|
3072
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
10 |
|
27361 | 11 |
primrec reduce :: "'a list => 'a list" |
12 |
where |
|
17244 | 13 |
reduce_Nil: "reduce [] = []" |
27361 | 14 |
| reduce_Cons: "reduce(x#xs) = |
17244 | 15 |
(case xs of |
16 |
[] => [x] |
|
17 |
| y#ys => (if (x=y) |
|
18 |
then reduce xs |
|
3072
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
19 |
else (x#(reduce xs))))" |
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
20 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
21 |
definition |
19689 | 22 |
abs where |
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
23 |
"abs = |
19689 | 24 |
(%p.(fst(p),(fst(snd(p)),(fst(snd(snd(p))), |
25 |
(reduce(fst(snd(snd(snd(p))))),reduce(snd(snd(snd(snd(p))))))))))" |
|
17244 | 26 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
27 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
28 |
system_ioa :: "('m action, bool * 'm impl_state)ioa" where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
29 |
"system_ioa = (env_ioa || impl_ioa)" |
3072
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
30 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
31 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
32 |
system_fin_ioa :: "('m action, bool * 'm impl_state)ioa" where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
33 |
"system_fin_ioa = (env_ioa || impl_fin_ioa)" |
17244 | 34 |
|
3072
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
35 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
36 |
axiomatization where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
20918
diff
changeset
|
37 |
sys_IOA: "IOA system_ioa" and |
17244 | 38 |
sys_fin_IOA: "IOA system_fin_ioa" |
39 |
||
19738 | 40 |
|
41 |
||
42 |
declare split_paired_All [simp del] Collect_empty_eq [simp del] |
|
43 |
||
44 |
lemmas [simp] = |
|
45 |
srch_asig_def rsch_asig_def rsch_ioa_def srch_ioa_def ch_ioa_def |
|
46 |
ch_asig_def srch_actions_def rsch_actions_def rename_def rename_set_def asig_of_def |
|
47 |
actions_def exis_elim srch_trans_def rsch_trans_def ch_trans_def |
|
48 |
trans_of_def asig_projections set_lemmas |
|
49 |
||
50 |
lemmas abschannel_fin [simp] = |
|
51 |
srch_fin_asig_def rsch_fin_asig_def |
|
52 |
rsch_fin_ioa_def srch_fin_ioa_def |
|
53 |
ch_fin_ioa_def ch_fin_trans_def ch_fin_asig_def |
|
54 |
||
55 |
lemmas impl_ioas = sender_ioa_def receiver_ioa_def |
|
56 |
and impl_trans = sender_trans_def receiver_trans_def |
|
57 |
and impl_asigs = sender_asig_def receiver_asig_def |
|
58 |
||
59 |
declare let_weak_cong [cong] |
|
35215
a03462cbf86f
get rid of warnings about duplicate simp rules in all HOLCF theories
huffman
parents:
35174
diff
changeset
|
60 |
declare ioa_triple_proj [simp] starts_of_par [simp] |
19738 | 61 |
|
62 |
lemmas env_ioas = env_ioa_def env_asig_def env_trans_def |
|
35215
a03462cbf86f
get rid of warnings about duplicate simp rules in all HOLCF theories
huffman
parents:
35174
diff
changeset
|
63 |
lemmas hom_ioas = |
a03462cbf86f
get rid of warnings about duplicate simp rules in all HOLCF theories
huffman
parents:
35174
diff
changeset
|
64 |
env_ioas [simp] impl_ioas [simp] impl_trans [simp] impl_asigs [simp] |
a03462cbf86f
get rid of warnings about duplicate simp rules in all HOLCF theories
huffman
parents:
35174
diff
changeset
|
65 |
asig_projections set_lemmas |
19738 | 66 |
|
67 |
||
68 |
subsection {* lemmas about reduce *} |
|
69 |
||
70 |
lemma l_iff_red_nil: "(reduce l = []) = (l = [])" |
|
71 |
by (induct l) (auto split: list.split) |
|
72 |
||
73 |
lemma hd_is_reduce_hd: "s ~= [] --> hd s = hd (reduce s)" |
|
74 |
by (induct s) (auto split: list.split) |
|
75 |
||
76 |
text {* to be used in the following Lemma *} |
|
77 |
lemma rev_red_not_nil [rule_format]: |
|
78 |
"l ~= [] --> reverse (reduce l) ~= []" |
|
79 |
by (induct l) (auto split: list.split) |
|
80 |
||
81 |
text {* shows applicability of the induction hypothesis of the following Lemma 1 *} |
|
82 |
lemma last_ind_on_first: |
|
83 |
"l ~= [] ==> hd (reverse (reduce (a # l))) = hd (reverse (reduce l))" |
|
84 |
apply simp |
|
26342 | 85 |
apply (tactic {* auto_tac (@{claset}, |
26649 | 86 |
HOL_ss addsplits [@{thm list.split}] |
87 |
addsimps (@{thms reverse.simps} @ [@{thm hd_append}, @{thm rev_red_not_nil}])) *}) |
|
19738 | 88 |
done |
89 |
||
90 |
text {* Main Lemma 1 for @{text "S_pkt"} in showing that reduce is refinement. *} |
|
91 |
lemma reduce_hd: |
|
92 |
"if x=hd(reverse(reduce(l))) & reduce(l)~=[] then |
|
93 |
reduce(l@[x])=reduce(l) else |
|
94 |
reduce(l@[x])=reduce(l)@[x]" |
|
95 |
apply (simplesubst split_if) |
|
96 |
apply (rule conjI) |
|
97 |
txt {* @{text "-->"} *} |
|
98 |
apply (induct_tac "l") |
|
99 |
apply (simp (no_asm)) |
|
100 |
apply (case_tac "list=[]") |
|
35215
a03462cbf86f
get rid of warnings about duplicate simp rules in all HOLCF theories
huffman
parents:
35174
diff
changeset
|
101 |
apply simp |
19738 | 102 |
apply (rule impI) |
103 |
apply (simp (no_asm)) |
|
104 |
apply (cut_tac l = "list" in cons_not_nil) |
|
105 |
apply (simp del: reduce_Cons) |
|
106 |
apply (erule exE)+ |
|
107 |
apply hypsubst |
|
108 |
apply (simp del: reduce_Cons add: last_ind_on_first l_iff_red_nil) |
|
109 |
txt {* @{text "<--"} *} |
|
110 |
apply (simp (no_asm) add: and_de_morgan_and_absorbe l_iff_red_nil) |
|
111 |
apply (induct_tac "l") |
|
112 |
apply (simp (no_asm)) |
|
113 |
apply (case_tac "list=[]") |
|
114 |
apply (cut_tac [2] l = "list" in cons_not_nil) |
|
115 |
apply simp |
|
116 |
apply (auto simp del: reduce_Cons simp add: last_ind_on_first l_iff_red_nil split: split_if) |
|
117 |
apply simp |
|
118 |
done |
|
119 |
||
120 |
||
121 |
text {* Main Lemma 2 for R_pkt in showing that reduce is refinement. *} |
|
122 |
lemma reduce_tl: "s~=[] ==> |
|
123 |
if hd(s)=hd(tl(s)) & tl(s)~=[] then |
|
124 |
reduce(tl(s))=reduce(s) else |
|
125 |
reduce(tl(s))=tl(reduce(s))" |
|
126 |
apply (cut_tac l = "s" in cons_not_nil) |
|
127 |
apply simp |
|
128 |
apply (erule exE)+ |
|
129 |
apply (auto split: list.split) |
|
130 |
done |
|
131 |
||
132 |
||
133 |
subsection {* Channel Abstraction *} |
|
134 |
||
135 |
declare split_if [split del] |
|
136 |
||
137 |
lemma channel_abstraction: "is_weak_ref_map reduce ch_ioa ch_fin_ioa" |
|
138 |
apply (simp (no_asm) add: is_weak_ref_map_def) |
|
139 |
txt {* main-part *} |
|
140 |
apply (rule allI)+ |
|
141 |
apply (rule imp_conj_lemma) |
|
142 |
apply (induct_tac "a") |
|
143 |
txt {* 2 cases *} |
|
144 |
apply (simp_all (no_asm) cong del: if_weak_cong add: externals_def) |
|
145 |
txt {* fst case *} |
|
146 |
apply (rule impI) |
|
147 |
apply (rule disjI2) |
|
148 |
apply (rule reduce_hd) |
|
149 |
txt {* snd case *} |
|
150 |
apply (rule impI) |
|
151 |
apply (erule conjE)+ |
|
152 |
apply (erule disjE) |
|
153 |
apply (simp add: l_iff_red_nil) |
|
154 |
apply (erule hd_is_reduce_hd [THEN mp]) |
|
155 |
apply (simp add: l_iff_red_nil) |
|
156 |
apply (rule conjI) |
|
157 |
apply (erule hd_is_reduce_hd [THEN mp]) |
|
158 |
apply (rule bool_if_impl_or [THEN mp]) |
|
159 |
apply (erule reduce_tl) |
|
160 |
done |
|
161 |
||
162 |
declare split_if [split] |
|
163 |
||
164 |
lemma sender_abstraction: "is_weak_ref_map reduce srch_ioa srch_fin_ioa" |
|
165 |
apply (tactic {* |
|
166 |
simp_tac (HOL_ss addsimps [thm "srch_fin_ioa_def", thm "rsch_fin_ioa_def", |
|
167 |
thm "srch_ioa_def", thm "rsch_ioa_def", thm "rename_through_pmap", |
|
168 |
thm "channel_abstraction"]) 1 *}) |
|
169 |
done |
|
170 |
||
171 |
lemma receiver_abstraction: "is_weak_ref_map reduce rsch_ioa rsch_fin_ioa" |
|
172 |
apply (tactic {* |
|
173 |
simp_tac (HOL_ss addsimps [thm "srch_fin_ioa_def", thm "rsch_fin_ioa_def", |
|
174 |
thm "srch_ioa_def", thm "rsch_ioa_def", thm "rename_through_pmap", |
|
175 |
thm "channel_abstraction"]) 1 *}) |
|
176 |
done |
|
177 |
||
178 |
||
179 |
text {* 3 thms that do not hold generally! The lucky restriction here is |
|
180 |
the absence of internal actions. *} |
|
181 |
lemma sender_unchanged: "is_weak_ref_map (%id. id) sender_ioa sender_ioa" |
|
182 |
apply (simp (no_asm) add: is_weak_ref_map_def) |
|
183 |
txt {* main-part *} |
|
184 |
apply (rule allI)+ |
|
185 |
apply (induct_tac a) |
|
186 |
txt {* 7 cases *} |
|
187 |
apply (simp_all (no_asm) add: externals_def) |
|
188 |
done |
|
189 |
||
190 |
text {* 2 copies of before *} |
|
191 |
lemma receiver_unchanged: "is_weak_ref_map (%id. id) receiver_ioa receiver_ioa" |
|
192 |
apply (simp (no_asm) add: is_weak_ref_map_def) |
|
193 |
txt {* main-part *} |
|
194 |
apply (rule allI)+ |
|
195 |
apply (induct_tac a) |
|
196 |
txt {* 7 cases *} |
|
197 |
apply (simp_all (no_asm) add: externals_def) |
|
198 |
done |
|
199 |
||
200 |
lemma env_unchanged: "is_weak_ref_map (%id. id) env_ioa env_ioa" |
|
201 |
apply (simp (no_asm) add: is_weak_ref_map_def) |
|
202 |
txt {* main-part *} |
|
203 |
apply (rule allI)+ |
|
204 |
apply (induct_tac a) |
|
205 |
txt {* 7 cases *} |
|
206 |
apply (simp_all (no_asm) add: externals_def) |
|
207 |
done |
|
208 |
||
209 |
||
210 |
lemma compat_single_ch: "compatible srch_ioa rsch_ioa" |
|
211 |
apply (simp add: compatible_def Int_def) |
|
212 |
apply (rule set_ext) |
|
213 |
apply (induct_tac x) |
|
214 |
apply simp_all |
|
215 |
done |
|
216 |
||
217 |
text {* totally the same as before *} |
|
218 |
lemma compat_single_fin_ch: "compatible srch_fin_ioa rsch_fin_ioa" |
|
219 |
apply (simp add: compatible_def Int_def) |
|
220 |
apply (rule set_ext) |
|
221 |
apply (induct_tac x) |
|
222 |
apply simp_all |
|
223 |
done |
|
224 |
||
225 |
lemmas del_simps = trans_of_def srch_asig_def rsch_asig_def |
|
226 |
asig_of_def actions_def srch_trans_def rsch_trans_def srch_ioa_def |
|
227 |
srch_fin_ioa_def rsch_fin_ioa_def rsch_ioa_def sender_trans_def |
|
228 |
receiver_trans_def set_lemmas |
|
229 |
||
230 |
lemma compat_rec: "compatible receiver_ioa (srch_ioa || rsch_ioa)" |
|
231 |
apply (simp del: del_simps |
|
232 |
add: compatible_def asig_of_par asig_comp_def actions_def Int_def) |
|
233 |
apply simp |
|
234 |
apply (rule set_ext) |
|
235 |
apply (induct_tac x) |
|
236 |
apply simp_all |
|
237 |
done |
|
238 |
||
239 |
text {* 5 proofs totally the same as before *} |
|
240 |
lemma compat_rec_fin: "compatible receiver_ioa (srch_fin_ioa || rsch_fin_ioa)" |
|
241 |
apply (simp del: del_simps |
|
242 |
add: compatible_def asig_of_par asig_comp_def actions_def Int_def) |
|
243 |
apply simp |
|
244 |
apply (rule set_ext) |
|
245 |
apply (induct_tac x) |
|
246 |
apply simp_all |
|
247 |
done |
|
248 |
||
249 |
lemma compat_sen: "compatible sender_ioa |
|
250 |
(receiver_ioa || srch_ioa || rsch_ioa)" |
|
251 |
apply (simp del: del_simps |
|
252 |
add: compatible_def asig_of_par asig_comp_def actions_def Int_def) |
|
253 |
apply simp |
|
254 |
apply (rule set_ext) |
|
255 |
apply (induct_tac x) |
|
256 |
apply simp_all |
|
257 |
done |
|
258 |
||
259 |
lemma compat_sen_fin: "compatible sender_ioa |
|
260 |
(receiver_ioa || srch_fin_ioa || rsch_fin_ioa)" |
|
261 |
apply (simp del: del_simps |
|
262 |
add: compatible_def asig_of_par asig_comp_def actions_def Int_def) |
|
263 |
apply simp |
|
264 |
apply (rule set_ext) |
|
265 |
apply (induct_tac x) |
|
266 |
apply simp_all |
|
267 |
done |
|
268 |
||
269 |
lemma compat_env: "compatible env_ioa |
|
270 |
(sender_ioa || receiver_ioa || srch_ioa || rsch_ioa)" |
|
271 |
apply (simp del: del_simps |
|
272 |
add: compatible_def asig_of_par asig_comp_def actions_def Int_def) |
|
273 |
apply simp |
|
274 |
apply (rule set_ext) |
|
275 |
apply (induct_tac x) |
|
276 |
apply simp_all |
|
277 |
done |
|
278 |
||
279 |
lemma compat_env_fin: "compatible env_ioa |
|
280 |
(sender_ioa || receiver_ioa || srch_fin_ioa || rsch_fin_ioa)" |
|
281 |
apply (simp del: del_simps |
|
282 |
add: compatible_def asig_of_par asig_comp_def actions_def Int_def) |
|
283 |
apply simp |
|
284 |
apply (rule set_ext) |
|
285 |
apply (induct_tac x) |
|
286 |
apply simp_all |
|
287 |
done |
|
288 |
||
289 |
||
290 |
text {* lemmata about externals of channels *} |
|
291 |
lemma ext_single_ch: "externals(asig_of(srch_fin_ioa)) = externals(asig_of(srch_ioa)) & |
|
292 |
externals(asig_of(rsch_fin_ioa)) = externals(asig_of(rsch_ioa))" |
|
293 |
by (simp add: externals_def) |
|
294 |
||
295 |
||
296 |
subsection {* Soundness of Abstraction *} |
|
297 |
||
298 |
lemmas ext_simps = externals_of_par ext_single_ch |
|
299 |
and compat_simps = compat_single_ch compat_single_fin_ch compat_rec |
|
300 |
compat_rec_fin compat_sen compat_sen_fin compat_env compat_env_fin |
|
301 |
and abstractions = env_unchanged sender_unchanged |
|
302 |
receiver_unchanged sender_abstraction receiver_abstraction |
|
303 |
||
304 |
||
305 |
(* FIX: this proof should be done with compositionality on trace level, not on |
|
306 |
weak_ref_map level, as done here with fxg_is_weak_ref_map_of_product_IOA |
|
307 |
||
308 |
Goal "is_weak_ref_map abs system_ioa system_fin_ioa" |
|
309 |
||
310 |
by (simp_tac (impl_ss delsimps ([srch_ioa_def, rsch_ioa_def, srch_fin_ioa_def, |
|
311 |
rsch_fin_ioa_def] @ env_ioas @ impl_ioas) |
|
312 |
addsimps [system_def, system_fin_def, abs_def, |
|
313 |
impl_ioa_def, impl_fin_ioa_def, sys_IOA, |
|
314 |
sys_fin_IOA]) 1); |
|
315 |
||
316 |
by (REPEAT (EVERY[rtac fxg_is_weak_ref_map_of_product_IOA 1, |
|
317 |
simp_tac (ss addsimps abstractions) 1, |
|
318 |
rtac conjI 1])); |
|
319 |
||
320 |
by (ALLGOALS (simp_tac (ss addsimps ext_ss @ compat_ss))); |
|
321 |
||
322 |
qed "system_refinement"; |
|
323 |
*) |
|
17244 | 324 |
|
3072
a31419014be5
Old ABP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
325 |
end |