author | paulson |
Thu, 26 Sep 1996 10:34:19 +0200 | |
changeset 2028 | 738bb98d65ec |
parent 2026 | 0df5a96bf77e |
child 2032 | 1bbf1bdcaf56 |
permissions | -rw-r--r-- |
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; |
|
1913 | 7 |
Inductive relations "parts", "analz" and "synth" |
1839 | 8 |
*) |
9 |
||
10 |
open Message; |
|
11 |
||
12 |
||
13 |
(** Inverse of keys **) |
|
14 |
||
15 |
goal thy "!!K K'. (invKey K = invKey K') = (K=K')"; |
|
16 |
by (Step_tac 1); |
|
17 |
br box_equals 1; |
|
18 |
by (REPEAT (rtac invKey 2)); |
|
19 |
by (Asm_simp_tac 1); |
|
20 |
qed "invKey_eq"; |
|
21 |
||
22 |
Addsimps [invKey, invKey_eq]; |
|
23 |
||
24 |
||
25 |
(**** keysFor operator ****) |
|
26 |
||
27 |
goalw thy [keysFor_def] "keysFor {} = {}"; |
|
28 |
by (Fast_tac 1); |
|
29 |
qed "keysFor_empty"; |
|
30 |
||
31 |
goalw thy [keysFor_def] "keysFor (H Un H') = keysFor H Un keysFor H'"; |
|
32 |
by (Fast_tac 1); |
|
33 |
qed "keysFor_Un"; |
|
34 |
||
35 |
goalw thy [keysFor_def] "keysFor (UN i. H i) = (UN i. keysFor (H i))"; |
|
36 |
by (Fast_tac 1); |
|
37 |
qed "keysFor_UN"; |
|
38 |
||
39 |
(*Monotonicity*) |
|
40 |
goalw thy [keysFor_def] "!!G H. G<=H ==> keysFor(G) <= keysFor(H)"; |
|
41 |
by (Fast_tac 1); |
|
42 |
qed "keysFor_mono"; |
|
43 |
||
44 |
goalw thy [keysFor_def] "keysFor (insert (Agent A) H) = keysFor H"; |
|
45 |
by (fast_tac (!claset addss (!simpset)) 1); |
|
46 |
qed "keysFor_insert_Agent"; |
|
47 |
||
48 |
goalw thy [keysFor_def] "keysFor (insert (Nonce N) H) = keysFor H"; |
|
49 |
by (fast_tac (!claset addss (!simpset)) 1); |
|
50 |
qed "keysFor_insert_Nonce"; |
|
51 |
||
52 |
goalw thy [keysFor_def] "keysFor (insert (Key K) H) = keysFor H"; |
|
53 |
by (fast_tac (!claset addss (!simpset)) 1); |
|
54 |
qed "keysFor_insert_Key"; |
|
55 |
||
56 |
goalw thy [keysFor_def] "keysFor (insert {|X,Y|} H) = keysFor H"; |
|
57 |
by (fast_tac (!claset addss (!simpset)) 1); |
|
58 |
qed "keysFor_insert_MPair"; |
|
59 |
||
60 |
goalw thy [keysFor_def] |
|
61 |
"keysFor (insert (Crypt X K) H) = insert (invKey K) (keysFor H)"; |
|
62 |
by (Auto_tac()); |
|
1964 | 63 |
by (Fast_tac 1); |
1839 | 64 |
qed "keysFor_insert_Crypt"; |
65 |
||
66 |
Addsimps [keysFor_empty, keysFor_Un, keysFor_UN, |
|
67 |
keysFor_insert_Agent, keysFor_insert_Nonce, |
|
68 |
keysFor_insert_Key, keysFor_insert_MPair, |
|
69 |
keysFor_insert_Crypt]; |
|
70 |
||
71 |
||
72 |
(**** Inductive relation "parts" ****) |
|
73 |
||
74 |
val major::prems = |
|
75 |
goal thy "[| {|X,Y|} : parts H; \ |
|
76 |
\ [| X : parts H; Y : parts H |] ==> P \ |
|
77 |
\ |] ==> P"; |
|
78 |
by (cut_facts_tac [major] 1); |
|
79 |
brs prems 1; |
|
80 |
by (REPEAT (eresolve_tac [asm_rl, parts.Fst, parts.Snd] 1)); |
|
81 |
qed "MPair_parts"; |
|
82 |
||
83 |
AddIs [parts.Inj]; |
|
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
84 |
|
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
85 |
val partsEs = [MPair_parts, make_elim parts.Body]; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
86 |
|
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
87 |
AddSEs partsEs; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
88 |
(*NB These two rules are UNSAFE in the formal sense, as they discard the |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
89 |
compound message. They work well on THIS FILE, perhaps because its |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
90 |
proofs concern only atomic messages.*) |
1839 | 91 |
|
92 |
goal thy "H <= parts(H)"; |
|
93 |
by (Fast_tac 1); |
|
94 |
qed "parts_increasing"; |
|
95 |
||
96 |
(*Monotonicity*) |
|
97 |
goalw thy parts.defs "!!G H. G<=H ==> parts(G) <= parts(H)"; |
|
98 |
by (rtac lfp_mono 1); |
|
99 |
by (REPEAT (ares_tac basic_monos 1)); |
|
100 |
qed "parts_mono"; |
|
101 |
||
102 |
goal thy "parts{} = {}"; |
|
103 |
by (Step_tac 1); |
|
104 |
be parts.induct 1; |
|
105 |
by (ALLGOALS Fast_tac); |
|
106 |
qed "parts_empty"; |
|
107 |
Addsimps [parts_empty]; |
|
108 |
||
109 |
goal thy "!!X. X: parts{} ==> P"; |
|
110 |
by (Asm_full_simp_tac 1); |
|
111 |
qed "parts_emptyE"; |
|
112 |
AddSEs [parts_emptyE]; |
|
113 |
||
1893 | 114 |
(*WARNING: loops if H = {Y}, therefore must not be repeated!*) |
115 |
goal thy "!!H. X: parts H ==> EX Y:H. X: parts {Y}"; |
|
116 |
be parts.induct 1; |
|
117 |
by (ALLGOALS Fast_tac); |
|
118 |
qed "parts_singleton"; |
|
119 |
||
1839 | 120 |
|
121 |
(** Unions **) |
|
122 |
||
123 |
goal thy "parts(G) Un parts(H) <= parts(G Un H)"; |
|
124 |
by (REPEAT (ares_tac [Un_least, parts_mono, Un_upper1, Un_upper2] 1)); |
|
125 |
val parts_Un_subset1 = result(); |
|
126 |
||
127 |
goal thy "parts(G Un H) <= parts(G) Un parts(H)"; |
|
128 |
br subsetI 1; |
|
129 |
be parts.induct 1; |
|
130 |
by (ALLGOALS Fast_tac); |
|
131 |
val parts_Un_subset2 = result(); |
|
132 |
||
133 |
goal thy "parts(G Un H) = parts(G) Un parts(H)"; |
|
134 |
by (REPEAT (ares_tac [equalityI, parts_Un_subset1, parts_Un_subset2] 1)); |
|
135 |
qed "parts_Un"; |
|
136 |
||
2011 | 137 |
goal thy "parts (insert X H) = parts {X} Un parts H"; |
1852 | 138 |
by (stac (read_instantiate [("A","H")] insert_is_Un) 1); |
2011 | 139 |
by (simp_tac (HOL_ss addsimps [parts_Un]) 1); |
140 |
qed "parts_insert"; |
|
141 |
||
142 |
(*TWO inserts to avoid looping. This rewrite is better than nothing. |
|
143 |
Not suitable for Addsimps: its behaviour can be strange.*) |
|
144 |
goal thy "parts (insert X (insert Y H)) = parts {X} Un parts {Y} Un parts H"; |
|
145 |
by (simp_tac (!simpset addsimps [Un_assoc]) 1); |
|
146 |
by (simp_tac (!simpset addsimps [parts_insert RS sym]) 1); |
|
1852 | 147 |
qed "parts_insert2"; |
148 |
||
1839 | 149 |
goal thy "(UN x:A. parts(H x)) <= parts(UN x:A. H x)"; |
150 |
by (REPEAT (ares_tac [UN_least, parts_mono, UN_upper] 1)); |
|
151 |
val parts_UN_subset1 = result(); |
|
152 |
||
153 |
goal thy "parts(UN x:A. H x) <= (UN x:A. parts(H x))"; |
|
154 |
br subsetI 1; |
|
155 |
be parts.induct 1; |
|
156 |
by (ALLGOALS Fast_tac); |
|
157 |
val parts_UN_subset2 = result(); |
|
158 |
||
159 |
goal thy "parts(UN x:A. H x) = (UN x:A. parts(H x))"; |
|
160 |
by (REPEAT (ares_tac [equalityI, parts_UN_subset1, parts_UN_subset2] 1)); |
|
161 |
qed "parts_UN"; |
|
162 |
||
163 |
goal thy "parts(UN x. H x) = (UN x. parts(H x))"; |
|
164 |
by (simp_tac (!simpset addsimps [UNION1_def, parts_UN]) 1); |
|
165 |
qed "parts_UN1"; |
|
166 |
||
1913 | 167 |
(*Added to simplify arguments to parts, analz and synth*) |
1839 | 168 |
Addsimps [parts_Un, parts_UN, parts_UN1]; |
169 |
||
170 |
goal thy "insert X (parts H) <= parts(insert X H)"; |
|
1852 | 171 |
by (fast_tac (!claset addEs [impOfSubs parts_mono]) 1); |
1839 | 172 |
qed "parts_insert_subset"; |
173 |
||
174 |
(** Idempotence and transitivity **) |
|
175 |
||
176 |
goal thy "!!H. X: parts (parts H) ==> X: parts H"; |
|
177 |
be parts.induct 1; |
|
178 |
by (ALLGOALS Fast_tac); |
|
179 |
qed "parts_partsE"; |
|
180 |
AddSEs [parts_partsE]; |
|
181 |
||
182 |
goal thy "parts (parts H) = parts H"; |
|
183 |
by (Fast_tac 1); |
|
184 |
qed "parts_idem"; |
|
185 |
Addsimps [parts_idem]; |
|
186 |
||
187 |
goal thy "!!H. [| X: parts G; G <= parts H |] ==> X: parts H"; |
|
188 |
by (dtac parts_mono 1); |
|
189 |
by (Fast_tac 1); |
|
190 |
qed "parts_trans"; |
|
191 |
||
192 |
(*Cut*) |
|
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
193 |
goal thy "!!H. [| Y: parts (insert X H); X: parts H |] ==> Y: parts H"; |
1839 | 194 |
be parts_trans 1; |
195 |
by (Fast_tac 1); |
|
196 |
qed "parts_cut"; |
|
197 |
||
2011 | 198 |
val parts_insertI = impOfSubs (subset_insertI RS parts_mono); |
199 |
||
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
200 |
goal thy "!!H. X: parts H ==> parts (insert X H) = parts H"; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
201 |
by (fast_tac (!claset addSEs [parts_cut] |
2011 | 202 |
addIs [parts_insertI]) 1); |
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
203 |
qed "parts_cut_eq"; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
204 |
|
2028
738bb98d65ec
Last working version prior to addition of "lost" component
paulson
parents:
2026
diff
changeset
|
205 |
Addsimps [parts_cut_eq]; |
738bb98d65ec
Last working version prior to addition of "lost" component
paulson
parents:
2026
diff
changeset
|
206 |
|
1839 | 207 |
|
208 |
(** Rewrite rules for pulling out atomic messages **) |
|
209 |
||
210 |
goal thy "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)"; |
|
211 |
by (rtac (parts_insert_subset RSN (2, equalityI)) 1); |
|
212 |
br subsetI 1; |
|
213 |
be parts.induct 1; |
|
214 |
(*Simplification breaks up equalities between messages; |
|
215 |
how to make it work for fast_tac??*) |
|
216 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
|
217 |
qed "parts_insert_Agent"; |
|
218 |
||
219 |
goal thy "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)"; |
|
220 |
by (rtac (parts_insert_subset RSN (2, equalityI)) 1); |
|
221 |
br subsetI 1; |
|
222 |
be parts.induct 1; |
|
223 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
|
224 |
qed "parts_insert_Nonce"; |
|
225 |
||
226 |
goal thy "parts (insert (Key K) H) = insert (Key K) (parts H)"; |
|
227 |
by (rtac (parts_insert_subset RSN (2, equalityI)) 1); |
|
228 |
br subsetI 1; |
|
229 |
be parts.induct 1; |
|
230 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
|
231 |
qed "parts_insert_Key"; |
|
232 |
||
233 |
goal thy "parts (insert (Crypt X K) H) = \ |
|
234 |
\ insert (Crypt X K) (parts (insert X H))"; |
|
235 |
br equalityI 1; |
|
236 |
br subsetI 1; |
|
237 |
be parts.induct 1; |
|
238 |
by (Auto_tac()); |
|
239 |
be parts.induct 1; |
|
240 |
by (ALLGOALS (best_tac (!claset addIs [parts.Body]))); |
|
241 |
qed "parts_insert_Crypt"; |
|
242 |
||
243 |
goal thy "parts (insert {|X,Y|} H) = \ |
|
244 |
\ insert {|X,Y|} (parts (insert X (insert Y H)))"; |
|
245 |
br equalityI 1; |
|
246 |
br subsetI 1; |
|
247 |
be parts.induct 1; |
|
248 |
by (Auto_tac()); |
|
249 |
be parts.induct 1; |
|
250 |
by (ALLGOALS (best_tac (!claset addIs [parts.Fst, parts.Snd]))); |
|
251 |
qed "parts_insert_MPair"; |
|
252 |
||
253 |
Addsimps [parts_insert_Agent, parts_insert_Nonce, |
|
254 |
parts_insert_Key, parts_insert_Crypt, parts_insert_MPair]; |
|
255 |
||
256 |
||
2026
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
257 |
goal thy "parts (Key``N) = Key``N"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
258 |
by (Auto_tac()); |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
259 |
be parts.induct 1; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
260 |
by (Auto_tac()); |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
261 |
qed "parts_image_Key"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
262 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
263 |
Addsimps [parts_image_Key]; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
264 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
265 |
|
1913 | 266 |
(**** Inductive relation "analz" ****) |
1839 | 267 |
|
268 |
val major::prems = |
|
1913 | 269 |
goal thy "[| {|X,Y|} : analz H; \ |
270 |
\ [| X : analz H; Y : analz H |] ==> P \ |
|
1839 | 271 |
\ |] ==> P"; |
272 |
by (cut_facts_tac [major] 1); |
|
273 |
brs prems 1; |
|
1913 | 274 |
by (REPEAT (eresolve_tac [asm_rl, analz.Fst, analz.Snd] 1)); |
275 |
qed "MPair_analz"; |
|
1839 | 276 |
|
1913 | 277 |
AddIs [analz.Inj]; |
2011 | 278 |
AddSEs [MPair_analz]; (*Perhaps it should NOT be deemed safe!*) |
1913 | 279 |
AddDs [analz.Decrypt]; |
1839 | 280 |
|
1913 | 281 |
Addsimps [analz.Inj]; |
1885 | 282 |
|
1913 | 283 |
goal thy "H <= analz(H)"; |
1839 | 284 |
by (Fast_tac 1); |
1913 | 285 |
qed "analz_increasing"; |
1839 | 286 |
|
1913 | 287 |
goal thy "analz H <= parts H"; |
1839 | 288 |
by (rtac subsetI 1); |
1913 | 289 |
be analz.induct 1; |
1839 | 290 |
by (ALLGOALS Fast_tac); |
1913 | 291 |
qed "analz_subset_parts"; |
1839 | 292 |
|
1913 | 293 |
bind_thm ("not_parts_not_analz", analz_subset_parts RS contra_subsetD); |
1839 | 294 |
|
295 |
||
1913 | 296 |
goal thy "parts (analz H) = parts H"; |
1839 | 297 |
br equalityI 1; |
1913 | 298 |
br (analz_subset_parts RS parts_mono RS subset_trans) 1; |
1839 | 299 |
by (Simp_tac 1); |
1913 | 300 |
by (fast_tac (!claset addDs [analz_increasing RS parts_mono RS subsetD]) 1); |
301 |
qed "parts_analz"; |
|
302 |
Addsimps [parts_analz]; |
|
1839 | 303 |
|
1913 | 304 |
goal thy "analz (parts H) = parts H"; |
1885 | 305 |
by (Auto_tac()); |
1913 | 306 |
be analz.induct 1; |
1885 | 307 |
by (Auto_tac()); |
1913 | 308 |
qed "analz_parts"; |
309 |
Addsimps [analz_parts]; |
|
1885 | 310 |
|
1839 | 311 |
(*Monotonicity; Lemma 1 of Lowe*) |
1913 | 312 |
goalw thy analz.defs "!!G H. G<=H ==> analz(G) <= analz(H)"; |
1839 | 313 |
by (rtac lfp_mono 1); |
314 |
by (REPEAT (ares_tac basic_monos 1)); |
|
1913 | 315 |
qed "analz_mono"; |
1839 | 316 |
|
317 |
(** General equational properties **) |
|
318 |
||
1913 | 319 |
goal thy "analz{} = {}"; |
1839 | 320 |
by (Step_tac 1); |
1913 | 321 |
be analz.induct 1; |
1839 | 322 |
by (ALLGOALS Fast_tac); |
1913 | 323 |
qed "analz_empty"; |
324 |
Addsimps [analz_empty]; |
|
1839 | 325 |
|
1913 | 326 |
(*Converse fails: we can analz more from the union than from the |
1839 | 327 |
separate parts, as a key in one might decrypt a message in the other*) |
1913 | 328 |
goal thy "analz(G) Un analz(H) <= analz(G Un H)"; |
329 |
by (REPEAT (ares_tac [Un_least, analz_mono, Un_upper1, Un_upper2] 1)); |
|
330 |
qed "analz_Un"; |
|
1839 | 331 |
|
1913 | 332 |
goal thy "insert X (analz H) <= analz(insert X H)"; |
333 |
by (fast_tac (!claset addEs [impOfSubs analz_mono]) 1); |
|
334 |
qed "analz_insert"; |
|
1839 | 335 |
|
336 |
(** Rewrite rules for pulling out atomic messages **) |
|
337 |
||
1913 | 338 |
goal thy "analz (insert (Agent agt) H) = insert (Agent agt) (analz H)"; |
339 |
by (rtac (analz_insert RSN (2, equalityI)) 1); |
|
1839 | 340 |
br subsetI 1; |
1913 | 341 |
be analz.induct 1; |
1839 | 342 |
(*Simplification breaks up equalities between messages; |
343 |
how to make it work for fast_tac??*) |
|
344 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
|
1913 | 345 |
qed "analz_insert_Agent"; |
1839 | 346 |
|
1913 | 347 |
goal thy "analz (insert (Nonce N) H) = insert (Nonce N) (analz H)"; |
348 |
by (rtac (analz_insert RSN (2, equalityI)) 1); |
|
1839 | 349 |
br subsetI 1; |
1913 | 350 |
be analz.induct 1; |
1839 | 351 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
1913 | 352 |
qed "analz_insert_Nonce"; |
1839 | 353 |
|
354 |
(*Can only pull out Keys if they are not needed to decrypt the rest*) |
|
355 |
goalw thy [keysFor_def] |
|
1913 | 356 |
"!!K. K ~: keysFor (analz H) ==> \ |
357 |
\ analz (insert (Key K) H) = insert (Key K) (analz H)"; |
|
358 |
by (rtac (analz_insert RSN (2, equalityI)) 1); |
|
1839 | 359 |
br subsetI 1; |
1913 | 360 |
be analz.induct 1; |
1839 | 361 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
1913 | 362 |
qed "analz_insert_Key"; |
1839 | 363 |
|
1913 | 364 |
goal thy "analz (insert {|X,Y|} H) = \ |
365 |
\ insert {|X,Y|} (analz (insert X (insert Y H)))"; |
|
1885 | 366 |
br equalityI 1; |
367 |
br subsetI 1; |
|
1913 | 368 |
be analz.induct 1; |
1885 | 369 |
by (Auto_tac()); |
1913 | 370 |
be analz.induct 1; |
371 |
by (ALLGOALS (deepen_tac (!claset addIs [analz.Fst, analz.Snd, analz.Decrypt]) 0)); |
|
372 |
qed "analz_insert_MPair"; |
|
1885 | 373 |
|
374 |
(*Can pull out enCrypted message if the Key is not known*) |
|
1913 | 375 |
goal thy "!!H. Key (invKey K) ~: analz H ==> \ |
376 |
\ analz (insert (Crypt X K) H) = \ |
|
377 |
\ insert (Crypt X K) (analz H)"; |
|
378 |
by (rtac (analz_insert RSN (2, equalityI)) 1); |
|
1839 | 379 |
br subsetI 1; |
1913 | 380 |
be analz.induct 1; |
1839 | 381 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
1913 | 382 |
qed "analz_insert_Crypt"; |
1839 | 383 |
|
1913 | 384 |
goal thy "!!H. Key (invKey K) : analz H ==> \ |
385 |
\ analz (insert (Crypt X K) H) <= \ |
|
386 |
\ insert (Crypt X K) (analz (insert X H))"; |
|
1839 | 387 |
br subsetI 1; |
1913 | 388 |
by (eres_inst_tac [("za","x")] analz.induct 1); |
1839 | 389 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
390 |
val lemma1 = result(); |
|
391 |
||
1913 | 392 |
goal thy "!!H. Key (invKey K) : analz H ==> \ |
393 |
\ insert (Crypt X K) (analz (insert X H)) <= \ |
|
394 |
\ analz (insert (Crypt X K) H)"; |
|
1839 | 395 |
by (Auto_tac()); |
1913 | 396 |
by (eres_inst_tac [("za","x")] analz.induct 1); |
1839 | 397 |
by (Auto_tac()); |
1913 | 398 |
by (best_tac (!claset addIs [subset_insertI RS analz_mono RS subsetD, |
399 |
analz.Decrypt]) 1); |
|
1839 | 400 |
val lemma2 = result(); |
401 |
||
1913 | 402 |
goal thy "!!H. Key (invKey K) : analz H ==> \ |
403 |
\ analz (insert (Crypt X K) H) = \ |
|
404 |
\ insert (Crypt X K) (analz (insert X H))"; |
|
1839 | 405 |
by (REPEAT (ares_tac [equalityI, lemma1, lemma2] 1)); |
1913 | 406 |
qed "analz_insert_Decrypt"; |
1839 | 407 |
|
1885 | 408 |
(*Case analysis: either the message is secure, or it is not! |
1946 | 409 |
Effective, but can cause subgoals to blow up! |
1885 | 410 |
Use with expand_if; apparently split_tac does not cope with patterns |
1913 | 411 |
such as "analz (insert (Crypt X' K) H)" *) |
412 |
goal thy "analz (insert (Crypt X' K) H) = \ |
|
413 |
\ (if (Key (invKey K) : analz H) then \ |
|
414 |
\ insert (Crypt X' K) (analz (insert X' H)) \ |
|
415 |
\ else insert (Crypt X' K) (analz H))"; |
|
416 |
by (excluded_middle_tac "Key (invKey K) : analz H " 1); |
|
417 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [analz_insert_Crypt, |
|
418 |
analz_insert_Decrypt]))); |
|
419 |
qed "analz_Crypt_if"; |
|
1885 | 420 |
|
1913 | 421 |
Addsimps [analz_insert_Agent, analz_insert_Nonce, |
422 |
analz_insert_Key, analz_insert_MPair, |
|
423 |
analz_Crypt_if]; |
|
1839 | 424 |
|
425 |
(*This rule supposes "for the sake of argument" that we have the key.*) |
|
1913 | 426 |
goal thy "analz (insert (Crypt X K) H) <= \ |
427 |
\ insert (Crypt X K) (analz (insert X H))"; |
|
1839 | 428 |
br subsetI 1; |
1913 | 429 |
be analz.induct 1; |
1839 | 430 |
by (Auto_tac()); |
1913 | 431 |
qed "analz_insert_Crypt_subset"; |
1839 | 432 |
|
433 |
||
2026
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
434 |
goal thy "analz (Key``N) = Key``N"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
435 |
by (Auto_tac()); |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
436 |
be analz.induct 1; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
437 |
by (Auto_tac()); |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
438 |
qed "analz_image_Key"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
439 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
440 |
Addsimps [analz_image_Key]; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
441 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
442 |
|
1839 | 443 |
(** Idempotence and transitivity **) |
444 |
||
1913 | 445 |
goal thy "!!H. X: analz (analz H) ==> X: analz H"; |
446 |
be analz.induct 1; |
|
1839 | 447 |
by (ALLGOALS Fast_tac); |
1913 | 448 |
qed "analz_analzE"; |
449 |
AddSEs [analz_analzE]; |
|
1839 | 450 |
|
1913 | 451 |
goal thy "analz (analz H) = analz H"; |
1839 | 452 |
by (Fast_tac 1); |
1913 | 453 |
qed "analz_idem"; |
454 |
Addsimps [analz_idem]; |
|
1839 | 455 |
|
1913 | 456 |
goal thy "!!H. [| X: analz G; G <= analz H |] ==> X: analz H"; |
457 |
by (dtac analz_mono 1); |
|
1839 | 458 |
by (Fast_tac 1); |
1913 | 459 |
qed "analz_trans"; |
1839 | 460 |
|
461 |
(*Cut; Lemma 2 of Lowe*) |
|
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
462 |
goal thy "!!H. [| Y: analz (insert X H); X: analz H |] ==> Y: analz H"; |
1913 | 463 |
be analz_trans 1; |
1839 | 464 |
by (Fast_tac 1); |
1913 | 465 |
qed "analz_cut"; |
1839 | 466 |
|
467 |
(*Cut can be proved easily by induction on |
|
1913 | 468 |
"!!H. Y: analz (insert X H) ==> X: analz H --> Y: analz H" |
1839 | 469 |
*) |
470 |
||
1885 | 471 |
|
1913 | 472 |
(** A congruence rule for "analz" **) |
1885 | 473 |
|
1913 | 474 |
goal thy "!!H. [| analz G <= analz G'; analz H <= analz H' \ |
475 |
\ |] ==> analz (G Un H) <= analz (G' Un H')"; |
|
1885 | 476 |
by (Step_tac 1); |
1913 | 477 |
be analz.induct 1; |
478 |
by (ALLGOALS (best_tac (!claset addIs [analz_mono RS subsetD]))); |
|
479 |
qed "analz_subset_cong"; |
|
1885 | 480 |
|
1913 | 481 |
goal thy "!!H. [| analz G = analz G'; analz H = analz H' \ |
482 |
\ |] ==> analz (G Un H) = analz (G' Un H')"; |
|
483 |
by (REPEAT_FIRST (ares_tac [equalityI, analz_subset_cong] |
|
1885 | 484 |
ORELSE' etac equalityE)); |
1913 | 485 |
qed "analz_cong"; |
1885 | 486 |
|
487 |
||
1913 | 488 |
goal thy "!!H. analz H = analz H' ==> analz(insert X H) = analz(insert X H')"; |
1885 | 489 |
by (asm_simp_tac (!simpset addsimps [insert_def] |
1913 | 490 |
setloop (rtac analz_cong)) 1); |
491 |
qed "analz_insert_cong"; |
|
1885 | 492 |
|
1913 | 493 |
(*If there are no pairs or encryptions then analz does nothing*) |
1839 | 494 |
goal thy "!!H. [| ALL X Y. {|X,Y|} ~: H; ALL X K. Crypt X K ~: H |] ==> \ |
1913 | 495 |
\ analz H = H"; |
1839 | 496 |
by (Step_tac 1); |
1913 | 497 |
be analz.induct 1; |
1839 | 498 |
by (ALLGOALS Fast_tac); |
1913 | 499 |
qed "analz_trivial"; |
1839 | 500 |
|
501 |
(*Helps to prove Fake cases*) |
|
1913 | 502 |
goal thy "!!X. X: analz (UN i. analz (H i)) ==> X: analz (UN i. H i)"; |
503 |
be analz.induct 1; |
|
504 |
by (ALLGOALS (fast_tac (!claset addEs [impOfSubs analz_mono]))); |
|
1839 | 505 |
val lemma = result(); |
506 |
||
1913 | 507 |
goal thy "analz (UN i. analz (H i)) = analz (UN i. H i)"; |
1839 | 508 |
by (fast_tac (!claset addIs [lemma] |
1913 | 509 |
addEs [impOfSubs analz_mono]) 1); |
510 |
qed "analz_UN_analz"; |
|
511 |
Addsimps [analz_UN_analz]; |
|
1839 | 512 |
|
513 |
||
1913 | 514 |
(**** Inductive relation "synth" ****) |
1839 | 515 |
|
1913 | 516 |
AddIs synth.intrs; |
1839 | 517 |
|
2011 | 518 |
(*Can only produce a nonce or key if it is already known, |
519 |
but can synth a pair or encryption from its components...*) |
|
520 |
val mk_cases = synth.mk_cases msg.simps; |
|
521 |
||
522 |
(*NO Agent_synth, as any Agent name can be synthd*) |
|
523 |
val Nonce_synth = mk_cases "Nonce n : synth H"; |
|
524 |
val Key_synth = mk_cases "Key K : synth H"; |
|
525 |
val MPair_synth = mk_cases "{|X,Y|} : synth H"; |
|
526 |
val Crypt_synth = mk_cases "Crypt X K : synth H"; |
|
527 |
||
528 |
AddSEs [Nonce_synth, Key_synth, MPair_synth, Crypt_synth]; |
|
529 |
||
1913 | 530 |
goal thy "H <= synth(H)"; |
1839 | 531 |
by (Fast_tac 1); |
1913 | 532 |
qed "synth_increasing"; |
1839 | 533 |
|
534 |
(*Monotonicity*) |
|
1913 | 535 |
goalw thy synth.defs "!!G H. G<=H ==> synth(G) <= synth(H)"; |
1839 | 536 |
by (rtac lfp_mono 1); |
537 |
by (REPEAT (ares_tac basic_monos 1)); |
|
1913 | 538 |
qed "synth_mono"; |
1839 | 539 |
|
540 |
(** Unions **) |
|
541 |
||
1913 | 542 |
(*Converse fails: we can synth more from the union than from the |
1839 | 543 |
separate parts, building a compound message using elements of each.*) |
1913 | 544 |
goal thy "synth(G) Un synth(H) <= synth(G Un H)"; |
545 |
by (REPEAT (ares_tac [Un_least, synth_mono, Un_upper1, Un_upper2] 1)); |
|
546 |
qed "synth_Un"; |
|
1839 | 547 |
|
1913 | 548 |
goal thy "insert X (synth H) <= synth(insert X H)"; |
549 |
by (fast_tac (!claset addEs [impOfSubs synth_mono]) 1); |
|
550 |
qed "synth_insert"; |
|
1885 | 551 |
|
1839 | 552 |
(** Idempotence and transitivity **) |
553 |
||
1913 | 554 |
goal thy "!!H. X: synth (synth H) ==> X: synth H"; |
555 |
be synth.induct 1; |
|
1839 | 556 |
by (ALLGOALS Fast_tac); |
1913 | 557 |
qed "synth_synthE"; |
558 |
AddSEs [synth_synthE]; |
|
1839 | 559 |
|
1913 | 560 |
goal thy "synth (synth H) = synth H"; |
1839 | 561 |
by (Fast_tac 1); |
1913 | 562 |
qed "synth_idem"; |
1839 | 563 |
|
1913 | 564 |
goal thy "!!H. [| X: synth G; G <= synth H |] ==> X: synth H"; |
565 |
by (dtac synth_mono 1); |
|
1839 | 566 |
by (Fast_tac 1); |
1913 | 567 |
qed "synth_trans"; |
1839 | 568 |
|
569 |
(*Cut; Lemma 2 of Lowe*) |
|
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
570 |
goal thy "!!H. [| Y: synth (insert X H); X: synth H |] ==> Y: synth H"; |
1913 | 571 |
be synth_trans 1; |
1839 | 572 |
by (Fast_tac 1); |
1913 | 573 |
qed "synth_cut"; |
1839 | 574 |
|
1946 | 575 |
goal thy "Agent A : synth H"; |
576 |
by (Fast_tac 1); |
|
577 |
qed "Agent_synth"; |
|
578 |
||
1913 | 579 |
goal thy "(Nonce N : synth H) = (Nonce N : H)"; |
1839 | 580 |
by (Fast_tac 1); |
1913 | 581 |
qed "Nonce_synth_eq"; |
1839 | 582 |
|
1913 | 583 |
goal thy "(Key K : synth H) = (Key K : H)"; |
1839 | 584 |
by (Fast_tac 1); |
1913 | 585 |
qed "Key_synth_eq"; |
1839 | 586 |
|
2011 | 587 |
goal thy "!!K. Key K ~: H ==> (Crypt X K : synth H) = (Crypt X K: H)"; |
588 |
by (Fast_tac 1); |
|
589 |
qed "Crypt_synth_eq"; |
|
590 |
||
591 |
Addsimps [Agent_synth, Nonce_synth_eq, Key_synth_eq, Crypt_synth_eq]; |
|
1839 | 592 |
|
593 |
||
594 |
goalw thy [keysFor_def] |
|
1913 | 595 |
"keysFor (synth H) = keysFor H Un invKey``{K. Key K : H}"; |
1839 | 596 |
by (Fast_tac 1); |
1913 | 597 |
qed "keysFor_synth"; |
598 |
Addsimps [keysFor_synth]; |
|
1839 | 599 |
|
600 |
||
1913 | 601 |
(*** Combinations of parts, analz and synth ***) |
1839 | 602 |
|
1913 | 603 |
goal thy "parts (synth H) = parts H Un synth H"; |
1839 | 604 |
br equalityI 1; |
605 |
br subsetI 1; |
|
606 |
be parts.induct 1; |
|
607 |
by (ALLGOALS |
|
1913 | 608 |
(best_tac (!claset addIs ((synth_increasing RS parts_mono RS subsetD) |
1839 | 609 |
::parts.intrs)))); |
1913 | 610 |
qed "parts_synth"; |
611 |
Addsimps [parts_synth]; |
|
1839 | 612 |
|
1913 | 613 |
goal thy "analz (synth H) = analz H Un synth H"; |
1839 | 614 |
br equalityI 1; |
615 |
br subsetI 1; |
|
1913 | 616 |
be analz.induct 1; |
1839 | 617 |
by (best_tac |
1913 | 618 |
(!claset addIs [synth_increasing RS analz_mono RS subsetD]) 5); |
1839 | 619 |
(*Strange that best_tac just can't hack this one...*) |
1913 | 620 |
by (ALLGOALS (deepen_tac (!claset addIs analz.intrs) 0)); |
621 |
qed "analz_synth"; |
|
622 |
Addsimps [analz_synth]; |
|
1839 | 623 |
|
624 |
(*Hard to prove; still needed now that there's only one Enemy?*) |
|
1913 | 625 |
goal thy "analz (UN i. synth (H i)) = \ |
626 |
\ analz (UN i. H i) Un (UN i. synth (H i))"; |
|
1839 | 627 |
br equalityI 1; |
628 |
br subsetI 1; |
|
1913 | 629 |
be analz.induct 1; |
1839 | 630 |
by (best_tac |
1913 | 631 |
(!claset addEs [impOfSubs synth_increasing, |
632 |
impOfSubs analz_mono]) 5); |
|
1839 | 633 |
by (Best_tac 1); |
1913 | 634 |
by (deepen_tac (!claset addIs [analz.Fst]) 0 1); |
635 |
by (deepen_tac (!claset addIs [analz.Snd]) 0 1); |
|
636 |
by (deepen_tac (!claset addSEs [analz.Decrypt] |
|
637 |
addIs [analz.Decrypt]) 0 1); |
|
638 |
qed "analz_UN1_synth"; |
|
639 |
Addsimps [analz_UN1_synth]; |
|
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
640 |
|
1946 | 641 |
|
642 |
(** For reasoning about the Fake rule in traces **) |
|
643 |
||
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
644 |
goal thy "!!Y. X: G ==> parts(insert X H) <= parts G Un parts H"; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
645 |
br ([parts_mono, parts_Un_subset2] MRS subset_trans) 1; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
646 |
by (Fast_tac 1); |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
647 |
qed "parts_insert_subset_Un"; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
648 |
|
1946 | 649 |
(*More specifically for Fake*) |
650 |
goal thy "!!H. X: synth (analz G) ==> \ |
|
651 |
\ parts (insert X H) <= synth (analz G) Un parts G Un parts H"; |
|
652 |
bd parts_insert_subset_Un 1; |
|
653 |
by (Full_simp_tac 1); |
|
654 |
by (Deepen_tac 0 1); |
|
655 |
qed "Fake_parts_insert"; |
|
656 |
||
657 |
goal thy "!!H. [| X: synth (analz G); G <= H |] ==> \ |
|
658 |
\ analz (insert X H) <= synth (analz H) Un analz H"; |
|
659 |
br subsetI 1; |
|
660 |
by (subgoal_tac "x : analz (synth (analz H))" 1); |
|
661 |
by (best_tac (!claset addIs [impOfSubs (analz_mono RS synth_mono)] |
|
662 |
addSEs [impOfSubs analz_mono]) 2); |
|
663 |
by (Full_simp_tac 1); |
|
664 |
by (Fast_tac 1); |
|
665 |
qed "Fake_analz_insert"; |
|
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
666 |
|
2011 | 667 |
goal thy "(X: analz H & X: parts H) = (X: analz H)"; |
668 |
by (fast_tac (!claset addDs [impOfSubs analz_subset_parts]) 1); |
|
669 |
val analz_conj_parts = result(); |
|
670 |
||
671 |
goal thy "(X: analz H | X: parts H) = (X: parts H)"; |
|
672 |
by (fast_tac (!claset addDs [impOfSubs analz_subset_parts]) 1); |
|
673 |
val analz_disj_parts = result(); |
|
674 |
||
675 |
AddIffs [analz_conj_parts, analz_disj_parts]; |
|
676 |
||
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
677 |
(*Without this equation, other rules for synth and analz would yield |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
678 |
redundant cases*) |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
679 |
goal thy "({|X,Y|} : synth (analz H)) = \ |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
680 |
\ (X : synth (analz H) & Y : synth (analz H))"; |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
681 |
by (Fast_tac 1); |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
682 |
qed "MPair_synth_analz"; |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
683 |
|
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
684 |
AddIffs [MPair_synth_analz]; |
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
685 |
|
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
686 |
|
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
687 |
(*We do NOT want Crypt... messages broken up in protocols!!*) |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
688 |
Delrules partsEs; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
689 |