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