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