author | wenzelm |
Tue, 27 May 1997 15:45:07 +0200 | |
changeset 3362 | 0b268cff9344 |
parent 3121 | cbb6c0c1c58a |
child 3431 | 05b397185e1d |
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 |
||
2373 | 12 |
AddIffs (msg.inject); |
1839 | 13 |
|
14 |
(** Inverse of keys **) |
|
15 |
||
16 |
goal thy "!!K K'. (invKey K = invKey K') = (K=K')"; |
|
17 |
by (Step_tac 1); |
|
2032 | 18 |
by (rtac box_equals 1); |
1839 | 19 |
by (REPEAT (rtac invKey 2)); |
20 |
by (Asm_simp_tac 1); |
|
21 |
qed "invKey_eq"; |
|
22 |
||
23 |
Addsimps [invKey, invKey_eq]; |
|
24 |
||
25 |
||
26 |
(**** keysFor operator ****) |
|
27 |
||
28 |
goalw thy [keysFor_def] "keysFor {} = {}"; |
|
2891 | 29 |
by (Blast_tac 1); |
1839 | 30 |
qed "keysFor_empty"; |
31 |
||
32 |
goalw thy [keysFor_def] "keysFor (H Un H') = keysFor H Un keysFor H'"; |
|
2891 | 33 |
by (Blast_tac 1); |
1839 | 34 |
qed "keysFor_Un"; |
35 |
||
36 |
goalw thy [keysFor_def] "keysFor (UN i. H i) = (UN i. keysFor (H i))"; |
|
2891 | 37 |
by (Blast_tac 1); |
3121
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
38 |
qed "keysFor_UN1"; |
1839 | 39 |
|
40 |
(*Monotonicity*) |
|
41 |
goalw thy [keysFor_def] "!!G H. G<=H ==> keysFor(G) <= keysFor(H)"; |
|
2891 | 42 |
by (Blast_tac 1); |
1839 | 43 |
qed "keysFor_mono"; |
44 |
||
45 |
goalw thy [keysFor_def] "keysFor (insert (Agent A) H) = keysFor H"; |
|
3102 | 46 |
by (Blast_tac 1); |
1839 | 47 |
qed "keysFor_insert_Agent"; |
48 |
||
49 |
goalw thy [keysFor_def] "keysFor (insert (Nonce N) H) = keysFor H"; |
|
3102 | 50 |
by (Blast_tac 1); |
1839 | 51 |
qed "keysFor_insert_Nonce"; |
52 |
||
53 |
goalw thy [keysFor_def] "keysFor (insert (Key K) H) = keysFor H"; |
|
3102 | 54 |
by (Blast_tac 1); |
1839 | 55 |
qed "keysFor_insert_Key"; |
56 |
||
2373 | 57 |
goalw thy [keysFor_def] "keysFor (insert (Hash X) H) = keysFor H"; |
3102 | 58 |
by (Blast_tac 1); |
2373 | 59 |
qed "keysFor_insert_Hash"; |
60 |
||
1839 | 61 |
goalw thy [keysFor_def] "keysFor (insert {|X,Y|} H) = keysFor H"; |
3102 | 62 |
by (Blast_tac 1); |
1839 | 63 |
qed "keysFor_insert_MPair"; |
64 |
||
65 |
goalw thy [keysFor_def] |
|
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
66 |
"keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)"; |
1839 | 67 |
by (Auto_tac()); |
68 |
qed "keysFor_insert_Crypt"; |
|
69 |
||
3121
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
70 |
Addsimps [keysFor_empty, keysFor_Un, keysFor_UN1, |
2373 | 71 |
keysFor_insert_Agent, keysFor_insert_Nonce, keysFor_insert_Key, |
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
72 |
keysFor_insert_Hash, keysFor_insert_MPair, keysFor_insert_Crypt]; |
3121
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
73 |
AddSEs [keysFor_Un RS equalityD1 RS subsetD RS UnE, |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
74 |
keysFor_UN1 RS equalityD1 RS subsetD RS UN1_E]; |
1839 | 75 |
|
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
76 |
goalw thy [keysFor_def] "!!H. Crypt K X : H ==> invKey K : keysFor H"; |
2891 | 77 |
by (Blast_tac 1); |
2068 | 78 |
qed "Crypt_imp_invKey_keysFor"; |
79 |
||
1839 | 80 |
|
81 |
(**** Inductive relation "parts" ****) |
|
82 |
||
83 |
val major::prems = |
|
84 |
goal thy "[| {|X,Y|} : parts H; \ |
|
85 |
\ [| X : parts H; Y : parts H |] ==> P \ |
|
86 |
\ |] ==> P"; |
|
87 |
by (cut_facts_tac [major] 1); |
|
2032 | 88 |
by (resolve_tac prems 1); |
1839 | 89 |
by (REPEAT (eresolve_tac [asm_rl, parts.Fst, parts.Snd] 1)); |
90 |
qed "MPair_parts"; |
|
91 |
||
92 |
AddIs [parts.Inj]; |
|
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
93 |
|
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
94 |
val partsEs = [MPair_parts, make_elim parts.Body]; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
95 |
|
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
96 |
AddSEs partsEs; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
97 |
(*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
|
98 |
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
|
99 |
proofs concern only atomic messages.*) |
1839 | 100 |
|
101 |
goal thy "H <= parts(H)"; |
|
2891 | 102 |
by (Blast_tac 1); |
1839 | 103 |
qed "parts_increasing"; |
104 |
||
105 |
(*Monotonicity*) |
|
106 |
goalw thy parts.defs "!!G H. G<=H ==> parts(G) <= parts(H)"; |
|
107 |
by (rtac lfp_mono 1); |
|
108 |
by (REPEAT (ares_tac basic_monos 1)); |
|
109 |
qed "parts_mono"; |
|
110 |
||
2373 | 111 |
val parts_insertI = impOfSubs (subset_insertI RS parts_mono); |
112 |
||
1839 | 113 |
goal thy "parts{} = {}"; |
114 |
by (Step_tac 1); |
|
2032 | 115 |
by (etac parts.induct 1); |
2891 | 116 |
by (ALLGOALS Blast_tac); |
1839 | 117 |
qed "parts_empty"; |
118 |
Addsimps [parts_empty]; |
|
119 |
||
120 |
goal thy "!!X. X: parts{} ==> P"; |
|
121 |
by (Asm_full_simp_tac 1); |
|
122 |
qed "parts_emptyE"; |
|
123 |
AddSEs [parts_emptyE]; |
|
124 |
||
1893 | 125 |
(*WARNING: loops if H = {Y}, therefore must not be repeated!*) |
126 |
goal thy "!!H. X: parts H ==> EX Y:H. X: parts {Y}"; |
|
2032 | 127 |
by (etac parts.induct 1); |
2891 | 128 |
by (ALLGOALS Blast_tac); |
1893 | 129 |
qed "parts_singleton"; |
130 |
||
1839 | 131 |
|
132 |
(** Unions **) |
|
133 |
||
134 |
goal thy "parts(G) Un parts(H) <= parts(G Un H)"; |
|
135 |
by (REPEAT (ares_tac [Un_least, parts_mono, Un_upper1, Un_upper2] 1)); |
|
136 |
val parts_Un_subset1 = result(); |
|
137 |
||
138 |
goal thy "parts(G Un H) <= parts(G) Un parts(H)"; |
|
2032 | 139 |
by (rtac subsetI 1); |
140 |
by (etac parts.induct 1); |
|
2891 | 141 |
by (ALLGOALS Blast_tac); |
1839 | 142 |
val parts_Un_subset2 = result(); |
143 |
||
144 |
goal thy "parts(G Un H) = parts(G) Un parts(H)"; |
|
145 |
by (REPEAT (ares_tac [equalityI, parts_Un_subset1, parts_Un_subset2] 1)); |
|
146 |
qed "parts_Un"; |
|
147 |
||
2011 | 148 |
goal thy "parts (insert X H) = parts {X} Un parts H"; |
1852 | 149 |
by (stac (read_instantiate [("A","H")] insert_is_Un) 1); |
2011 | 150 |
by (simp_tac (HOL_ss addsimps [parts_Un]) 1); |
151 |
qed "parts_insert"; |
|
152 |
||
153 |
(*TWO inserts to avoid looping. This rewrite is better than nothing. |
|
154 |
Not suitable for Addsimps: its behaviour can be strange.*) |
|
155 |
goal thy "parts (insert X (insert Y H)) = parts {X} Un parts {Y} Un parts H"; |
|
156 |
by (simp_tac (!simpset addsimps [Un_assoc]) 1); |
|
157 |
by (simp_tac (!simpset addsimps [parts_insert RS sym]) 1); |
|
1852 | 158 |
qed "parts_insert2"; |
159 |
||
1839 | 160 |
goal thy "(UN x:A. parts(H x)) <= parts(UN x:A. H x)"; |
161 |
by (REPEAT (ares_tac [UN_least, parts_mono, UN_upper] 1)); |
|
162 |
val parts_UN_subset1 = result(); |
|
163 |
||
164 |
goal thy "parts(UN x:A. H x) <= (UN x:A. parts(H x))"; |
|
2032 | 165 |
by (rtac subsetI 1); |
166 |
by (etac parts.induct 1); |
|
2891 | 167 |
by (ALLGOALS Blast_tac); |
1839 | 168 |
val parts_UN_subset2 = result(); |
169 |
||
170 |
goal thy "parts(UN x:A. H x) = (UN x:A. parts(H x))"; |
|
171 |
by (REPEAT (ares_tac [equalityI, parts_UN_subset1, parts_UN_subset2] 1)); |
|
172 |
qed "parts_UN"; |
|
173 |
||
174 |
goal thy "parts(UN x. H x) = (UN x. parts(H x))"; |
|
175 |
by (simp_tac (!simpset addsimps [UNION1_def, parts_UN]) 1); |
|
176 |
qed "parts_UN1"; |
|
177 |
||
3121
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
178 |
(*Added to simplify arguments to parts, analz and synth. |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
179 |
NOTE: the UN versions are no longer used!*) |
1839 | 180 |
Addsimps [parts_Un, parts_UN, parts_UN1]; |
3121
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
181 |
AddSEs [parts_Un RS equalityD1 RS subsetD RS UnE, |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
182 |
parts_UN RS equalityD1 RS subsetD RS UN_E, |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
183 |
parts_UN1 RS equalityD1 RS subsetD RS UN1_E]; |
1839 | 184 |
|
185 |
goal thy "insert X (parts H) <= parts(insert X H)"; |
|
2922 | 186 |
by (blast_tac (!claset addIs [impOfSubs parts_mono]) 1); |
1839 | 187 |
qed "parts_insert_subset"; |
188 |
||
189 |
(** Idempotence and transitivity **) |
|
190 |
||
191 |
goal thy "!!H. X: parts (parts H) ==> X: parts H"; |
|
2032 | 192 |
by (etac parts.induct 1); |
2891 | 193 |
by (ALLGOALS Blast_tac); |
2922 | 194 |
qed "parts_partsD"; |
195 |
AddSDs [parts_partsD]; |
|
1839 | 196 |
|
197 |
goal thy "parts (parts H) = parts H"; |
|
2891 | 198 |
by (Blast_tac 1); |
1839 | 199 |
qed "parts_idem"; |
200 |
Addsimps [parts_idem]; |
|
201 |
||
202 |
goal thy "!!H. [| X: parts G; G <= parts H |] ==> X: parts H"; |
|
203 |
by (dtac parts_mono 1); |
|
2891 | 204 |
by (Blast_tac 1); |
1839 | 205 |
qed "parts_trans"; |
206 |
||
207 |
(*Cut*) |
|
2373 | 208 |
goal thy "!!H. [| Y: parts (insert X G); X: parts H |] \ |
209 |
\ ==> Y: parts (G Un H)"; |
|
2032 | 210 |
by (etac parts_trans 1); |
2373 | 211 |
by (Auto_tac()); |
1839 | 212 |
qed "parts_cut"; |
213 |
||
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
214 |
goal thy "!!H. X: parts H ==> parts (insert X H) = parts H"; |
2373 | 215 |
by (fast_tac (!claset addSDs [parts_cut] |
216 |
addIs [parts_insertI] |
|
217 |
addss (!simpset)) 1); |
|
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
218 |
qed "parts_cut_eq"; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
219 |
|
2028
738bb98d65ec
Last working version prior to addition of "lost" component
paulson
parents:
2026
diff
changeset
|
220 |
Addsimps [parts_cut_eq]; |
738bb98d65ec
Last working version prior to addition of "lost" component
paulson
parents:
2026
diff
changeset
|
221 |
|
1839 | 222 |
|
223 |
(** Rewrite rules for pulling out atomic messages **) |
|
224 |
||
2373 | 225 |
fun parts_tac i = |
226 |
EVERY [rtac ([subsetI, parts_insert_subset] MRS equalityI) i, |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
227 |
etac parts.induct i, |
3102 | 228 |
REPEAT (Blast_tac i)]; |
2373 | 229 |
|
1839 | 230 |
goal thy "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)"; |
2373 | 231 |
by (parts_tac 1); |
1839 | 232 |
qed "parts_insert_Agent"; |
233 |
||
234 |
goal thy "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)"; |
|
2373 | 235 |
by (parts_tac 1); |
1839 | 236 |
qed "parts_insert_Nonce"; |
237 |
||
238 |
goal thy "parts (insert (Key K) H) = insert (Key K) (parts H)"; |
|
2373 | 239 |
by (parts_tac 1); |
1839 | 240 |
qed "parts_insert_Key"; |
241 |
||
2373 | 242 |
goal thy "parts (insert (Hash X) H) = insert (Hash X) (parts H)"; |
243 |
by (parts_tac 1); |
|
244 |
qed "parts_insert_Hash"; |
|
245 |
||
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
246 |
goal thy "parts (insert (Crypt K X) H) = \ |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
247 |
\ insert (Crypt K X) (parts (insert X H))"; |
2032 | 248 |
by (rtac equalityI 1); |
249 |
by (rtac subsetI 1); |
|
250 |
by (etac parts.induct 1); |
|
1839 | 251 |
by (Auto_tac()); |
2032 | 252 |
by (etac parts.induct 1); |
2922 | 253 |
by (ALLGOALS (blast_tac (!claset addIs [parts.Body]))); |
1839 | 254 |
qed "parts_insert_Crypt"; |
255 |
||
256 |
goal thy "parts (insert {|X,Y|} H) = \ |
|
257 |
\ insert {|X,Y|} (parts (insert X (insert Y H)))"; |
|
2032 | 258 |
by (rtac equalityI 1); |
259 |
by (rtac subsetI 1); |
|
260 |
by (etac parts.induct 1); |
|
1839 | 261 |
by (Auto_tac()); |
2032 | 262 |
by (etac parts.induct 1); |
2922 | 263 |
by (ALLGOALS (blast_tac (!claset addIs [parts.Fst, parts.Snd]))); |
1839 | 264 |
qed "parts_insert_MPair"; |
265 |
||
2373 | 266 |
Addsimps [parts_insert_Agent, parts_insert_Nonce, parts_insert_Key, |
267 |
parts_insert_Hash, parts_insert_Crypt, parts_insert_MPair]; |
|
1839 | 268 |
|
269 |
||
2026
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
270 |
goal thy "parts (Key``N) = Key``N"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
271 |
by (Auto_tac()); |
2032 | 272 |
by (etac parts.induct 1); |
2026
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
273 |
by (Auto_tac()); |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
274 |
qed "parts_image_Key"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
275 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
276 |
Addsimps [parts_image_Key]; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
277 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
278 |
|
1913 | 279 |
(**** Inductive relation "analz" ****) |
1839 | 280 |
|
281 |
val major::prems = |
|
1913 | 282 |
goal thy "[| {|X,Y|} : analz H; \ |
283 |
\ [| X : analz H; Y : analz H |] ==> P \ |
|
1839 | 284 |
\ |] ==> P"; |
285 |
by (cut_facts_tac [major] 1); |
|
2032 | 286 |
by (resolve_tac prems 1); |
1913 | 287 |
by (REPEAT (eresolve_tac [asm_rl, analz.Fst, analz.Snd] 1)); |
288 |
qed "MPair_analz"; |
|
1839 | 289 |
|
1913 | 290 |
AddIs [analz.Inj]; |
2011 | 291 |
AddSEs [MPair_analz]; (*Perhaps it should NOT be deemed safe!*) |
1913 | 292 |
AddDs [analz.Decrypt]; |
1839 | 293 |
|
1913 | 294 |
Addsimps [analz.Inj]; |
1885 | 295 |
|
1913 | 296 |
goal thy "H <= analz(H)"; |
2891 | 297 |
by (Blast_tac 1); |
1913 | 298 |
qed "analz_increasing"; |
1839 | 299 |
|
1913 | 300 |
goal thy "analz H <= parts H"; |
1839 | 301 |
by (rtac subsetI 1); |
2032 | 302 |
by (etac analz.induct 1); |
2891 | 303 |
by (ALLGOALS Blast_tac); |
1913 | 304 |
qed "analz_subset_parts"; |
1839 | 305 |
|
1913 | 306 |
bind_thm ("not_parts_not_analz", analz_subset_parts RS contra_subsetD); |
1839 | 307 |
|
308 |
||
1913 | 309 |
goal thy "parts (analz H) = parts H"; |
2032 | 310 |
by (rtac equalityI 1); |
311 |
by (rtac (analz_subset_parts RS parts_mono RS subset_trans) 1); |
|
1839 | 312 |
by (Simp_tac 1); |
2891 | 313 |
by (blast_tac (!claset addIs [analz_increasing RS parts_mono RS subsetD]) 1); |
1913 | 314 |
qed "parts_analz"; |
315 |
Addsimps [parts_analz]; |
|
1839 | 316 |
|
1913 | 317 |
goal thy "analz (parts H) = parts H"; |
1885 | 318 |
by (Auto_tac()); |
2032 | 319 |
by (etac analz.induct 1); |
1885 | 320 |
by (Auto_tac()); |
1913 | 321 |
qed "analz_parts"; |
322 |
Addsimps [analz_parts]; |
|
1885 | 323 |
|
1839 | 324 |
(*Monotonicity; Lemma 1 of Lowe*) |
1913 | 325 |
goalw thy analz.defs "!!G H. G<=H ==> analz(G) <= analz(H)"; |
1839 | 326 |
by (rtac lfp_mono 1); |
327 |
by (REPEAT (ares_tac basic_monos 1)); |
|
1913 | 328 |
qed "analz_mono"; |
1839 | 329 |
|
2373 | 330 |
val analz_insertI = impOfSubs (subset_insertI RS analz_mono); |
331 |
||
1839 | 332 |
(** General equational properties **) |
333 |
||
1913 | 334 |
goal thy "analz{} = {}"; |
1839 | 335 |
by (Step_tac 1); |
2032 | 336 |
by (etac analz.induct 1); |
2891 | 337 |
by (ALLGOALS Blast_tac); |
1913 | 338 |
qed "analz_empty"; |
339 |
Addsimps [analz_empty]; |
|
1839 | 340 |
|
1913 | 341 |
(*Converse fails: we can analz more from the union than from the |
1839 | 342 |
separate parts, as a key in one might decrypt a message in the other*) |
1913 | 343 |
goal thy "analz(G) Un analz(H) <= analz(G Un H)"; |
344 |
by (REPEAT (ares_tac [Un_least, analz_mono, Un_upper1, Un_upper2] 1)); |
|
345 |
qed "analz_Un"; |
|
1839 | 346 |
|
1913 | 347 |
goal thy "insert X (analz H) <= analz(insert X H)"; |
2922 | 348 |
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 1); |
1913 | 349 |
qed "analz_insert"; |
1839 | 350 |
|
351 |
(** Rewrite rules for pulling out atomic messages **) |
|
352 |
||
2373 | 353 |
fun analz_tac i = |
354 |
EVERY [rtac ([subsetI, analz_insert] MRS equalityI) i, |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
355 |
etac analz.induct i, |
3102 | 356 |
REPEAT (Blast_tac i)]; |
2373 | 357 |
|
1913 | 358 |
goal thy "analz (insert (Agent agt) H) = insert (Agent agt) (analz H)"; |
2373 | 359 |
by (analz_tac 1); |
1913 | 360 |
qed "analz_insert_Agent"; |
1839 | 361 |
|
1913 | 362 |
goal thy "analz (insert (Nonce N) H) = insert (Nonce N) (analz H)"; |
2373 | 363 |
by (analz_tac 1); |
1913 | 364 |
qed "analz_insert_Nonce"; |
1839 | 365 |
|
2373 | 366 |
goal thy "analz (insert (Hash X) H) = insert (Hash X) (analz H)"; |
367 |
by (analz_tac 1); |
|
368 |
qed "analz_insert_Hash"; |
|
369 |
||
1839 | 370 |
(*Can only pull out Keys if they are not needed to decrypt the rest*) |
371 |
goalw thy [keysFor_def] |
|
1913 | 372 |
"!!K. K ~: keysFor (analz H) ==> \ |
373 |
\ analz (insert (Key K) H) = insert (Key K) (analz H)"; |
|
2373 | 374 |
by (analz_tac 1); |
1913 | 375 |
qed "analz_insert_Key"; |
1839 | 376 |
|
1913 | 377 |
goal thy "analz (insert {|X,Y|} H) = \ |
378 |
\ insert {|X,Y|} (analz (insert X (insert Y H)))"; |
|
2032 | 379 |
by (rtac equalityI 1); |
380 |
by (rtac subsetI 1); |
|
381 |
by (etac analz.induct 1); |
|
1885 | 382 |
by (Auto_tac()); |
2032 | 383 |
by (etac analz.induct 1); |
2922 | 384 |
by (ALLGOALS (blast_tac (!claset addIs [analz.Fst, analz.Snd]))); |
1913 | 385 |
qed "analz_insert_MPair"; |
1885 | 386 |
|
387 |
(*Can pull out enCrypted message if the Key is not known*) |
|
1913 | 388 |
goal thy "!!H. Key (invKey K) ~: analz H ==> \ |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
389 |
\ analz (insert (Crypt K X) H) = \ |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
390 |
\ insert (Crypt K X) (analz H)"; |
2373 | 391 |
by (analz_tac 1); |
1913 | 392 |
qed "analz_insert_Crypt"; |
1839 | 393 |
|
1913 | 394 |
goal thy "!!H. Key (invKey K) : analz H ==> \ |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
395 |
\ analz (insert (Crypt K X) H) <= \ |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
396 |
\ insert (Crypt K X) (analz (insert X H))"; |
2032 | 397 |
by (rtac subsetI 1); |
1913 | 398 |
by (eres_inst_tac [("za","x")] analz.induct 1); |
3102 | 399 |
by (ALLGOALS (Blast_tac)); |
1839 | 400 |
val lemma1 = result(); |
401 |
||
1913 | 402 |
goal thy "!!H. Key (invKey K) : analz H ==> \ |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
403 |
\ insert (Crypt K X) (analz (insert X H)) <= \ |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
404 |
\ analz (insert (Crypt K X) H)"; |
1839 | 405 |
by (Auto_tac()); |
1913 | 406 |
by (eres_inst_tac [("za","x")] analz.induct 1); |
1839 | 407 |
by (Auto_tac()); |
2922 | 408 |
by (blast_tac (!claset addIs [subset_insertI RS analz_mono RS subsetD, |
2032 | 409 |
analz.Decrypt]) 1); |
1839 | 410 |
val lemma2 = result(); |
411 |
||
1913 | 412 |
goal thy "!!H. Key (invKey K) : analz H ==> \ |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
413 |
\ analz (insert (Crypt K X) H) = \ |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
414 |
\ insert (Crypt K X) (analz (insert X H))"; |
1839 | 415 |
by (REPEAT (ares_tac [equalityI, lemma1, lemma2] 1)); |
1913 | 416 |
qed "analz_insert_Decrypt"; |
1839 | 417 |
|
1885 | 418 |
(*Case analysis: either the message is secure, or it is not! |
1946 | 419 |
Effective, but can cause subgoals to blow up! |
1885 | 420 |
Use with expand_if; apparently split_tac does not cope with patterns |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
421 |
such as "analz (insert (Crypt K X) H)" *) |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
422 |
goal thy "analz (insert (Crypt K X) H) = \ |
2154 | 423 |
\ (if (Key (invKey K) : analz H) \ |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
424 |
\ then insert (Crypt K X) (analz (insert X H)) \ |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
425 |
\ else insert (Crypt K X) (analz H))"; |
2102 | 426 |
by (case_tac "Key (invKey K) : analz H " 1); |
1913 | 427 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [analz_insert_Crypt, |
2032 | 428 |
analz_insert_Decrypt]))); |
1913 | 429 |
qed "analz_Crypt_if"; |
1885 | 430 |
|
2373 | 431 |
Addsimps [analz_insert_Agent, analz_insert_Nonce, analz_insert_Key, |
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
432 |
analz_insert_Hash, analz_insert_MPair, analz_Crypt_if]; |
1839 | 433 |
|
434 |
(*This rule supposes "for the sake of argument" that we have the key.*) |
|
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
435 |
goal thy "analz (insert (Crypt K X) H) <= \ |
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
436 |
\ insert (Crypt K X) (analz (insert X H))"; |
2032 | 437 |
by (rtac subsetI 1); |
438 |
by (etac analz.induct 1); |
|
1839 | 439 |
by (Auto_tac()); |
1913 | 440 |
qed "analz_insert_Crypt_subset"; |
1839 | 441 |
|
442 |
||
2026
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
443 |
goal thy "analz (Key``N) = Key``N"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
444 |
by (Auto_tac()); |
2032 | 445 |
by (etac analz.induct 1); |
2026
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
446 |
by (Auto_tac()); |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
447 |
qed "analz_image_Key"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
448 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
449 |
Addsimps [analz_image_Key]; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
450 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2011
diff
changeset
|
451 |
|
1839 | 452 |
(** Idempotence and transitivity **) |
453 |
||
1913 | 454 |
goal thy "!!H. X: analz (analz H) ==> X: analz H"; |
2032 | 455 |
by (etac analz.induct 1); |
2891 | 456 |
by (ALLGOALS Blast_tac); |
2922 | 457 |
qed "analz_analzD"; |
458 |
AddSDs [analz_analzD]; |
|
1839 | 459 |
|
1913 | 460 |
goal thy "analz (analz H) = analz H"; |
2891 | 461 |
by (Blast_tac 1); |
1913 | 462 |
qed "analz_idem"; |
463 |
Addsimps [analz_idem]; |
|
1839 | 464 |
|
1913 | 465 |
goal thy "!!H. [| X: analz G; G <= analz H |] ==> X: analz H"; |
466 |
by (dtac analz_mono 1); |
|
2891 | 467 |
by (Blast_tac 1); |
1913 | 468 |
qed "analz_trans"; |
1839 | 469 |
|
470 |
(*Cut; Lemma 2 of Lowe*) |
|
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
471 |
goal thy "!!H. [| Y: analz (insert X H); X: analz H |] ==> Y: analz H"; |
2032 | 472 |
by (etac analz_trans 1); |
2891 | 473 |
by (Blast_tac 1); |
1913 | 474 |
qed "analz_cut"; |
1839 | 475 |
|
476 |
(*Cut can be proved easily by induction on |
|
1913 | 477 |
"!!H. Y: analz (insert X H) ==> X: analz H --> Y: analz H" |
1839 | 478 |
*) |
479 |
||
1885 | 480 |
|
1913 | 481 |
(** A congruence rule for "analz" **) |
1885 | 482 |
|
1913 | 483 |
goal thy "!!H. [| analz G <= analz G'; analz H <= analz H' \ |
484 |
\ |] ==> analz (G Un H) <= analz (G' Un H')"; |
|
1885 | 485 |
by (Step_tac 1); |
2032 | 486 |
by (etac analz.induct 1); |
1913 | 487 |
by (ALLGOALS (best_tac (!claset addIs [analz_mono RS subsetD]))); |
488 |
qed "analz_subset_cong"; |
|
1885 | 489 |
|
1913 | 490 |
goal thy "!!H. [| analz G = analz G'; analz H = analz H' \ |
491 |
\ |] ==> analz (G Un H) = analz (G' Un H')"; |
|
492 |
by (REPEAT_FIRST (ares_tac [equalityI, analz_subset_cong] |
|
2032 | 493 |
ORELSE' etac equalityE)); |
1913 | 494 |
qed "analz_cong"; |
1885 | 495 |
|
496 |
||
1913 | 497 |
goal thy "!!H. analz H = analz H' ==> analz(insert X H) = analz(insert X H')"; |
1885 | 498 |
by (asm_simp_tac (!simpset addsimps [insert_def] |
2032 | 499 |
setloop (rtac analz_cong)) 1); |
1913 | 500 |
qed "analz_insert_cong"; |
1885 | 501 |
|
1913 | 502 |
(*If there are no pairs or encryptions then analz does nothing*) |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
503 |
goal thy "!!H. [| ALL X Y. {|X,Y|} ~: H; ALL X K. Crypt K X ~: H |] ==> \ |
1913 | 504 |
\ analz H = H"; |
1839 | 505 |
by (Step_tac 1); |
2032 | 506 |
by (etac analz.induct 1); |
2891 | 507 |
by (ALLGOALS Blast_tac); |
1913 | 508 |
qed "analz_trivial"; |
1839 | 509 |
|
510 |
(*Helps to prove Fake cases*) |
|
1913 | 511 |
goal thy "!!X. X: analz (UN i. analz (H i)) ==> X: analz (UN i. H i)"; |
2032 | 512 |
by (etac analz.induct 1); |
2922 | 513 |
by (ALLGOALS (blast_tac (!claset addIs [impOfSubs analz_mono]))); |
1839 | 514 |
val lemma = result(); |
515 |
||
1913 | 516 |
goal thy "analz (UN i. analz (H i)) = analz (UN i. H i)"; |
2922 | 517 |
by (blast_tac (!claset addIs [lemma, impOfSubs analz_mono]) 1); |
1913 | 518 |
qed "analz_UN_analz"; |
519 |
Addsimps [analz_UN_analz]; |
|
1839 | 520 |
|
521 |
||
1913 | 522 |
(**** Inductive relation "synth" ****) |
1839 | 523 |
|
1913 | 524 |
AddIs synth.intrs; |
1839 | 525 |
|
2011 | 526 |
(*Can only produce a nonce or key if it is already known, |
527 |
but can synth a pair or encryption from its components...*) |
|
528 |
val mk_cases = synth.mk_cases msg.simps; |
|
529 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
530 |
(*NO Agent_synth, as any Agent name can be synthesized*) |
2011 | 531 |
val Nonce_synth = mk_cases "Nonce n : synth H"; |
532 |
val Key_synth = mk_cases "Key K : synth H"; |
|
2373 | 533 |
val Hash_synth = mk_cases "Hash X : synth H"; |
2011 | 534 |
val MPair_synth = mk_cases "{|X,Y|} : synth H"; |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
535 |
val Crypt_synth = mk_cases "Crypt K X : synth H"; |
2011 | 536 |
|
2373 | 537 |
AddSEs [Nonce_synth, Key_synth, Hash_synth, MPair_synth, Crypt_synth]; |
2011 | 538 |
|
1913 | 539 |
goal thy "H <= synth(H)"; |
2891 | 540 |
by (Blast_tac 1); |
1913 | 541 |
qed "synth_increasing"; |
1839 | 542 |
|
543 |
(*Monotonicity*) |
|
1913 | 544 |
goalw thy synth.defs "!!G H. G<=H ==> synth(G) <= synth(H)"; |
1839 | 545 |
by (rtac lfp_mono 1); |
546 |
by (REPEAT (ares_tac basic_monos 1)); |
|
1913 | 547 |
qed "synth_mono"; |
1839 | 548 |
|
549 |
(** Unions **) |
|
550 |
||
1913 | 551 |
(*Converse fails: we can synth more from the union than from the |
1839 | 552 |
separate parts, building a compound message using elements of each.*) |
1913 | 553 |
goal thy "synth(G) Un synth(H) <= synth(G Un H)"; |
554 |
by (REPEAT (ares_tac [Un_least, synth_mono, Un_upper1, Un_upper2] 1)); |
|
555 |
qed "synth_Un"; |
|
1839 | 556 |
|
1913 | 557 |
goal thy "insert X (synth H) <= synth(insert X H)"; |
2922 | 558 |
by (blast_tac (!claset addIs [impOfSubs synth_mono]) 1); |
1913 | 559 |
qed "synth_insert"; |
1885 | 560 |
|
1839 | 561 |
(** Idempotence and transitivity **) |
562 |
||
1913 | 563 |
goal thy "!!H. X: synth (synth H) ==> X: synth H"; |
2032 | 564 |
by (etac synth.induct 1); |
2891 | 565 |
by (ALLGOALS Blast_tac); |
2922 | 566 |
qed "synth_synthD"; |
567 |
AddSDs [synth_synthD]; |
|
1839 | 568 |
|
1913 | 569 |
goal thy "synth (synth H) = synth H"; |
2891 | 570 |
by (Blast_tac 1); |
1913 | 571 |
qed "synth_idem"; |
1839 | 572 |
|
1913 | 573 |
goal thy "!!H. [| X: synth G; G <= synth H |] ==> X: synth H"; |
574 |
by (dtac synth_mono 1); |
|
2891 | 575 |
by (Blast_tac 1); |
1913 | 576 |
qed "synth_trans"; |
1839 | 577 |
|
578 |
(*Cut; Lemma 2 of Lowe*) |
|
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
579 |
goal thy "!!H. [| Y: synth (insert X H); X: synth H |] ==> Y: synth H"; |
2032 | 580 |
by (etac synth_trans 1); |
2891 | 581 |
by (Blast_tac 1); |
1913 | 582 |
qed "synth_cut"; |
1839 | 583 |
|
1946 | 584 |
goal thy "Agent A : synth H"; |
2891 | 585 |
by (Blast_tac 1); |
1946 | 586 |
qed "Agent_synth"; |
587 |
||
1913 | 588 |
goal thy "(Nonce N : synth H) = (Nonce N : H)"; |
2891 | 589 |
by (Blast_tac 1); |
1913 | 590 |
qed "Nonce_synth_eq"; |
1839 | 591 |
|
1913 | 592 |
goal thy "(Key K : synth H) = (Key K : H)"; |
2891 | 593 |
by (Blast_tac 1); |
1913 | 594 |
qed "Key_synth_eq"; |
1839 | 595 |
|
2373 | 596 |
goal thy "!!K. Key K ~: H ==> (Crypt K X : synth H) = (Crypt K X : H)"; |
2891 | 597 |
by (Blast_tac 1); |
2011 | 598 |
qed "Crypt_synth_eq"; |
599 |
||
600 |
Addsimps [Agent_synth, Nonce_synth_eq, Key_synth_eq, Crypt_synth_eq]; |
|
1839 | 601 |
|
602 |
||
603 |
goalw thy [keysFor_def] |
|
1913 | 604 |
"keysFor (synth H) = keysFor H Un invKey``{K. Key K : H}"; |
2891 | 605 |
by (Blast_tac 1); |
1913 | 606 |
qed "keysFor_synth"; |
607 |
Addsimps [keysFor_synth]; |
|
1839 | 608 |
|
609 |
||
1913 | 610 |
(*** Combinations of parts, analz and synth ***) |
1839 | 611 |
|
1913 | 612 |
goal thy "parts (synth H) = parts H Un synth H"; |
2032 | 613 |
by (rtac equalityI 1); |
614 |
by (rtac subsetI 1); |
|
615 |
by (etac parts.induct 1); |
|
1839 | 616 |
by (ALLGOALS |
2922 | 617 |
(blast_tac (!claset addIs ((synth_increasing RS parts_mono RS subsetD) |
2032 | 618 |
::parts.intrs)))); |
1913 | 619 |
qed "parts_synth"; |
620 |
Addsimps [parts_synth]; |
|
1839 | 621 |
|
2373 | 622 |
goal thy "analz (analz G Un H) = analz (G Un H)"; |
623 |
by (REPEAT_FIRST (resolve_tac [equalityI, analz_subset_cong])); |
|
624 |
by (ALLGOALS Simp_tac); |
|
625 |
qed "analz_analz_Un"; |
|
626 |
||
627 |
goal thy "analz (synth G Un H) = analz (G Un H) Un synth G"; |
|
2032 | 628 |
by (rtac equalityI 1); |
629 |
by (rtac subsetI 1); |
|
630 |
by (etac analz.induct 1); |
|
2922 | 631 |
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 5); |
632 |
by (ALLGOALS (blast_tac (!claset addIs analz.intrs))); |
|
2373 | 633 |
qed "analz_synth_Un"; |
634 |
||
635 |
goal thy "analz (synth H) = analz H Un synth H"; |
|
636 |
by (cut_inst_tac [("H","{}")] analz_synth_Un 1); |
|
637 |
by (Full_simp_tac 1); |
|
1913 | 638 |
qed "analz_synth"; |
2373 | 639 |
Addsimps [analz_analz_Un, analz_synth_Un, analz_synth]; |
1839 | 640 |
|
2032 | 641 |
(*Hard to prove; still needed now that there's only one Spy?*) |
1913 | 642 |
goal thy "analz (UN i. synth (H i)) = \ |
643 |
\ analz (UN i. H i) Un (UN i. synth (H i))"; |
|
2032 | 644 |
by (rtac equalityI 1); |
645 |
by (rtac subsetI 1); |
|
646 |
by (etac analz.induct 1); |
|
2922 | 647 |
by (blast_tac |
648 |
(!claset addIs [impOfSubs synth_increasing, |
|
2032 | 649 |
impOfSubs analz_mono]) 5); |
2891 | 650 |
by (Blast_tac 1); |
651 |
by (blast_tac (!claset addIs [analz.Inj RS analz.Fst]) 1); |
|
652 |
by (blast_tac (!claset addIs [analz.Inj RS analz.Snd]) 1); |
|
653 |
by (blast_tac (!claset addIs [analz.Decrypt]) 1); |
|
1913 | 654 |
qed "analz_UN1_synth"; |
655 |
Addsimps [analz_UN1_synth]; |
|
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
656 |
|
1946 | 657 |
|
658 |
(** For reasoning about the Fake rule in traces **) |
|
659 |
||
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
660 |
goal thy "!!Y. X: G ==> parts(insert X H) <= parts G Un parts H"; |
2032 | 661 |
by (rtac ([parts_mono, parts_Un_subset2] MRS subset_trans) 1); |
2891 | 662 |
by (Blast_tac 1); |
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
663 |
qed "parts_insert_subset_Un"; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
664 |
|
1946 | 665 |
(*More specifically for Fake*) |
666 |
goal thy "!!H. X: synth (analz G) ==> \ |
|
667 |
\ parts (insert X H) <= synth (analz G) Un parts G Un parts H"; |
|
2032 | 668 |
by (dtac parts_insert_subset_Un 1); |
1946 | 669 |
by (Full_simp_tac 1); |
2891 | 670 |
by (Blast_tac 1); |
1946 | 671 |
qed "Fake_parts_insert"; |
672 |
||
2061 | 673 |
goal thy |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
674 |
"!!H. [| Crypt K Y : parts (insert X H); X: synth (analz G); \ |
2061 | 675 |
\ Key K ~: analz G |] \ |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
676 |
\ ==> Crypt K Y : parts G Un parts H"; |
2061 | 677 |
by (dtac (impOfSubs Fake_parts_insert) 1); |
2170 | 678 |
by (assume_tac 1); |
3102 | 679 |
by (blast_tac (!claset addDs [impOfSubs analz_subset_parts]) 1); |
2061 | 680 |
qed "Crypt_Fake_parts_insert"; |
681 |
||
2373 | 682 |
goal thy "!!H. X: synth (analz G) ==> \ |
683 |
\ analz (insert X H) <= synth (analz G) Un analz (G Un H)"; |
|
684 |
by (rtac subsetI 1); |
|
685 |
by (subgoal_tac "x : analz (synth (analz G) Un H)" 1); |
|
2922 | 686 |
by (blast_tac (!claset addIs [impOfSubs analz_mono, |
687 |
impOfSubs (analz_mono RS synth_mono)]) 2); |
|
2373 | 688 |
by (Full_simp_tac 1); |
2891 | 689 |
by (Blast_tac 1); |
2373 | 690 |
qed "Fake_analz_insert"; |
691 |
||
2011 | 692 |
goal thy "(X: analz H & X: parts H) = (X: analz H)"; |
2891 | 693 |
by (blast_tac (!claset addIs [impOfSubs analz_subset_parts]) 1); |
2011 | 694 |
val analz_conj_parts = result(); |
695 |
||
696 |
goal thy "(X: analz H | X: parts H) = (X: parts H)"; |
|
2891 | 697 |
by (blast_tac (!claset addIs [impOfSubs analz_subset_parts]) 1); |
2011 | 698 |
val analz_disj_parts = result(); |
699 |
||
700 |
AddIffs [analz_conj_parts, analz_disj_parts]; |
|
701 |
||
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
702 |
(*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
|
703 |
redundant cases*) |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
704 |
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
|
705 |
\ (X : synth (analz H) & Y : synth (analz H))"; |
2891 | 706 |
by (Blast_tac 1); |
1998
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
707 |
qed "MPair_synth_analz"; |
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
708 |
|
f8230821f1e8
Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents:
1994
diff
changeset
|
709 |
AddIffs [MPair_synth_analz]; |
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
710 |
|
2154 | 711 |
goal thy "!!K. [| Key K : analz H; Key (invKey K) : analz H |] \ |
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2170
diff
changeset
|
712 |
\ ==> (Crypt K X : synth (analz H)) = (X : synth (analz H))"; |
2891 | 713 |
by (Blast_tac 1); |
2154 | 714 |
qed "Crypt_synth_analz"; |
715 |
||
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
716 |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
717 |
goal thy "!!K. X ~: synth (analz H) \ |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
718 |
\ ==> (Hash{|X,Y|} : synth (analz H)) = (Hash{|X,Y|} : analz H)"; |
2891 | 719 |
by (Blast_tac 1); |
2373 | 720 |
qed "Hash_synth_analz"; |
721 |
Addsimps [Hash_synth_analz]; |
|
722 |
||
723 |
||
2484 | 724 |
(**** HPair: a combination of Hash and MPair ****) |
725 |
||
726 |
(*** Freeness ***) |
|
727 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
728 |
goalw thy [HPair_def] "Agent A ~= Hash[X] Y"; |
2484 | 729 |
by (Simp_tac 1); |
730 |
qed "Agent_neq_HPair"; |
|
731 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
732 |
goalw thy [HPair_def] "Nonce N ~= Hash[X] Y"; |
2484 | 733 |
by (Simp_tac 1); |
734 |
qed "Nonce_neq_HPair"; |
|
735 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
736 |
goalw thy [HPair_def] "Key K ~= Hash[X] Y"; |
2484 | 737 |
by (Simp_tac 1); |
738 |
qed "Key_neq_HPair"; |
|
739 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
740 |
goalw thy [HPair_def] "Hash Z ~= Hash[X] Y"; |
2484 | 741 |
by (Simp_tac 1); |
742 |
qed "Hash_neq_HPair"; |
|
743 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
744 |
goalw thy [HPair_def] "Crypt K X' ~= Hash[X] Y"; |
2484 | 745 |
by (Simp_tac 1); |
746 |
qed "Crypt_neq_HPair"; |
|
747 |
||
748 |
val HPair_neqs = [Agent_neq_HPair, Nonce_neq_HPair, |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
749 |
Key_neq_HPair, Hash_neq_HPair, Crypt_neq_HPair]; |
2484 | 750 |
|
751 |
AddIffs HPair_neqs; |
|
752 |
AddIffs (HPair_neqs RL [not_sym]); |
|
753 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
754 |
goalw thy [HPair_def] "(Hash[X'] Y' = Hash[X] Y) = (X' = X & Y'=Y)"; |
2484 | 755 |
by (Simp_tac 1); |
756 |
qed "HPair_eq"; |
|
757 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
758 |
goalw thy [HPair_def] "({|X',Y'|} = Hash[X] Y) = (X' = Hash{|X,Y|} & Y'=Y)"; |
2484 | 759 |
by (Simp_tac 1); |
760 |
qed "MPair_eq_HPair"; |
|
761 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
762 |
goalw thy [HPair_def] "(Hash[X] Y = {|X',Y'|}) = (X' = Hash{|X,Y|} & Y'=Y)"; |
2484 | 763 |
by (Auto_tac()); |
764 |
qed "HPair_eq_MPair"; |
|
765 |
||
766 |
AddIffs [HPair_eq, MPair_eq_HPair, HPair_eq_MPair]; |
|
767 |
||
768 |
||
769 |
(*** Specialized laws, proved in terms of those for Hash and MPair ***) |
|
770 |
||
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
771 |
goalw thy [HPair_def] "keysFor (insert (Hash[X] Y) H) = keysFor H"; |
2484 | 772 |
by (Simp_tac 1); |
773 |
qed "keysFor_insert_HPair"; |
|
774 |
||
775 |
goalw thy [HPair_def] |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
776 |
"parts (insert (Hash[X] Y) H) = \ |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
777 |
\ insert (Hash[X] Y) (insert (Hash{|X,Y|}) (parts (insert Y H)))"; |
2484 | 778 |
by (Simp_tac 1); |
779 |
qed "parts_insert_HPair"; |
|
780 |
||
781 |
goalw thy [HPair_def] |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
782 |
"analz (insert (Hash[X] Y) H) = \ |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
783 |
\ insert (Hash[X] Y) (insert (Hash{|X,Y|}) (analz (insert Y H)))"; |
2484 | 784 |
by (Simp_tac 1); |
785 |
qed "analz_insert_HPair"; |
|
786 |
||
787 |
goalw thy [HPair_def] "!!H. X ~: synth (analz H) \ |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
788 |
\ ==> (Hash[X] Y : synth (analz H)) = \ |
2484 | 789 |
\ (Hash {|X, Y|} : analz H & Y : synth (analz H))"; |
790 |
by (Simp_tac 1); |
|
2891 | 791 |
by (Blast_tac 1); |
2484 | 792 |
qed "HPair_synth_analz"; |
793 |
||
794 |
Addsimps [keysFor_insert_HPair, parts_insert_HPair, analz_insert_HPair, |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
795 |
HPair_synth_analz, HPair_synth_analz]; |
2484 | 796 |
|
797 |
||
1929
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
798 |
(*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
|
799 |
Delrules partsEs; |
f0839bab4b00
Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents:
1913
diff
changeset
|
800 |
|
2327 | 801 |
|
802 |
(** Rewrites to push in Key and Crypt messages, so that other messages can |
|
803 |
be pulled out using the analz_insert rules **) |
|
804 |
||
805 |
fun insComm thy x y = read_instantiate_sg (sign_of thy) [("x",x), ("y",y)] |
|
806 |
insert_commute; |
|
807 |
||
808 |
val pushKeys = map (insComm thy "Key ?K") |
|
2373 | 809 |
["Agent ?C", "Nonce ?N", "Hash ?X", |
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
810 |
"MPair ?X ?Y", "Crypt ?X ?K'"]; |
2327 | 811 |
|
812 |
val pushCrypts = map (insComm thy "Crypt ?X ?K") |
|
2373 | 813 |
["Agent ?C", "Nonce ?N", "Hash ?X'", "MPair ?X' ?Y"]; |
2327 | 814 |
|
815 |
(*Cannot be added with Addsimps -- we don't always want to re-order messages*) |
|
816 |
val pushes = pushKeys@pushCrypts; |
|
817 |
||
3121
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
818 |
|
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
819 |
(*** Tactics useful for many protocol proofs ***) |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
820 |
|
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
821 |
(*Prove base case (subgoal i) and simplify others*) |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
822 |
fun prove_simple_subgoals_tac i = |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
823 |
fast_tac (!claset addss (!simpset)) i THEN |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
824 |
ALLGOALS Asm_simp_tac; |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
825 |
|
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
826 |
fun Fake_parts_insert_tac i = |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
827 |
blast_tac (!claset addDs [impOfSubs analz_subset_parts, |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
828 |
impOfSubs Fake_parts_insert]) i; |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
829 |
|
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
830 |
(*Apply rules to break down assumptions of the form |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
831 |
Y : parts(insert X H) and Y : analz(insert X H) |
cbb6c0c1c58a
Conversion to use blast_tac (with other improvements)
paulson
parents:
3102
diff
changeset
|
832 |
*) |
2373 | 833 |
val Fake_insert_tac = |
834 |
dresolve_tac [impOfSubs Fake_analz_insert, |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
835 |
impOfSubs Fake_parts_insert] THEN' |
2373 | 836 |
eresolve_tac [asm_rl, synth.Inj]; |
837 |
||
838 |
(*Analysis of Fake cases and of messages that forward unknown parts. |
|
2327 | 839 |
Abstraction over i is ESSENTIAL: it delays the dereferencing of claset |
840 |
DEPENDS UPON "X" REFERRING TO THE FRADULENT MESSAGE *) |
|
841 |
fun spy_analz_tac i = |
|
2373 | 842 |
DETERM |
843 |
(SELECT_GOAL |
|
844 |
(EVERY |
|
845 |
[ (*push in occurrences of X...*) |
|
846 |
(REPEAT o CHANGED) |
|
847 |
(res_inst_tac [("x1","X")] (insert_commute RS ssubst) 1), |
|
848 |
(*...allowing further simplifications*) |
|
849 |
simp_tac (!simpset setloop split_tac [expand_if]) 1, |
|
850 |
REPEAT (FIRSTGOAL (resolve_tac [allI,impI,notI,conjI])), |
|
851 |
DEPTH_SOLVE |
|
852 |
(REPEAT (Fake_insert_tac 1) THEN Asm_full_simp_tac 1 |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
853 |
THEN |
3102 | 854 |
IF_UNSOLVED (Blast.depth_tac |
855 |
(!claset addIs [impOfSubs analz_mono, |
|
856 |
impOfSubs analz_subset_parts]) 2 1)) |
|
2373 | 857 |
]) i); |
2327 | 858 |
|
2415 | 859 |
(** Useful in many uniqueness proofs **) |
2327 | 860 |
fun ex_strip_tac i = REPEAT (swap_res_tac [exI, conjI] i) THEN |
861 |
assume_tac (i+1); |
|
862 |
||
2415 | 863 |
(*Apply the EX-ALL quantifification to prove uniqueness theorems in |
864 |
their standard form*) |
|
865 |
fun prove_unique_tac lemma = |
|
866 |
EVERY' [dtac lemma, |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
867 |
REPEAT o (mp_tac ORELSE' eresolve_tac [asm_rl,exE]), |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
868 |
(*Duplicate the assumption*) |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
869 |
forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl, |
3102 | 870 |
Blast.depth_tac (!claset addSDs [spec]) 0]; |
2415 | 871 |
|
2373 | 872 |
|
873 |
(*Needed occasionally with spy_analz_tac, e.g. in analz_insert_Key_newK*) |
|
874 |
goal Set.thy "A Un (B Un A) = B Un A"; |
|
2891 | 875 |
by (Blast_tac 1); |
2373 | 876 |
val Un_absorb3 = result(); |
877 |
Addsimps [Un_absorb3]; |