1839
|
1 |
(* Title: HOL/Auth/Message
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1996 University of Cambridge
|
|
5 |
|
|
6 |
Datatypes of agents and messages;
|
|
7 |
Inductive relations "parts", "analyze" and "synthesize"
|
|
8 |
*)
|
|
9 |
|
|
10 |
open Message;
|
|
11 |
|
|
12 |
|
|
13 |
(**************** INSTALL CENTRALLY SOMEWHERE? ****************)
|
|
14 |
|
|
15 |
(*Maybe swap the safe_tac and simp_tac lines?**)
|
|
16 |
fun auto_tac (cs,ss) =
|
|
17 |
TRY (safe_tac cs) THEN
|
|
18 |
ALLGOALS (asm_full_simp_tac ss) THEN
|
|
19 |
REPEAT (FIRSTGOAL (best_tac (cs addss ss)));
|
|
20 |
|
|
21 |
fun Auto_tac() = auto_tac (!claset, !simpset);
|
|
22 |
|
|
23 |
fun auto() = by (Auto_tac());
|
|
24 |
|
1852
|
25 |
fun impOfSubs th = th RSN (2, rev_subsetD);
|
1839
|
26 |
|
|
27 |
(**************** INSTALL CENTRALLY SOMEWHERE? ****************)
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
(** Inverse of keys **)
|
|
32 |
|
|
33 |
goal thy "!!K K'. (invKey K = invKey K') = (K=K')";
|
|
34 |
by (Step_tac 1);
|
|
35 |
br box_equals 1;
|
|
36 |
by (REPEAT (rtac invKey 2));
|
|
37 |
by (Asm_simp_tac 1);
|
|
38 |
qed "invKey_eq";
|
|
39 |
|
|
40 |
Addsimps [invKey, invKey_eq];
|
|
41 |
|
|
42 |
|
|
43 |
(**** keysFor operator ****)
|
|
44 |
|
|
45 |
goalw thy [keysFor_def] "keysFor {} = {}";
|
|
46 |
by (Fast_tac 1);
|
|
47 |
qed "keysFor_empty";
|
|
48 |
|
|
49 |
goalw thy [keysFor_def] "keysFor (H Un H') = keysFor H Un keysFor H'";
|
|
50 |
by (Fast_tac 1);
|
|
51 |
qed "keysFor_Un";
|
|
52 |
|
|
53 |
goalw thy [keysFor_def] "keysFor (UN i. H i) = (UN i. keysFor (H i))";
|
|
54 |
by (Fast_tac 1);
|
|
55 |
qed "keysFor_UN";
|
|
56 |
|
|
57 |
(*Monotonicity*)
|
|
58 |
goalw thy [keysFor_def] "!!G H. G<=H ==> keysFor(G) <= keysFor(H)";
|
|
59 |
by (Fast_tac 1);
|
|
60 |
qed "keysFor_mono";
|
|
61 |
|
|
62 |
goalw thy [keysFor_def] "keysFor (insert (Agent A) H) = keysFor H";
|
|
63 |
by (fast_tac (!claset addss (!simpset)) 1);
|
|
64 |
qed "keysFor_insert_Agent";
|
|
65 |
|
|
66 |
goalw thy [keysFor_def] "keysFor (insert (Nonce N) H) = keysFor H";
|
|
67 |
by (fast_tac (!claset addss (!simpset)) 1);
|
|
68 |
qed "keysFor_insert_Nonce";
|
|
69 |
|
|
70 |
goalw thy [keysFor_def] "keysFor (insert (Key K) H) = keysFor H";
|
|
71 |
by (fast_tac (!claset addss (!simpset)) 1);
|
|
72 |
qed "keysFor_insert_Key";
|
|
73 |
|
|
74 |
goalw thy [keysFor_def] "keysFor (insert {|X,Y|} H) = keysFor H";
|
|
75 |
by (fast_tac (!claset addss (!simpset)) 1);
|
|
76 |
qed "keysFor_insert_MPair";
|
|
77 |
|
|
78 |
goalw thy [keysFor_def]
|
|
79 |
"keysFor (insert (Crypt X K) H) = insert (invKey K) (keysFor H)";
|
|
80 |
by (Auto_tac());
|
|
81 |
by (fast_tac (!claset addIs [image_eqI]) 1);
|
|
82 |
qed "keysFor_insert_Crypt";
|
|
83 |
|
|
84 |
Addsimps [keysFor_empty, keysFor_Un, keysFor_UN,
|
|
85 |
keysFor_insert_Agent, keysFor_insert_Nonce,
|
|
86 |
keysFor_insert_Key, keysFor_insert_MPair,
|
|
87 |
keysFor_insert_Crypt];
|
|
88 |
|
|
89 |
|
|
90 |
(**** Inductive relation "parts" ****)
|
|
91 |
|
|
92 |
val major::prems =
|
|
93 |
goal thy "[| {|X,Y|} : parts H; \
|
|
94 |
\ [| X : parts H; Y : parts H |] ==> P \
|
|
95 |
\ |] ==> P";
|
|
96 |
by (cut_facts_tac [major] 1);
|
|
97 |
brs prems 1;
|
|
98 |
by (REPEAT (eresolve_tac [asm_rl, parts.Fst, parts.Snd] 1));
|
|
99 |
qed "MPair_parts";
|
|
100 |
|
|
101 |
AddIs [parts.Inj];
|
|
102 |
AddSEs [MPair_parts];
|
|
103 |
AddDs [parts.Body];
|
|
104 |
|
|
105 |
goal thy "H <= parts(H)";
|
|
106 |
by (Fast_tac 1);
|
|
107 |
qed "parts_increasing";
|
|
108 |
|
|
109 |
(*Monotonicity*)
|
|
110 |
goalw thy parts.defs "!!G H. G<=H ==> parts(G) <= parts(H)";
|
|
111 |
by (rtac lfp_mono 1);
|
|
112 |
by (REPEAT (ares_tac basic_monos 1));
|
|
113 |
qed "parts_mono";
|
|
114 |
|
|
115 |
goal thy "parts{} = {}";
|
|
116 |
by (Step_tac 1);
|
|
117 |
be parts.induct 1;
|
|
118 |
by (ALLGOALS Fast_tac);
|
|
119 |
qed "parts_empty";
|
|
120 |
Addsimps [parts_empty];
|
|
121 |
|
|
122 |
goal thy "!!X. X: parts{} ==> P";
|
|
123 |
by (Asm_full_simp_tac 1);
|
|
124 |
qed "parts_emptyE";
|
|
125 |
AddSEs [parts_emptyE];
|
|
126 |
|
|
127 |
|
|
128 |
(** Unions **)
|
|
129 |
|
|
130 |
goal thy "parts(G) Un parts(H) <= parts(G Un H)";
|
|
131 |
by (REPEAT (ares_tac [Un_least, parts_mono, Un_upper1, Un_upper2] 1));
|
|
132 |
val parts_Un_subset1 = result();
|
|
133 |
|
|
134 |
goal thy "parts(G Un H) <= parts(G) Un parts(H)";
|
|
135 |
br subsetI 1;
|
|
136 |
be parts.induct 1;
|
|
137 |
by (ALLGOALS Fast_tac);
|
|
138 |
val parts_Un_subset2 = result();
|
|
139 |
|
|
140 |
goal thy "parts(G Un H) = parts(G) Un parts(H)";
|
|
141 |
by (REPEAT (ares_tac [equalityI, parts_Un_subset1, parts_Un_subset2] 1));
|
|
142 |
qed "parts_Un";
|
|
143 |
|
1852
|
144 |
(*TWO inserts to avoid looping. This rewrite is better than nothing...*)
|
|
145 |
goal thy "parts (insert X (insert Y H)) = parts {X} Un parts {Y} Un parts H";
|
|
146 |
by (stac (read_instantiate [("A","H")] insert_is_Un) 1);
|
|
147 |
by (stac (read_instantiate [("A","{Y} Un H")] insert_is_Un) 1);
|
|
148 |
by (simp_tac (HOL_ss addsimps [parts_Un, Un_assoc]) 1);
|
|
149 |
qed "parts_insert2";
|
|
150 |
|
1839
|
151 |
goal thy "(UN x:A. parts(H x)) <= parts(UN x:A. H x)";
|
|
152 |
by (REPEAT (ares_tac [UN_least, parts_mono, UN_upper] 1));
|
|
153 |
val parts_UN_subset1 = result();
|
|
154 |
|
|
155 |
goal thy "parts(UN x:A. H x) <= (UN x:A. parts(H x))";
|
|
156 |
br subsetI 1;
|
|
157 |
be parts.induct 1;
|
|
158 |
by (ALLGOALS Fast_tac);
|
|
159 |
val parts_UN_subset2 = result();
|
|
160 |
|
|
161 |
goal thy "parts(UN x:A. H x) = (UN x:A. parts(H x))";
|
|
162 |
by (REPEAT (ares_tac [equalityI, parts_UN_subset1, parts_UN_subset2] 1));
|
|
163 |
qed "parts_UN";
|
|
164 |
|
|
165 |
goal thy "parts(UN x. H x) = (UN x. parts(H x))";
|
|
166 |
by (simp_tac (!simpset addsimps [UNION1_def, parts_UN]) 1);
|
|
167 |
qed "parts_UN1";
|
|
168 |
|
|
169 |
(*Added to simplify arguments to parts, analyze and synthesize*)
|
|
170 |
Addsimps [parts_Un, parts_UN, parts_UN1];
|
|
171 |
|
|
172 |
goal thy "insert X (parts H) <= parts(insert X H)";
|
1852
|
173 |
by (fast_tac (!claset addEs [impOfSubs parts_mono]) 1);
|
1839
|
174 |
qed "parts_insert_subset";
|
|
175 |
|
|
176 |
(*Especially for reasoning about the Fake rule in traces*)
|
|
177 |
goal thy "!!Y. X: G ==> parts(insert X H) <= parts G Un parts H";
|
|
178 |
br ([parts_mono, parts_Un_subset2] MRS subset_trans) 1;
|
|
179 |
by (Fast_tac 1);
|
|
180 |
qed "parts_insert_subset_Un";
|
|
181 |
|
|
182 |
(** Idempotence and transitivity **)
|
|
183 |
|
|
184 |
goal thy "!!H. X: parts (parts H) ==> X: parts H";
|
|
185 |
be parts.induct 1;
|
|
186 |
by (ALLGOALS Fast_tac);
|
|
187 |
qed "parts_partsE";
|
|
188 |
AddSEs [parts_partsE];
|
|
189 |
|
|
190 |
goal thy "parts (parts H) = parts H";
|
|
191 |
by (Fast_tac 1);
|
|
192 |
qed "parts_idem";
|
|
193 |
Addsimps [parts_idem];
|
|
194 |
|
|
195 |
goal thy "!!H. [| X: parts G; G <= parts H |] ==> X: parts H";
|
|
196 |
by (dtac parts_mono 1);
|
|
197 |
by (Fast_tac 1);
|
|
198 |
qed "parts_trans";
|
|
199 |
|
|
200 |
(*Cut*)
|
|
201 |
goal thy "!!H. [| X: parts H; Y: parts (insert X H) |] ==> Y: parts H";
|
|
202 |
be parts_trans 1;
|
|
203 |
by (Fast_tac 1);
|
|
204 |
qed "parts_cut";
|
|
205 |
|
|
206 |
|
|
207 |
(** Rewrite rules for pulling out atomic messages **)
|
|
208 |
|
|
209 |
goal thy "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)";
|
|
210 |
by (rtac (parts_insert_subset RSN (2, equalityI)) 1);
|
|
211 |
br subsetI 1;
|
|
212 |
be parts.induct 1;
|
|
213 |
(*Simplification breaks up equalities between messages;
|
|
214 |
how to make it work for fast_tac??*)
|
|
215 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
216 |
qed "parts_insert_Agent";
|
|
217 |
|
|
218 |
goal thy "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)";
|
|
219 |
by (rtac (parts_insert_subset RSN (2, equalityI)) 1);
|
|
220 |
br subsetI 1;
|
|
221 |
be parts.induct 1;
|
|
222 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
223 |
qed "parts_insert_Nonce";
|
|
224 |
|
|
225 |
goal thy "parts (insert (Key K) H) = insert (Key K) (parts H)";
|
|
226 |
by (rtac (parts_insert_subset RSN (2, equalityI)) 1);
|
|
227 |
br subsetI 1;
|
|
228 |
be parts.induct 1;
|
|
229 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
230 |
qed "parts_insert_Key";
|
|
231 |
|
|
232 |
goal thy "parts (insert (Crypt X K) H) = \
|
|
233 |
\ insert (Crypt X K) (parts (insert X H))";
|
|
234 |
br equalityI 1;
|
|
235 |
br subsetI 1;
|
|
236 |
be parts.induct 1;
|
|
237 |
by (Auto_tac());
|
|
238 |
be parts.induct 1;
|
|
239 |
by (ALLGOALS (best_tac (!claset addIs [parts.Body])));
|
|
240 |
qed "parts_insert_Crypt";
|
|
241 |
|
|
242 |
goal thy "parts (insert {|X,Y|} H) = \
|
|
243 |
\ insert {|X,Y|} (parts (insert X (insert Y H)))";
|
|
244 |
br equalityI 1;
|
|
245 |
br subsetI 1;
|
|
246 |
be parts.induct 1;
|
|
247 |
by (Auto_tac());
|
|
248 |
be parts.induct 1;
|
|
249 |
by (ALLGOALS (best_tac (!claset addIs [parts.Fst, parts.Snd])));
|
|
250 |
qed "parts_insert_MPair";
|
|
251 |
|
|
252 |
Addsimps [parts_insert_Agent, parts_insert_Nonce,
|
|
253 |
parts_insert_Key, parts_insert_Crypt, parts_insert_MPair];
|
|
254 |
|
|
255 |
|
|
256 |
(**** Inductive relation "analyze" ****)
|
|
257 |
|
|
258 |
val major::prems =
|
|
259 |
goal thy "[| {|X,Y|} : analyze H; \
|
|
260 |
\ [| X : analyze H; Y : analyze H |] ==> P \
|
|
261 |
\ |] ==> P";
|
|
262 |
by (cut_facts_tac [major] 1);
|
|
263 |
brs prems 1;
|
|
264 |
by (REPEAT (eresolve_tac [asm_rl, analyze.Fst, analyze.Snd] 1));
|
|
265 |
qed "MPair_analyze";
|
|
266 |
|
|
267 |
AddIs [analyze.Inj];
|
|
268 |
AddSEs [MPair_analyze];
|
|
269 |
AddDs [analyze.Decrypt];
|
|
270 |
|
|
271 |
goal thy "H <= analyze(H)";
|
|
272 |
by (Fast_tac 1);
|
|
273 |
qed "analyze_increasing";
|
|
274 |
|
|
275 |
goal thy "analyze H <= parts H";
|
|
276 |
by (rtac subsetI 1);
|
|
277 |
be analyze.induct 1;
|
|
278 |
by (ALLGOALS Fast_tac);
|
|
279 |
qed "analyze_subset_parts";
|
|
280 |
|
|
281 |
bind_thm ("not_parts_not_analyze", analyze_subset_parts RS contra_subsetD);
|
|
282 |
|
|
283 |
|
|
284 |
goal thy "parts (analyze H) = parts H";
|
|
285 |
br equalityI 1;
|
|
286 |
br (analyze_subset_parts RS parts_mono RS subset_trans) 1;
|
|
287 |
by (Simp_tac 1);
|
|
288 |
by (fast_tac (!claset addDs [analyze_increasing RS parts_mono RS subsetD]) 1);
|
|
289 |
qed "parts_analyze";
|
|
290 |
Addsimps [parts_analyze];
|
|
291 |
|
|
292 |
(*Monotonicity; Lemma 1 of Lowe*)
|
|
293 |
goalw thy analyze.defs "!!G H. G<=H ==> analyze(G) <= analyze(H)";
|
|
294 |
by (rtac lfp_mono 1);
|
|
295 |
by (REPEAT (ares_tac basic_monos 1));
|
|
296 |
qed "analyze_mono";
|
|
297 |
|
|
298 |
(** General equational properties **)
|
|
299 |
|
|
300 |
goal thy "analyze{} = {}";
|
|
301 |
by (Step_tac 1);
|
|
302 |
be analyze.induct 1;
|
|
303 |
by (ALLGOALS Fast_tac);
|
|
304 |
qed "analyze_empty";
|
|
305 |
Addsimps [analyze_empty];
|
|
306 |
|
|
307 |
(*Converse fails: we can analyze more from the union than from the
|
|
308 |
separate parts, as a key in one might decrypt a message in the other*)
|
|
309 |
goal thy "analyze(G) Un analyze(H) <= analyze(G Un H)";
|
|
310 |
by (REPEAT (ares_tac [Un_least, analyze_mono, Un_upper1, Un_upper2] 1));
|
|
311 |
qed "analyze_Un";
|
|
312 |
|
|
313 |
goal thy "insert X (analyze H) <= analyze(insert X H)";
|
1852
|
314 |
by (fast_tac (!claset addEs [impOfSubs analyze_mono]) 1);
|
1839
|
315 |
qed "analyze_insert";
|
|
316 |
|
|
317 |
(** Rewrite rules for pulling out atomic messages **)
|
|
318 |
|
|
319 |
goal thy "analyze (insert (Agent agt) H) = insert (Agent agt) (analyze H)";
|
|
320 |
by (rtac (analyze_insert RSN (2, equalityI)) 1);
|
|
321 |
br subsetI 1;
|
|
322 |
be analyze.induct 1;
|
|
323 |
(*Simplification breaks up equalities between messages;
|
|
324 |
how to make it work for fast_tac??*)
|
|
325 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
326 |
qed "analyze_insert_Agent";
|
|
327 |
|
|
328 |
goal thy "analyze (insert (Nonce N) H) = insert (Nonce N) (analyze H)";
|
|
329 |
by (rtac (analyze_insert RSN (2, equalityI)) 1);
|
|
330 |
br subsetI 1;
|
|
331 |
be analyze.induct 1;
|
|
332 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
333 |
qed "analyze_insert_Nonce";
|
|
334 |
|
|
335 |
(*Can only pull out Keys if they are not needed to decrypt the rest*)
|
|
336 |
goalw thy [keysFor_def]
|
|
337 |
"!!K. K ~: keysFor (analyze H) ==> \
|
|
338 |
\ analyze (insert (Key K) H) = insert (Key K) (analyze H)";
|
|
339 |
by (rtac (analyze_insert RSN (2, equalityI)) 1);
|
|
340 |
br subsetI 1;
|
|
341 |
be analyze.induct 1;
|
|
342 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
343 |
qed "analyze_insert_Key";
|
|
344 |
|
|
345 |
goal thy "!!H. Key (invKey K) ~: analyze H ==> \
|
|
346 |
\ analyze (insert (Crypt X K) H) = \
|
|
347 |
\ insert (Crypt X K) (analyze H)";
|
|
348 |
by (rtac (analyze_insert RSN (2, equalityI)) 1);
|
|
349 |
br subsetI 1;
|
|
350 |
be analyze.induct 1;
|
|
351 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
352 |
qed "analyze_insert_Crypt";
|
|
353 |
|
|
354 |
goal thy "!!H. Key (invKey K) : analyze H ==> \
|
|
355 |
\ analyze (insert (Crypt X K) H) <= \
|
|
356 |
\ insert (Crypt X K) (analyze (insert X H))";
|
|
357 |
br subsetI 1;
|
|
358 |
by (eres_inst_tac [("za","x")] analyze.induct 1);
|
|
359 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
360 |
val lemma1 = result();
|
|
361 |
|
|
362 |
goal thy "!!H. Key (invKey K) : analyze H ==> \
|
|
363 |
\ insert (Crypt X K) (analyze (insert X H)) <= \
|
|
364 |
\ analyze (insert (Crypt X K) H)";
|
|
365 |
by (Auto_tac());
|
|
366 |
by (eres_inst_tac [("za","x")] analyze.induct 1);
|
|
367 |
by (Auto_tac());
|
|
368 |
by (best_tac (!claset addIs [subset_insertI RS analyze_mono RS subsetD,
|
|
369 |
analyze.Decrypt]) 1);
|
|
370 |
val lemma2 = result();
|
|
371 |
|
|
372 |
goal thy "!!H. Key (invKey K) : analyze H ==> \
|
|
373 |
\ analyze (insert (Crypt X K) H) = \
|
|
374 |
\ insert (Crypt X K) (analyze (insert X H))";
|
|
375 |
by (REPEAT (ares_tac [equalityI, lemma1, lemma2] 1));
|
|
376 |
qed "analyze_insert_Decrypt";
|
|
377 |
|
|
378 |
Addsimps [analyze_insert_Agent, analyze_insert_Nonce,
|
|
379 |
analyze_insert_Key, analyze_insert_Crypt,
|
|
380 |
analyze_insert_Decrypt];
|
|
381 |
|
|
382 |
|
|
383 |
(*This rule supposes "for the sake of argument" that we have the key.*)
|
|
384 |
goal thy "analyze (insert (Crypt X K) H) <= \
|
|
385 |
\ insert (Crypt X K) (analyze (insert X H))";
|
|
386 |
br subsetI 1;
|
|
387 |
be analyze.induct 1;
|
|
388 |
by (Auto_tac());
|
|
389 |
qed "analyze_insert_Crypt_subset";
|
|
390 |
|
|
391 |
|
|
392 |
(** Rewrite rules for pulling out atomic parts of messages **)
|
|
393 |
|
|
394 |
goal thy "analyze (insert X H) <= analyze (insert {|X,Y|} H)";
|
|
395 |
br subsetI 1;
|
|
396 |
be analyze.induct 1;
|
|
397 |
by (ALLGOALS (best_tac (!claset addIs [analyze.Fst])));
|
|
398 |
qed "analyze_insert_subset_MPair1";
|
|
399 |
|
|
400 |
goal thy "analyze (insert Y H) <= analyze (insert {|X,Y|} H)";
|
|
401 |
br subsetI 1;
|
|
402 |
be analyze.induct 1;
|
|
403 |
by (ALLGOALS (best_tac (!claset addIs [analyze.Snd])));
|
|
404 |
qed "analyze_insert_subset_MPair2";
|
|
405 |
|
|
406 |
goal thy "analyze (insert {|Agent agt,Y|} H) = \
|
|
407 |
\ insert {|Agent agt,Y|} (insert (Agent agt) (analyze (insert Y H)))";
|
|
408 |
by (rtac equalityI 1);
|
|
409 |
by (best_tac (!claset addIs [analyze.Fst,
|
1852
|
410 |
impOfSubs analyze_insert_subset_MPair2]) 2);
|
1839
|
411 |
br subsetI 1;
|
|
412 |
be analyze.induct 1;
|
|
413 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
414 |
qed "analyze_insert_Agent_MPair";
|
|
415 |
|
|
416 |
goal thy "analyze (insert {|Nonce N,Y|} H) = \
|
|
417 |
\ insert {|Nonce N,Y|} (insert (Nonce N) (analyze (insert Y H)))";
|
|
418 |
by (rtac equalityI 1);
|
|
419 |
by (best_tac (!claset addIs [analyze.Fst,
|
1852
|
420 |
impOfSubs analyze_insert_subset_MPair2]) 2);
|
1839
|
421 |
br subsetI 1;
|
|
422 |
be analyze.induct 1;
|
|
423 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
424 |
qed "analyze_insert_Nonce_MPair";
|
|
425 |
|
|
426 |
(*Can only pull out Keys if they are not needed to decrypt the rest*)
|
|
427 |
goalw thy [keysFor_def]
|
|
428 |
"!!K. K ~: keysFor (analyze (insert Y H)) ==> \
|
|
429 |
\ analyze (insert {|Key K, Y|} H) = \
|
|
430 |
\ insert {|Key K, Y|} (insert (Key K) (analyze (insert Y H)))";
|
|
431 |
by (rtac equalityI 1);
|
|
432 |
by (best_tac (!claset addIs [analyze.Fst,
|
1852
|
433 |
impOfSubs analyze_insert_subset_MPair2]) 2);
|
1839
|
434 |
br subsetI 1;
|
|
435 |
be analyze.induct 1;
|
|
436 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
437 |
qed "analyze_insert_Key_MPair";
|
|
438 |
|
|
439 |
Addsimps [analyze_insert_Agent_MPair, analyze_insert_Nonce_MPair,
|
|
440 |
analyze_insert_Key_MPair];
|
|
441 |
|
|
442 |
(** Idempotence and transitivity **)
|
|
443 |
|
|
444 |
goal thy "!!H. X: analyze (analyze H) ==> X: analyze H";
|
|
445 |
be analyze.induct 1;
|
|
446 |
by (ALLGOALS Fast_tac);
|
|
447 |
qed "analyze_analyzeE";
|
|
448 |
AddSEs [analyze_analyzeE];
|
|
449 |
|
|
450 |
goal thy "analyze (analyze H) = analyze H";
|
|
451 |
by (Fast_tac 1);
|
|
452 |
qed "analyze_idem";
|
|
453 |
Addsimps [analyze_idem];
|
|
454 |
|
|
455 |
goal thy "!!H. [| X: analyze G; G <= analyze H |] ==> X: analyze H";
|
|
456 |
by (dtac analyze_mono 1);
|
|
457 |
by (Fast_tac 1);
|
|
458 |
qed "analyze_trans";
|
|
459 |
|
|
460 |
(*Cut; Lemma 2 of Lowe*)
|
|
461 |
goal thy "!!H. [| X: analyze H; Y: analyze (insert X H) |] ==> Y: analyze H";
|
|
462 |
be analyze_trans 1;
|
|
463 |
by (Fast_tac 1);
|
|
464 |
qed "analyze_cut";
|
|
465 |
|
|
466 |
(*Cut can be proved easily by induction on
|
|
467 |
"!!H. Y: analyze (insert X H) ==> X: analyze H --> Y: analyze H"
|
|
468 |
*)
|
|
469 |
|
|
470 |
(*If there are no pairs or encryptions then analyze does nothing*)
|
|
471 |
goal thy "!!H. [| ALL X Y. {|X,Y|} ~: H; ALL X K. Crypt X K ~: H |] ==> \
|
|
472 |
\ analyze H = H";
|
|
473 |
by (Step_tac 1);
|
|
474 |
be analyze.induct 1;
|
|
475 |
by (ALLGOALS Fast_tac);
|
|
476 |
qed "analyze_trivial";
|
|
477 |
|
|
478 |
(*Helps to prove Fake cases*)
|
|
479 |
goal thy "!!X. X: analyze (UN i. analyze (H i)) ==> X: analyze (UN i. H i)";
|
|
480 |
be analyze.induct 1;
|
1852
|
481 |
by (ALLGOALS (fast_tac (!claset addEs [impOfSubs analyze_mono])));
|
1839
|
482 |
val lemma = result();
|
|
483 |
|
|
484 |
goal thy "analyze (UN i. analyze (H i)) = analyze (UN i. H i)";
|
|
485 |
by (fast_tac (!claset addIs [lemma]
|
1852
|
486 |
addEs [impOfSubs analyze_mono]) 1);
|
1839
|
487 |
qed "analyze_UN_analyze";
|
|
488 |
Addsimps [analyze_UN_analyze];
|
|
489 |
|
|
490 |
|
|
491 |
(**** Inductive relation "synthesize" ****)
|
|
492 |
|
|
493 |
AddIs synthesize.intrs;
|
|
494 |
|
|
495 |
goal thy "H <= synthesize(H)";
|
|
496 |
by (Fast_tac 1);
|
|
497 |
qed "synthesize_increasing";
|
|
498 |
|
|
499 |
(*Monotonicity*)
|
|
500 |
goalw thy synthesize.defs "!!G H. G<=H ==> synthesize(G) <= synthesize(H)";
|
|
501 |
by (rtac lfp_mono 1);
|
|
502 |
by (REPEAT (ares_tac basic_monos 1));
|
|
503 |
qed "synthesize_mono";
|
|
504 |
|
|
505 |
(** Unions **)
|
|
506 |
|
|
507 |
(*Converse fails: we can synthesize more from the union than from the
|
|
508 |
separate parts, building a compound message using elements of each.*)
|
|
509 |
goal thy "synthesize(G) Un synthesize(H) <= synthesize(G Un H)";
|
|
510 |
by (REPEAT (ares_tac [Un_least, synthesize_mono, Un_upper1, Un_upper2] 1));
|
|
511 |
qed "synthesize_Un";
|
|
512 |
|
|
513 |
(** Idempotence and transitivity **)
|
|
514 |
|
|
515 |
goal thy "!!H. X: synthesize (synthesize H) ==> X: synthesize H";
|
|
516 |
be synthesize.induct 1;
|
|
517 |
by (ALLGOALS Fast_tac);
|
|
518 |
qed "synthesize_synthesizeE";
|
|
519 |
AddSEs [synthesize_synthesizeE];
|
|
520 |
|
|
521 |
goal thy "synthesize (synthesize H) = synthesize H";
|
|
522 |
by (Fast_tac 1);
|
|
523 |
qed "synthesize_idem";
|
|
524 |
|
|
525 |
goal thy "!!H. [| X: synthesize G; G <= synthesize H |] ==> X: synthesize H";
|
|
526 |
by (dtac synthesize_mono 1);
|
|
527 |
by (Fast_tac 1);
|
|
528 |
qed "synthesize_trans";
|
|
529 |
|
|
530 |
(*Cut; Lemma 2 of Lowe*)
|
|
531 |
goal thy "!!H. [| X: synthesize H; Y: synthesize (insert X H) \
|
|
532 |
\ |] ==> Y: synthesize H";
|
|
533 |
be synthesize_trans 1;
|
|
534 |
by (Fast_tac 1);
|
|
535 |
qed "synthesize_cut";
|
|
536 |
|
|
537 |
|
|
538 |
(*Can only produce a nonce or key if it is already known,
|
|
539 |
but can synthesize a pair or encryption from its components...*)
|
|
540 |
val mk_cases = synthesize.mk_cases msg.simps;
|
|
541 |
|
|
542 |
val Nonce_synthesize = mk_cases "Nonce n : synthesize H";
|
|
543 |
val Key_synthesize = mk_cases "Key K : synthesize H";
|
|
544 |
val MPair_synthesize = mk_cases "{|X,Y|} : synthesize H";
|
|
545 |
val Crypt_synthesize = mk_cases "Crypt X K : synthesize H";
|
|
546 |
|
|
547 |
AddSEs [Nonce_synthesize, Key_synthesize, MPair_synthesize, Crypt_synthesize];
|
|
548 |
|
|
549 |
goal thy "(Nonce N : synthesize H) = (Nonce N : H)";
|
|
550 |
by (Fast_tac 1);
|
|
551 |
qed "Nonce_synthesize_eq";
|
|
552 |
|
|
553 |
goal thy "(Key K : synthesize H) = (Key K : H)";
|
|
554 |
by (Fast_tac 1);
|
|
555 |
qed "Key_synthesize_eq";
|
|
556 |
|
|
557 |
Addsimps [Nonce_synthesize_eq, Key_synthesize_eq];
|
|
558 |
|
|
559 |
|
|
560 |
goalw thy [keysFor_def]
|
|
561 |
"keysFor (synthesize H) = keysFor H Un invKey``{K. Key K : H}";
|
|
562 |
by (Fast_tac 1);
|
|
563 |
qed "keysFor_synthesize";
|
|
564 |
Addsimps [keysFor_synthesize];
|
|
565 |
|
|
566 |
|
|
567 |
(*** Combinations of parts, analyze and synthesize ***)
|
|
568 |
|
|
569 |
(*Not that useful, in view of the following one...*)
|
|
570 |
goal thy "parts (synthesize H) <= synthesize (parts H)";
|
|
571 |
by (Step_tac 1);
|
|
572 |
be parts.induct 1;
|
|
573 |
be (parts_increasing RS synthesize_mono RS subsetD) 1;
|
|
574 |
by (ALLGOALS Fast_tac);
|
|
575 |
qed "parts_synthesize_subset";
|
|
576 |
|
|
577 |
goal thy "parts (synthesize H) = parts H Un synthesize H";
|
|
578 |
br equalityI 1;
|
|
579 |
br subsetI 1;
|
|
580 |
be parts.induct 1;
|
|
581 |
by (ALLGOALS
|
|
582 |
(best_tac (!claset addIs ((synthesize_increasing RS parts_mono RS subsetD)
|
|
583 |
::parts.intrs))));
|
|
584 |
qed "parts_synthesize";
|
|
585 |
Addsimps [parts_synthesize];
|
|
586 |
|
|
587 |
goal thy "analyze (synthesize H) = analyze H Un synthesize H";
|
|
588 |
br equalityI 1;
|
|
589 |
br subsetI 1;
|
|
590 |
be analyze.induct 1;
|
|
591 |
by (best_tac
|
|
592 |
(!claset addIs [synthesize_increasing RS analyze_mono RS subsetD]) 5);
|
|
593 |
(*Strange that best_tac just can't hack this one...*)
|
|
594 |
by (ALLGOALS (deepen_tac (!claset addIs analyze.intrs) 0));
|
|
595 |
qed "analyze_synthesize";
|
|
596 |
Addsimps [analyze_synthesize];
|
|
597 |
|
|
598 |
(*Hard to prove; still needed now that there's only one Enemy?*)
|
|
599 |
goal thy "analyze (UN i. synthesize (H i)) = \
|
|
600 |
\ analyze (UN i. H i) Un (UN i. synthesize (H i))";
|
|
601 |
br equalityI 1;
|
|
602 |
br subsetI 1;
|
|
603 |
be analyze.induct 1;
|
|
604 |
by (best_tac
|
1852
|
605 |
(!claset addEs [impOfSubs synthesize_increasing,
|
|
606 |
impOfSubs analyze_mono]) 5);
|
1839
|
607 |
by (Best_tac 1);
|
|
608 |
by (deepen_tac (!claset addIs [analyze.Fst]) 0 1);
|
|
609 |
by (deepen_tac (!claset addIs [analyze.Snd]) 0 1);
|
|
610 |
by (deepen_tac (!claset addSEs [analyze.Decrypt]
|
|
611 |
addIs [analyze.Decrypt]) 0 1);
|
|
612 |
qed "analyze_UN1_synthesize";
|
|
613 |
Addsimps [analyze_UN1_synthesize];
|