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 |
|
1328
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
open Abschannel Impl;
|
1051
|
13 |
|
|
14 |
val impl_ioas =
|
|
15 |
[Impl.impl_def,
|
|
16 |
Sender.sender_ioa_def,
|
|
17 |
Receiver.receiver_ioa_def,
|
|
18 |
srch_ioa_thm RS eq_reflection,
|
|
19 |
rsch_ioa_thm RS eq_reflection];
|
|
20 |
|
|
21 |
val transitions = [Sender.sender_trans_def, Receiver.receiver_trans_def,
|
1328
|
22 |
srch_trans_def, rsch_trans_def];
|
1051
|
23 |
|
|
24 |
|
1266
|
25 |
Addsimps [ioa_triple_proj, starts_of_par, trans_of_par4,
|
|
26 |
in_sender_asig, in_receiver_asig, in_srch_asig,
|
1328
|
27 |
in_rsch_asig];
|
|
28 |
Addcongs [let_weak_cong];
|
1051
|
29 |
|
|
30 |
goal Impl.thy
|
|
31 |
"fst(x) = sen(x) & \
|
|
32 |
\ fst(snd(x)) = rec(x) & \
|
|
33 |
\ fst(snd(snd(x))) = srch(x) & \
|
|
34 |
\ snd(snd(snd(x))) = rsch(x)";
|
1266
|
35 |
by(simp_tac (!simpset addsimps
|
1328
|
36 |
[sen_def,rec_def,srch_def,rsch_def]) 1);
|
1266
|
37 |
Addsimps [result()];
|
1051
|
38 |
|
|
39 |
goal Impl.thy "a:actions(sender_asig) \
|
|
40 |
\ | a:actions(receiver_asig) \
|
|
41 |
\ | a:actions(srch_asig) \
|
|
42 |
\ | a:actions(rsch_asig)";
|
|
43 |
by(Action.action.induct_tac "a" 1);
|
1328
|
44 |
by(ALLGOALS (Simp_tac));
|
1266
|
45 |
Addsimps [result()];
|
1051
|
46 |
|
1328
|
47 |
Delsimps [split_paired_All];
|
|
48 |
|
|
49 |
|
|
50 |
(* Three Simp_sets in different sizes
|
|
51 |
----------------------------------------------
|
|
52 |
|
|
53 |
1) !simpset does not unfold the transition relations
|
|
54 |
2) ss unfolds transition relations
|
|
55 |
3) renname_ss unfolds transitions and the abstract channel *)
|
|
56 |
|
|
57 |
|
|
58 |
val ss = (!simpset addcongs [if_weak_cong]
|
|
59 |
addsimps transitions);
|
|
60 |
val rename_ss = (ss addsimps unfold_renaming);
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
val tac = asm_simp_tac ((ss addcongs [conj_cong])
|
|
65 |
setloop (split_tac [expand_if]));
|
|
66 |
val tac_ren = asm_simp_tac ((rename_ss addcongs [conj_cong])
|
|
67 |
setloop (split_tac [expand_if]));
|
|
68 |
|
|
69 |
|
1051
|
70 |
|
|
71 |
(* INVARIANT 1 *)
|
|
72 |
|
|
73 |
goalw Impl.thy impl_ioas "invariant impl_ioa inv1";
|
1465
|
74 |
by (rtac invariantI 1);
|
1328
|
75 |
by(asm_full_simp_tac (!simpset
|
|
76 |
addsimps [inv1_def, hdr_sum_def, Sender.srcvd_def,
|
1266
|
77 |
Sender.ssent_def, Receiver.rsent_def,Receiver.rrcvd_def]) 1);
|
1051
|
78 |
|
1328
|
79 |
by(simp_tac (!simpset delsimps [trans_of_par4]
|
|
80 |
addsimps [fork_lemma,inv1_def]) 1);
|
1051
|
81 |
|
|
82 |
(* Split proof in two *)
|
1328
|
83 |
by (rtac conjI 1);
|
1051
|
84 |
|
|
85 |
(* First half *)
|
1328
|
86 |
by(asm_full_simp_tac (!simpset addsimps [Impl.inv1_def]) 1);
|
1465
|
87 |
by (rtac Action.action.induct 1);
|
1051
|
88 |
|
|
89 |
by (EVERY1[tac, tac, tac, tac]);
|
|
90 |
by (tac 1);
|
1328
|
91 |
by (tac_ren 1);
|
1051
|
92 |
|
|
93 |
(* 5 + 1 *)
|
1266
|
94 |
|
1051
|
95 |
by (tac 1);
|
1328
|
96 |
by (tac_ren 1);
|
1266
|
97 |
|
1051
|
98 |
(* 4 + 1 *)
|
|
99 |
by(EVERY1[tac, tac, tac, tac]);
|
|
100 |
|
|
101 |
|
|
102 |
(* Now the other half *)
|
1328
|
103 |
by(asm_full_simp_tac (!simpset addsimps [Impl.inv1_def]) 1);
|
1465
|
104 |
by (rtac Action.action.induct 1);
|
1051
|
105 |
by(EVERY1[tac, tac]);
|
|
106 |
|
|
107 |
(* detour 1 *)
|
|
108 |
by (tac 1);
|
1328
|
109 |
by (tac_ren 1);
|
1051
|
110 |
by (rtac impI 1);
|
|
111 |
by (REPEAT (etac conjE 1));
|
1328
|
112 |
by (asm_simp_tac (!simpset addsimps [hdr_sum_def, Multiset.count_def,
|
|
113 |
Multiset.countm_nonempty_def]
|
|
114 |
setloop (split_tac [expand_if])) 1);
|
1051
|
115 |
(* detour 2 *)
|
|
116 |
by (tac 1);
|
1328
|
117 |
by (tac_ren 1);
|
1051
|
118 |
by (rtac impI 1);
|
|
119 |
by (REPEAT (etac conjE 1));
|
1328
|
120 |
by (asm_full_simp_tac (!simpset addsimps [Impl.hdr_sum_def,
|
1266
|
121 |
Multiset.count_def,
|
|
122 |
Multiset.countm_nonempty_def,
|
|
123 |
Multiset.delm_nonempty_def,
|
|
124 |
left_plus_cancel,
|
|
125 |
left_plus_cancel_inside_succ,
|
|
126 |
unzero_less]
|
|
127 |
setloop (split_tac [expand_if])) 1);
|
1051
|
128 |
by (rtac allI 1);
|
|
129 |
by (rtac conjI 1);
|
|
130 |
by (rtac impI 1);
|
|
131 |
by (hyp_subst_tac 1);
|
|
132 |
by (rtac (pred_suc RS mp RS sym RS iffD2) 1);
|
|
133 |
by (dtac less_le_trans 1);
|
|
134 |
by (cut_facts_tac [rewrite_rule[Packet.hdr_def]
|
1465
|
135 |
eq_packet_imp_eq_hdr RS countm_props] 1);;
|
1051
|
136 |
by (assume_tac 1);
|
|
137 |
by (assume_tac 1);
|
|
138 |
|
|
139 |
by (rtac (countm_done_delm RS mp RS sym) 1);
|
|
140 |
by (rtac refl 1);
|
1328
|
141 |
by (asm_simp_tac (!simpset addsimps [Multiset.count_def]) 1);
|
1051
|
142 |
|
|
143 |
by (rtac impI 1);
|
1328
|
144 |
by (asm_full_simp_tac (!simpset addsimps [neg_flip]) 1);
|
1051
|
145 |
by (hyp_subst_tac 1);
|
|
146 |
by (rtac countm_spurious_delm 1);
|
1266
|
147 |
by (Simp_tac 1);
|
1051
|
148 |
|
|
149 |
by (EVERY1[tac, tac, tac, tac, tac, tac]);
|
|
150 |
|
|
151 |
qed "inv1";
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
(* INVARIANT 2 *)
|
|
156 |
|
|
157 |
goal Impl.thy "invariant impl_ioa inv2";
|
|
158 |
|
|
159 |
by (rtac invariantI1 1);
|
|
160 |
(* Base case *)
|
1328
|
161 |
by (asm_full_simp_tac (!simpset addsimps (inv2_def ::
|
|
162 |
(receiver_projections
|
|
163 |
@ sender_projections @ impl_ioas)))
|
1266
|
164 |
1);
|
1051
|
165 |
|
1328
|
166 |
by (asm_simp_tac (!simpset addsimps impl_ioas) 1);
|
1051
|
167 |
by (Action.action.induct_tac "a" 1);
|
|
168 |
|
1328
|
169 |
(* 10 cases. First 4 are simple, since state doesn't change *)
|
|
170 |
|
|
171 |
val tac2 = asm_full_simp_tac (ss addsimps [inv2_def]);
|
|
172 |
|
|
173 |
(* 10 - 7 *)
|
|
174 |
by (EVERY1[tac2,tac2,tac2,tac2]);
|
1051
|
175 |
(* 6 *)
|
|
176 |
by(forward_tac [rewrite_rule [Impl.inv1_def]
|
|
177 |
(inv1 RS invariantE) RS conjunct1] 1);
|
1328
|
178 |
(* 6 - 5 *)
|
|
179 |
by (EVERY1[tac2,tac2]);
|
|
180 |
|
1051
|
181 |
(* 4 *)
|
|
182 |
by (forward_tac [rewrite_rule [Impl.inv1_def]
|
|
183 |
(inv1 RS invariantE) RS conjunct1] 1);
|
1328
|
184 |
by (tac2 1);
|
1051
|
185 |
by (fast_tac (HOL_cs addDs [add_leD1,leD]) 1);
|
|
186 |
|
|
187 |
(* 3 *)
|
|
188 |
by (forward_tac [rewrite_rule [Impl.inv1_def] (inv1 RS invariantE)] 1);
|
|
189 |
|
1328
|
190 |
by (tac2 1);
|
1051
|
191 |
by (fold_tac [rewrite_rule [Packet.hdr_def]Impl.hdr_sum_def]);
|
|
192 |
by (fast_tac (HOL_cs addDs [add_leD1,leD]) 1);
|
|
193 |
|
|
194 |
(* 2 *)
|
1328
|
195 |
by (tac2 1);
|
1051
|
196 |
by(forward_tac [rewrite_rule [Impl.inv1_def]
|
|
197 |
(inv1 RS invariantE) RS conjunct1] 1);
|
|
198 |
by (rtac impI 1);
|
|
199 |
by (rtac impI 1);
|
|
200 |
by (REPEAT (etac conjE 1));
|
|
201 |
by (dres_inst_tac [("k","count (rsch s) (~sbit(sen s))")]
|
|
202 |
(standard(leq_add_leq RS mp)) 1);
|
1328
|
203 |
by (Asm_full_simp_tac 1);
|
1051
|
204 |
|
|
205 |
(* 1 *)
|
1328
|
206 |
by (tac2 1);
|
1051
|
207 |
by(forward_tac [rewrite_rule [Impl.inv1_def]
|
|
208 |
(inv1 RS invariantE) RS conjunct2] 1);
|
|
209 |
by (rtac impI 1);
|
|
210 |
by (rtac impI 1);
|
|
211 |
by (REPEAT (etac conjE 1));
|
|
212 |
by (fold_tac [rewrite_rule[Packet.hdr_def]Impl.hdr_sum_def]);
|
|
213 |
by (dres_inst_tac [("k","hdr_sum (srch s) (sbit(sen s))")]
|
|
214 |
(standard(leq_add_leq RS mp)) 1);
|
1328
|
215 |
by (Asm_full_simp_tac 1);
|
1051
|
216 |
qed "inv2";
|
|
217 |
|
|
218 |
|
|
219 |
(* INVARIANT 3 *)
|
1266
|
220 |
|
1051
|
221 |
goal Impl.thy "invariant impl_ioa inv3";
|
|
222 |
|
|
223 |
by (rtac invariantI 1);
|
|
224 |
(* Base case *)
|
1328
|
225 |
by (asm_full_simp_tac (!simpset addsimps
|
1051
|
226 |
(Impl.inv3_def :: (receiver_projections
|
|
227 |
@ sender_projections @ impl_ioas))) 1);
|
|
228 |
|
1328
|
229 |
by (asm_simp_tac (!simpset addsimps impl_ioas) 1);
|
1051
|
230 |
by (Action.action.induct_tac "a" 1);
|
|
231 |
|
1328
|
232 |
val tac3 = asm_full_simp_tac (ss addsimps [inv3_def]
|
|
233 |
setloop (split_tac [expand_if]));
|
|
234 |
|
|
235 |
(* 10 - 8 *)
|
1051
|
236 |
|
1328
|
237 |
by (EVERY1[tac3,tac3,tac3]);
|
|
238 |
|
|
239 |
by (tac_ren 1);
|
1051
|
240 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
241 |
by (hyp_subst_tac 1);
|
|
242 |
by (etac exE 1);
|
1266
|
243 |
by (Asm_full_simp_tac 1);
|
1051
|
244 |
|
|
245 |
(* 7 *)
|
1328
|
246 |
by (tac3 1);
|
|
247 |
by (tac_ren 1);
|
1051
|
248 |
by (fast_tac HOL_cs 1);
|
|
249 |
|
1328
|
250 |
(* 6 - 3 *)
|
1051
|
251 |
|
1328
|
252 |
by (EVERY1[tac3,tac3,tac3,tac3]);
|
1051
|
253 |
|
|
254 |
(* 2 *)
|
1328
|
255 |
by (asm_full_simp_tac ss 1);
|
|
256 |
by (simp_tac (!simpset addsimps [inv3_def]) 1);
|
1051
|
257 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
258 |
by (rtac (imp_or_lem RS iffD2) 1);
|
|
259 |
by (rtac impI 1);
|
|
260 |
by (forward_tac [rewrite_rule [Impl.inv2_def] (inv2 RS invariantE)] 1);
|
1328
|
261 |
by (Asm_full_simp_tac 1);
|
1051
|
262 |
by (REPEAT (etac conjE 1));
|
|
263 |
by (res_inst_tac [("j","count (ssent(sen s)) (~sbit(sen s))"),
|
|
264 |
("k","count (rsent(rec s)) (sbit(sen s))")] le_trans 1);
|
1328
|
265 |
by (forward_tac [rewrite_rule [inv1_def]
|
1051
|
266 |
(inv1 RS invariantE) RS conjunct2] 1);
|
1328
|
267 |
by (asm_full_simp_tac (!simpset addsimps
|
|
268 |
[hdr_sum_def, Multiset.count_def]) 1);
|
1051
|
269 |
by (rtac (less_eq_add_cong RS mp RS mp) 1);
|
|
270 |
by (rtac countm_props 1);
|
1328
|
271 |
by (Simp_tac 1);
|
1051
|
272 |
by (rtac countm_props 1);
|
1328
|
273 |
by (Simp_tac 1);
|
1051
|
274 |
by (assume_tac 1);
|
|
275 |
|
|
276 |
(* 1 *)
|
1328
|
277 |
by (tac3 1);
|
1051
|
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);
|
1328
|
282 |
by (Asm_full_simp_tac 1);
|
1051
|
283 |
by (REPEAT (etac conjE 1));
|
|
284 |
by (dtac mp 1);
|
|
285 |
by (assume_tac 1);
|
|
286 |
by (etac allE 1);
|
|
287 |
by (dtac (imp_or_lem RS iffD1) 1);
|
|
288 |
by (dtac mp 1);
|
|
289 |
by (assume_tac 1);
|
|
290 |
by (assume_tac 1);
|
|
291 |
qed "inv3";
|
|
292 |
|
|
293 |
|
|
294 |
(* INVARIANT 4 *)
|
|
295 |
|
|
296 |
goal Impl.thy "invariant impl_ioa inv4";
|
|
297 |
|
|
298 |
by (rtac invariantI 1);
|
|
299 |
(* Base case *)
|
1328
|
300 |
by (asm_full_simp_tac (!simpset addsimps
|
1051
|
301 |
(Impl.inv4_def :: (receiver_projections
|
|
302 |
@ sender_projections @ impl_ioas))) 1);
|
|
303 |
|
1328
|
304 |
by (asm_simp_tac (!simpset addsimps impl_ioas) 1);
|
1051
|
305 |
by (Action.action.induct_tac "a" 1);
|
|
306 |
|
1328
|
307 |
val tac4 = asm_full_simp_tac (ss addsimps [inv4_def]
|
|
308 |
setloop (split_tac [expand_if]));
|
1051
|
309 |
|
1328
|
310 |
(* 10 - 2 *)
|
|
311 |
|
|
312 |
by (EVERY1[tac4,tac4,tac4,tac4,tac4,tac4,tac4,tac4,tac4]);
|
|
313 |
|
|
314 |
(* 2 b *)
|
|
315 |
|
1051
|
316 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
317 |
by(forward_tac [rewrite_rule [Impl.inv2_def]
|
|
318 |
(inv2 RS invariantE)] 1);
|
1328
|
319 |
by (tac4 1);
|
1266
|
320 |
by (Asm_full_simp_tac 1);
|
1051
|
321 |
|
|
322 |
(* 1 *)
|
1328
|
323 |
by (tac4 1);
|
1051
|
324 |
by (strip_tac 1 THEN REPEAT (etac conjE 1));
|
|
325 |
by (rtac ccontr 1);
|
|
326 |
by(forward_tac [rewrite_rule [Impl.inv2_def]
|
|
327 |
(inv2 RS invariantE)] 1);
|
|
328 |
by(forward_tac [rewrite_rule [Impl.inv3_def]
|
|
329 |
(inv3 RS invariantE)] 1);
|
1266
|
330 |
by (Asm_full_simp_tac 1);
|
1051
|
331 |
by (eres_inst_tac [("x","m")] allE 1);
|
|
332 |
by (dtac less_le_trans 1);
|
|
333 |
by (dtac (left_add_leq RS mp) 1);
|
1266
|
334 |
by (Asm_full_simp_tac 1);
|
|
335 |
by (Asm_full_simp_tac 1);
|
1051
|
336 |
qed "inv4";
|
|
337 |
|
|
338 |
|
|
339 |
(* rebind them *)
|
|
340 |
|
|
341 |
val inv1 = rewrite_rule [Impl.inv1_def] (inv1 RS invariantE);
|
|
342 |
val inv2 = rewrite_rule [Impl.inv2_def] (inv2 RS invariantE);
|
|
343 |
val inv3 = rewrite_rule [Impl.inv3_def] (inv3 RS invariantE);
|
|
344 |
val inv4 = rewrite_rule [Impl.inv4_def] (inv4 RS invariantE);
|