1051
|
1 |
(* Title: HOL/IOA/NTP/Impl.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow & Konrad Slind
|
|
4 |
Copyright 1994 TU Muenchen
|
|
5 |
|
|
6 |
The implementation --- Invariants
|
|
7 |
*)
|
|
8 |
|
|
9 |
open Abschannel;
|
|
10 |
|
|
11 |
val impl_ioas =
|
|
12 |
[Impl.impl_def,
|
|
13 |
Sender.sender_ioa_def,
|
|
14 |
Receiver.receiver_ioa_def,
|
|
15 |
srch_ioa_thm RS eq_reflection,
|
|
16 |
rsch_ioa_thm RS eq_reflection];
|
|
17 |
|
|
18 |
val transitions = [Sender.sender_trans_def, Receiver.receiver_trans_def,
|
|
19 |
Abschannel.srch_trans_def, Abschannel.rsch_trans_def];
|
|
20 |
|
|
21 |
|
|
22 |
val impl_ss = merge_ss(action_ss,list_ss)
|
|
23 |
addcongs [let_weak_cong]
|
|
24 |
addsimps [Let_def, ioa_triple_proj, starts_of_par, trans_of_par4,
|
|
25 |
in_sender_asig, in_receiver_asig, in_srch_asig,
|
|
26 |
in_rsch_asig, count_addm_simp, count_delm_simp,
|
|
27 |
Multiset.countm_empty_def, Multiset.delm_empty_def,
|
|
28 |
(* Multiset.count_def, *) count_empty,
|
|
29 |
Packet.hdr_def, Packet.msg_def];
|
|
30 |
|
|
31 |
goal Impl.thy
|
|
32 |
"fst(x) = sen(x) & \
|
|
33 |
\ fst(snd(x)) = rec(x) & \
|
|
34 |
\ fst(snd(snd(x))) = srch(x) & \
|
|
35 |
\ snd(snd(snd(x))) = rsch(x)";
|
|
36 |
by(simp_tac (HOL_ss addsimps
|
|
37 |
[Impl.sen_def,Impl.rec_def,Impl.srch_def,Impl.rsch_def]) 1);
|
|
38 |
val impl_ss = impl_ss addsimps [result()];
|
|
39 |
|
|
40 |
goal Impl.thy "a:actions(sender_asig) \
|
|
41 |
\ | a:actions(receiver_asig) \
|
|
42 |
\ | a:actions(srch_asig) \
|
|
43 |
\ | a:actions(rsch_asig)";
|
|
44 |
by(Action.action.induct_tac "a" 1);
|
|
45 |
by(ALLGOALS(simp_tac impl_ss));
|
|
46 |
val impl_ss = impl_ss addsimps [result()];
|
|
47 |
|
|
48 |
|
|
49 |
(* INVARIANT 1 *)
|
|
50 |
val ss = impl_ss addcongs [if_weak_cong] addsimps transitions;
|
|
51 |
val abs_ss= merge_ss(ss,abschannel_ss);
|
|
52 |
|
|
53 |
goalw Impl.thy impl_ioas "invariant impl_ioa inv1";
|
|
54 |
br invariantI 1;
|
|
55 |
by(asm_full_simp_tac (impl_ss addsimps
|
|
56 |
[Impl.inv1_def, Impl.hdr_sum_def,
|
|
57 |
Sender.srcvd_def, Sender.ssent_def,
|
|
58 |
Receiver.rsent_def,Receiver.rrcvd_def]) 1);
|
|
59 |
|
|
60 |
by(simp_tac (HOL_ss addsimps [fork_lemma,Impl.inv1_def]) 1);
|
|
61 |
|
|
62 |
(* Split proof in two *)
|
|
63 |
by (rtac conjI 1);
|
|
64 |
|
|
65 |
(* First half *)
|
|
66 |
by(asm_full_simp_tac (impl_ss addsimps [Impl.inv1_def]) 1);
|
|
67 |
br Action.action.induct 1;
|
|
68 |
|
|
69 |
val tac = asm_simp_tac (ss addcongs [conj_cong]
|
|
70 |
addsimps [Suc_pred_lemma]
|
|
71 |
setloop (split_tac [expand_if]));
|
|
72 |
val tac_abs = asm_simp_tac (abs_ss addcongs [conj_cong]
|
|
73 |
addsimps [Suc_pred_lemma]
|
|
74 |
setloop (split_tac [expand_if]));
|
|
75 |
by (EVERY1[tac, tac, tac, tac]);
|
|
76 |
by (tac 1);
|
|
77 |
by (tac_abs 1);
|
|
78 |
|
|
79 |
(* 5 + 1 *)
|
|
80 |
|
|
81 |
by (tac 1);
|
|
82 |
by (tac_abs 1);
|
|
83 |
|
|
84 |
(* 4 + 1 *)
|
|
85 |
by(EVERY1[tac, tac, tac, tac]);
|
|
86 |
|
|
87 |
|
|
88 |
(* Now the other half *)
|
|
89 |
by(asm_full_simp_tac (impl_ss addsimps [Impl.inv1_def]) 1);
|
|
90 |
br Action.action.induct 1;
|
|
91 |
by(EVERY1[tac, tac]);
|
|
92 |
|
|
93 |
(* detour 1 *)
|
|
94 |
by (tac 1);
|
|
95 |
by (tac_abs 1);
|
|
96 |
by (rtac impI 1);
|
|
97 |
by (REPEAT (etac conjE 1));
|
|
98 |
by (asm_simp_tac (impl_ss addsimps [Impl.hdr_sum_def, Multiset.count_def,
|
|
99 |
Multiset.countm_nonempty_def]
|
|
100 |
setloop (split_tac [expand_if])) 1);
|
|
101 |
(* detour 2 *)
|
|
102 |
by (tac 1);
|
|
103 |
by (tac_abs 1);
|
|
104 |
by (rtac impI 1);
|
|
105 |
by (REPEAT (etac conjE 1));
|
|
106 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
107 |
[Impl.hdr_sum_def,
|
|
108 |
Multiset.count_def,
|
|
109 |
Multiset.countm_nonempty_def,
|
|
110 |
Multiset.delm_nonempty_def,
|
|
111 |
left_plus_cancel,left_plus_cancel_inside_succ,
|
|
112 |
unzero_less]
|
|
113 |
setloop (split_tac [expand_if])) 1);
|
|
114 |
by (rtac allI 1);
|
|
115 |
by (rtac conjI 1);
|
|
116 |
by (rtac impI 1);
|
|
117 |
by (hyp_subst_tac 1);
|
|
118 |
|
|
119 |
by (rtac (pred_suc RS mp RS sym RS iffD2) 1);
|
|
120 |
by (dtac less_le_trans 1);
|
|
121 |
by (cut_facts_tac [rewrite_rule[Packet.hdr_def]
|
|
122 |
eq_packet_imp_eq_hdr RS countm_props] 1);;
|
|
123 |
by (assume_tac 1);
|
|
124 |
by (assume_tac 1);
|
|
125 |
|
|
126 |
by (rtac (countm_done_delm RS mp RS sym) 1);
|
|
127 |
by (rtac refl 1);
|
|
128 |
by (asm_simp_tac (HOL_ss addsimps [Multiset.count_def]) 1);
|
|
129 |
|
|
130 |
by (rtac impI 1);
|
|
131 |
by (asm_full_simp_tac (HOL_ss addsimps [neg_flip]) 1);
|
|
132 |
by (hyp_subst_tac 1);
|
|
133 |
by (rtac countm_spurious_delm 1);
|
|
134 |
by (simp_tac HOL_ss 1);
|
|
135 |
|
|
136 |
by (EVERY1[tac, tac, tac, tac, tac, tac]);
|
|
137 |
|
|
138 |
qed "inv1";
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
(* INVARIANT 2 *)
|
|
143 |
|
|
144 |
goal Impl.thy "invariant impl_ioa inv2";
|
|
145 |
|
|
146 |
by (rtac invariantI1 1);
|
|
147 |
(* Base case *)
|
|
148 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
149 |
(Impl.inv2_def :: (receiver_projections
|
|
150 |
@ sender_projections @ impl_ioas))) 1);
|
|
151 |
|
|
152 |
by (asm_simp_tac (impl_ss addsimps impl_ioas) 1);
|
|
153 |
by (Action.action.induct_tac "a" 1);
|
|
154 |
|
|
155 |
(* 10 cases. First 4 are simple, since state doesn't change wrt. invariant *)
|
|
156 |
(* 10 *)
|
|
157 |
by (asm_simp_tac (impl_ss addsimps (Impl.inv2_def::transitions)) 1);
|
|
158 |
(* 9 *)
|
|
159 |
by (asm_simp_tac (impl_ss addsimps (Impl.inv2_def::transitions)) 1);
|
|
160 |
(* 8 *)
|
|
161 |
by (asm_simp_tac (impl_ss addsimps (Impl.inv2_def::transitions)) 2);
|
|
162 |
(* 7 *)
|
|
163 |
by (asm_simp_tac (impl_ss addsimps (Impl.inv2_def::transitions)) 3);
|
|
164 |
(* 6 *)
|
|
165 |
by(forward_tac [rewrite_rule [Impl.inv1_def]
|
|
166 |
(inv1 RS invariantE) RS conjunct1] 1);
|
|
167 |
by (asm_full_simp_tac (impl_ss addsimps [leq_imp_leq_suc,Impl.inv2_def]
|
|
168 |
addsimps transitions) 1);
|
|
169 |
(* 5 *)
|
|
170 |
by (asm_full_simp_tac (impl_ss addsimps [leq_imp_leq_suc,Impl.inv2_def]
|
|
171 |
addsimps transitions) 1);
|
|
172 |
(* 4 *)
|
|
173 |
by (forward_tac [rewrite_rule [Impl.inv1_def]
|
|
174 |
(inv1 RS invariantE) RS conjunct1] 1);
|
|
175 |
by (asm_full_simp_tac (impl_ss addsimps [Impl.inv2_def]
|
|
176 |
addsimps transitions) 1);
|
|
177 |
by (fast_tac (HOL_cs addDs [add_leD1,leD]) 1);
|
|
178 |
|
|
179 |
(* 3 *)
|
|
180 |
by (forward_tac [rewrite_rule [Impl.inv1_def] (inv1 RS invariantE)] 1);
|
|
181 |
|
|
182 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
183 |
(Impl.inv2_def::transitions)) 1);
|
|
184 |
by (fold_tac [rewrite_rule [Packet.hdr_def]Impl.hdr_sum_def]);
|
|
185 |
by (fast_tac (HOL_cs addDs [add_leD1,leD]) 1);
|
|
186 |
|
|
187 |
(* 2 *)
|
|
188 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
189 |
(Impl.inv2_def::transitions)) 1);
|
|
190 |
by(forward_tac [rewrite_rule [Impl.inv1_def]
|
|
191 |
(inv1 RS invariantE) RS conjunct1] 1);
|
|
192 |
by (rtac impI 1);
|
|
193 |
by (rtac impI 1);
|
|
194 |
by (REPEAT (etac conjE 1));
|
|
195 |
by (dres_inst_tac [("k","count (rsch s) (~sbit(sen s))")]
|
|
196 |
(standard(leq_add_leq RS mp)) 1);
|
|
197 |
by (asm_full_simp_tac HOL_ss 1);
|
|
198 |
|
|
199 |
(* 1 *)
|
|
200 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
201 |
(Impl.inv2_def::transitions)) 1);
|
|
202 |
by(forward_tac [rewrite_rule [Impl.inv1_def]
|
|
203 |
(inv1 RS invariantE) RS conjunct2] 1);
|
|
204 |
by (rtac impI 1);
|
|
205 |
by (rtac impI 1);
|
|
206 |
by (REPEAT (etac conjE 1));
|
|
207 |
by (fold_tac [rewrite_rule[Packet.hdr_def]Impl.hdr_sum_def]);
|
|
208 |
by (dres_inst_tac [("k","hdr_sum (srch s) (sbit(sen s))")]
|
|
209 |
(standard(leq_add_leq RS mp)) 1);
|
|
210 |
by (asm_full_simp_tac HOL_ss 1);
|
|
211 |
qed "inv2";
|
|
212 |
|
|
213 |
|
|
214 |
(* INVARIANT 3 *)
|
|
215 |
goal Impl.thy "invariant impl_ioa inv3";
|
|
216 |
|
|
217 |
by (rtac invariantI 1);
|
|
218 |
(* Base case *)
|
|
219 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
220 |
(Impl.inv3_def :: (receiver_projections
|
|
221 |
@ sender_projections @ impl_ioas))) 1);
|
|
222 |
|
|
223 |
by (asm_simp_tac (impl_ss addsimps impl_ioas) 1);
|
|
224 |
by (Action.action.induct_tac "a" 1);
|
|
225 |
|
|
226 |
(* 10 *)
|
|
227 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
228 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
229 |
setloop (split_tac [expand_if])) 1);
|
|
230 |
|
|
231 |
(* 9 *)
|
|
232 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
233 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
234 |
setloop (split_tac [expand_if])) 1);
|
|
235 |
|
|
236 |
(* 8 *)
|
|
237 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
238 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
239 |
setloop (split_tac [expand_if])) 1);
|
|
240 |
by (tac_abs 1);
|
|
241 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
242 |
by (asm_full_simp_tac (HOL_ss addsimps [cons_imp_not_null]) 1);
|
|
243 |
|
|
244 |
|
|
245 |
by (hyp_subst_tac 1);
|
|
246 |
by (etac exE 1);
|
|
247 |
by (asm_full_simp_tac list_ss 1);
|
|
248 |
|
|
249 |
(* 7 *)
|
|
250 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
251 |
(Suc_pred_lemma::append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
252 |
setloop (split_tac [expand_if])) 1);
|
|
253 |
by (tac_abs 1);
|
|
254 |
by (fast_tac HOL_cs 1);
|
|
255 |
|
|
256 |
(* 6 *)
|
|
257 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
258 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
259 |
setloop (split_tac [expand_if])) 1);
|
|
260 |
(* 5 *)
|
|
261 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
262 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
263 |
setloop (split_tac [expand_if])) 1);
|
|
264 |
|
|
265 |
(* 4 *)
|
|
266 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
267 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
268 |
setloop (split_tac [expand_if])) 1);
|
|
269 |
|
|
270 |
(* 3 *)
|
|
271 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
272 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
273 |
setloop (split_tac [expand_if])) 1);
|
|
274 |
|
|
275 |
(* 2 *)
|
|
276 |
by (asm_full_simp_tac (impl_ss addsimps transitions) 1);
|
|
277 |
by (simp_tac (HOL_ss addsimps [Impl.inv3_def]) 1);
|
|
278 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
279 |
by (rtac (imp_or_lem RS iffD2) 1);
|
|
280 |
by (rtac impI 1);
|
|
281 |
by (forward_tac [rewrite_rule [Impl.inv2_def] (inv2 RS invariantE)] 1);
|
|
282 |
by (asm_full_simp_tac list_ss 1);
|
|
283 |
by (REPEAT (etac conjE 1));
|
|
284 |
by (res_inst_tac [("j","count (ssent(sen s)) (~sbit(sen s))"),
|
|
285 |
("k","count (rsent(rec s)) (sbit(sen s))")] le_trans 1);
|
|
286 |
by (forward_tac [rewrite_rule [Impl.inv1_def]
|
|
287 |
(inv1 RS invariantE) RS conjunct2] 1);
|
|
288 |
by (asm_full_simp_tac (list_ss addsimps
|
|
289 |
[Impl.hdr_sum_def, Multiset.count_def]) 1);
|
|
290 |
by (rtac (less_eq_add_cong RS mp RS mp) 1);
|
|
291 |
by (rtac countm_props 1);
|
|
292 |
by (simp_tac (list_ss addsimps [Packet.hdr_def]) 1);
|
|
293 |
by (rtac countm_props 1);
|
|
294 |
by (simp_tac (list_ss addsimps [Packet.hdr_def]) 1);
|
|
295 |
by (assume_tac 1);
|
|
296 |
|
|
297 |
|
|
298 |
(* 1 *)
|
|
299 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
300 |
(append_cons::not_hd_append::Impl.inv3_def::transitions)
|
|
301 |
setloop (split_tac [expand_if])) 1);
|
|
302 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
303 |
by (rtac (imp_or_lem RS iffD2) 1);
|
|
304 |
by (rtac impI 1);
|
|
305 |
by (forward_tac [rewrite_rule [Impl.inv2_def] (inv2 RS invariantE)] 1);
|
|
306 |
by (asm_full_simp_tac list_ss 1);
|
|
307 |
by (REPEAT (etac conjE 1));
|
|
308 |
by (dtac mp 1);
|
|
309 |
by (assume_tac 1);
|
|
310 |
by (etac allE 1);
|
|
311 |
by (dtac (imp_or_lem RS iffD1) 1);
|
|
312 |
by (dtac mp 1);
|
|
313 |
by (assume_tac 1);
|
|
314 |
by (assume_tac 1);
|
|
315 |
qed "inv3";
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
(* INVARIANT 4 *)
|
|
320 |
|
|
321 |
goal Impl.thy "invariant impl_ioa inv4";
|
|
322 |
|
|
323 |
by (rtac invariantI 1);
|
|
324 |
(* Base case *)
|
|
325 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
326 |
(Impl.inv4_def :: (receiver_projections
|
|
327 |
@ sender_projections @ impl_ioas))) 1);
|
|
328 |
|
|
329 |
by (asm_simp_tac (impl_ss addsimps impl_ioas) 1);
|
|
330 |
by (Action.action.induct_tac "a" 1);
|
|
331 |
|
|
332 |
(* 10 *)
|
|
333 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
334 |
(append_cons::Impl.inv4_def::transitions)
|
|
335 |
setloop (split_tac [expand_if])) 1);
|
|
336 |
|
|
337 |
(* 9 *)
|
|
338 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
339 |
(append_cons::Impl.inv4_def::transitions)
|
|
340 |
setloop (split_tac [expand_if])) 1);
|
|
341 |
|
|
342 |
(* 8 *)
|
|
343 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
344 |
(append_cons::Impl.inv4_def::transitions)
|
|
345 |
setloop (split_tac [expand_if])) 1);
|
|
346 |
(* 7 *)
|
|
347 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
348 |
(append_cons::Impl.inv4_def::transitions)
|
|
349 |
setloop (split_tac [expand_if])) 1);
|
|
350 |
|
|
351 |
(* 6 *)
|
|
352 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
353 |
(append_cons::Impl.inv4_def::transitions)
|
|
354 |
setloop (split_tac [expand_if])) 1);
|
|
355 |
|
|
356 |
(* 5 *)
|
|
357 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
358 |
(append_cons::Impl.inv4_def::transitions)
|
|
359 |
setloop (split_tac [expand_if])) 1);
|
|
360 |
|
|
361 |
(* 4 *)
|
|
362 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
363 |
(append_cons::Impl.inv4_def::transitions)
|
|
364 |
setloop (split_tac [expand_if])) 1);
|
|
365 |
|
|
366 |
(* 3 *)
|
|
367 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
368 |
(append_cons::Impl.inv4_def::transitions)
|
|
369 |
setloop (split_tac [expand_if])) 1);
|
|
370 |
|
|
371 |
(* 2 *)
|
|
372 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
373 |
(append_cons::Impl.inv4_def::transitions)
|
|
374 |
setloop (split_tac [expand_if])) 1);
|
|
375 |
|
|
376 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
377 |
by(forward_tac [rewrite_rule [Impl.inv2_def]
|
|
378 |
(inv2 RS invariantE)] 1);
|
|
379 |
|
|
380 |
by (asm_full_simp_tac list_ss 1);
|
|
381 |
|
|
382 |
(* 1 *)
|
|
383 |
by (asm_full_simp_tac (impl_ss addsimps
|
|
384 |
(append_cons::Impl.inv4_def::transitions)
|
|
385 |
setloop (split_tac [expand_if])) 1);
|
|
386 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
387 |
by (rtac ccontr 1);
|
|
388 |
by(forward_tac [rewrite_rule [Impl.inv2_def]
|
|
389 |
(inv2 RS invariantE)] 1);
|
|
390 |
by(forward_tac [rewrite_rule [Impl.inv3_def]
|
|
391 |
(inv3 RS invariantE)] 1);
|
|
392 |
by (asm_full_simp_tac list_ss 1);
|
|
393 |
by (eres_inst_tac [("x","m")] allE 1);
|
|
394 |
by (dtac less_le_trans 1);
|
|
395 |
by (dtac (left_add_leq RS mp) 1);
|
|
396 |
by (asm_full_simp_tac list_ss 1);
|
|
397 |
by (asm_full_simp_tac arith_ss 1);
|
|
398 |
qed "inv4";
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
(* rebind them *)
|
|
403 |
|
|
404 |
val inv1 = rewrite_rule [Impl.inv1_def] (inv1 RS invariantE);
|
|
405 |
val inv2 = rewrite_rule [Impl.inv2_def] (inv2 RS invariantE);
|
|
406 |
val inv3 = rewrite_rule [Impl.inv3_def] (inv3 RS invariantE);
|
|
407 |
val inv4 = rewrite_rule [Impl.inv4_def] (inv4 RS invariantE);
|
|
408 |
|