author | wenzelm |
Mon, 16 Mar 2009 18:24:30 +0100 | |
changeset 30549 | d2d7874648bd |
parent 30510 | 4120fc59dd85 |
child 30607 | c3d1590debd8 |
permissions | -rw-r--r-- |
14199 | 1 |
(* Title: HOL/Auth/SET/MessageSET |
2 |
ID: $Id$ |
|
3 |
Authors: Giampaolo Bella, Fabio Massacci, Lawrence C Paulson |
|
4 |
*) |
|
5 |
||
6 |
header{*The Message Theory, Modified for SET*} |
|
7 |
||
25592 | 8 |
theory MessageSET |
29888 | 9 |
imports Main Nat_Int_Bij |
25592 | 10 |
begin |
14199 | 11 |
|
12 |
subsection{*General Lemmas*} |
|
13 |
||
14 |
text{*Needed occasionally with @{text spy_analz_tac}, e.g. in |
|
15 |
@{text analz_insert_Key_newK}*} |
|
16 |
||
17 |
lemma Un_absorb3 [simp] : "A \<union> (B \<union> A) = B \<union> A" |
|
18 |
by blast |
|
19 |
||
20 |
text{*Collapses redundant cases in the huge protocol proofs*} |
|
21 |
lemmas disj_simps = disj_comms disj_left_absorb disj_assoc |
|
22 |
||
23 |
text{*Effective with assumptions like @{term "K \<notin> range pubK"} and |
|
24 |
@{term "K \<notin> invKey`range pubK"}*} |
|
25 |
lemma notin_image_iff: "(y \<notin> f`I) = (\<forall>i\<in>I. f i \<noteq> y)" |
|
26 |
by blast |
|
27 |
||
28 |
text{*Effective with the assumption @{term "KK \<subseteq> - (range(invKey o pubK))"} *} |
|
29 |
lemma disjoint_image_iff: "(A <= - (f`I)) = (\<forall>i\<in>I. f i \<notin> A)" |
|
30 |
by blast |
|
31 |
||
32 |
||
33 |
||
34 |
types |
|
35 |
key = nat |
|
36 |
||
37 |
consts |
|
38 |
all_symmetric :: bool --{*true if all keys are symmetric*} |
|
39 |
invKey :: "key=>key" --{*inverse of a symmetric key*} |
|
40 |
||
41 |
specification (invKey) |
|
42 |
invKey [simp]: "invKey (invKey K) = K" |
|
43 |
invKey_symmetric: "all_symmetric --> invKey = id" |
|
44 |
by (rule exI [of _ id], auto) |
|
45 |
||
46 |
||
47 |
text{*The inverse of a symmetric key is itself; that of a public key |
|
48 |
is the private key and vice versa*} |
|
49 |
||
50 |
constdefs |
|
51 |
symKeys :: "key set" |
|
52 |
"symKeys == {K. invKey K = K}" |
|
53 |
||
54 |
text{*Agents. We allow any number of certification authorities, cardholders |
|
55 |
merchants, and payment gateways.*} |
|
56 |
datatype |
|
57 |
agent = CA nat | Cardholder nat | Merchant nat | PG nat | Spy |
|
58 |
||
59 |
text{*Messages*} |
|
60 |
datatype |
|
61 |
msg = Agent agent --{*Agent names*} |
|
62 |
| Number nat --{*Ordinary integers, timestamps, ...*} |
|
63 |
| Nonce nat --{*Unguessable nonces*} |
|
64 |
| Pan nat --{*Unguessable Primary Account Numbers (??)*} |
|
65 |
| Key key --{*Crypto keys*} |
|
66 |
| Hash msg --{*Hashing*} |
|
67 |
| MPair msg msg --{*Compound messages*} |
|
68 |
| Crypt key msg --{*Encryption, public- or shared-key*} |
|
69 |
||
70 |
||
71 |
(*Concrete syntax: messages appear as {|A,B,NA|}, etc...*) |
|
72 |
syntax |
|
73 |
"@MTuple" :: "['a, args] => 'a * 'b" ("(2{|_,/ _|})") |
|
74 |
||
75 |
syntax (xsymbols) |
|
76 |
"@MTuple" :: "['a, args] => 'a * 'b" ("(2\<lbrace>_,/ _\<rbrace>)") |
|
77 |
||
78 |
translations |
|
79 |
"{|x, y, z|}" == "{|x, {|y, z|}|}" |
|
80 |
"{|x, y|}" == "MPair x y" |
|
81 |
||
82 |
||
83 |
constdefs |
|
84 |
nat_of_agent :: "agent => nat" |
|
85 |
"nat_of_agent == agent_case (curry nat2_to_nat 0) |
|
86 |
(curry nat2_to_nat 1) |
|
87 |
(curry nat2_to_nat 2) |
|
88 |
(curry nat2_to_nat 3) |
|
89 |
(nat2_to_nat (4,0))" |
|
90 |
--{*maps each agent to a unique natural number, for specifications*} |
|
91 |
||
92 |
text{*The function is indeed injective*} |
|
93 |
lemma inj_nat_of_agent: "inj nat_of_agent" |
|
94 |
by (simp add: nat_of_agent_def inj_on_def curry_def |
|
95 |
nat2_to_nat_inj [THEN inj_eq] split: agent.split) |
|
96 |
||
97 |
||
98 |
constdefs |
|
99 |
(*Keys useful to decrypt elements of a message set*) |
|
100 |
keysFor :: "msg set => key set" |
|
101 |
"keysFor H == invKey ` {K. \<exists>X. Crypt K X \<in> H}" |
|
102 |
||
103 |
subsubsection{*Inductive definition of all "parts" of a message.*} |
|
104 |
||
23755 | 105 |
inductive_set |
106 |
parts :: "msg set => msg set" |
|
107 |
for H :: "msg set" |
|
108 |
where |
|
14199 | 109 |
Inj [intro]: "X \<in> H ==> X \<in> parts H" |
23755 | 110 |
| Fst: "{|X,Y|} \<in> parts H ==> X \<in> parts H" |
111 |
| Snd: "{|X,Y|} \<in> parts H ==> Y \<in> parts H" |
|
112 |
| Body: "Crypt K X \<in> parts H ==> X \<in> parts H" |
|
14199 | 113 |
|
114 |
||
115 |
(*Monotonicity*) |
|
116 |
lemma parts_mono: "G<=H ==> parts(G) <= parts(H)" |
|
117 |
apply auto |
|
118 |
apply (erule parts.induct) |
|
119 |
apply (auto dest: Fst Snd Body) |
|
120 |
done |
|
121 |
||
122 |
||
123 |
subsubsection{*Inverse of keys*} |
|
124 |
||
125 |
(*Equations hold because constructors are injective; cannot prove for all f*) |
|
126 |
lemma Key_image_eq [simp]: "(Key x \<in> Key`A) = (x\<in>A)" |
|
127 |
by auto |
|
128 |
||
129 |
lemma Nonce_Key_image_eq [simp]: "(Nonce x \<notin> Key`A)" |
|
130 |
by auto |
|
131 |
||
132 |
lemma Cardholder_image_eq [simp]: "(Cardholder x \<in> Cardholder`A) = (x \<in> A)" |
|
133 |
by auto |
|
134 |
||
135 |
lemma CA_image_eq [simp]: "(CA x \<in> CA`A) = (x \<in> A)" |
|
136 |
by auto |
|
137 |
||
138 |
lemma Pan_image_eq [simp]: "(Pan x \<in> Pan`A) = (x \<in> A)" |
|
139 |
by auto |
|
140 |
||
141 |
lemma Pan_Key_image_eq [simp]: "(Pan x \<notin> Key`A)" |
|
142 |
by auto |
|
143 |
||
144 |
lemma Nonce_Pan_image_eq [simp]: "(Nonce x \<notin> Pan`A)" |
|
145 |
by auto |
|
146 |
||
147 |
lemma invKey_eq [simp]: "(invKey K = invKey K') = (K=K')" |
|
148 |
apply safe |
|
149 |
apply (drule_tac f = invKey in arg_cong, simp) |
|
150 |
done |
|
151 |
||
152 |
||
153 |
subsection{*keysFor operator*} |
|
154 |
||
155 |
lemma keysFor_empty [simp]: "keysFor {} = {}" |
|
156 |
by (unfold keysFor_def, blast) |
|
157 |
||
158 |
lemma keysFor_Un [simp]: "keysFor (H \<union> H') = keysFor H \<union> keysFor H'" |
|
159 |
by (unfold keysFor_def, blast) |
|
160 |
||
161 |
lemma keysFor_UN [simp]: "keysFor (\<Union>i\<in>A. H i) = (\<Union>i\<in>A. keysFor (H i))" |
|
162 |
by (unfold keysFor_def, blast) |
|
163 |
||
164 |
(*Monotonicity*) |
|
165 |
lemma keysFor_mono: "G\<subseteq>H ==> keysFor(G) \<subseteq> keysFor(H)" |
|
166 |
by (unfold keysFor_def, blast) |
|
167 |
||
168 |
lemma keysFor_insert_Agent [simp]: "keysFor (insert (Agent A) H) = keysFor H" |
|
169 |
by (unfold keysFor_def, auto) |
|
170 |
||
171 |
lemma keysFor_insert_Nonce [simp]: "keysFor (insert (Nonce N) H) = keysFor H" |
|
172 |
by (unfold keysFor_def, auto) |
|
173 |
||
174 |
lemma keysFor_insert_Number [simp]: "keysFor (insert (Number N) H) = keysFor H" |
|
175 |
by (unfold keysFor_def, auto) |
|
176 |
||
177 |
lemma keysFor_insert_Key [simp]: "keysFor (insert (Key K) H) = keysFor H" |
|
178 |
by (unfold keysFor_def, auto) |
|
179 |
||
180 |
lemma keysFor_insert_Pan [simp]: "keysFor (insert (Pan A) H) = keysFor H" |
|
181 |
by (unfold keysFor_def, auto) |
|
182 |
||
183 |
lemma keysFor_insert_Hash [simp]: "keysFor (insert (Hash X) H) = keysFor H" |
|
184 |
by (unfold keysFor_def, auto) |
|
185 |
||
186 |
lemma keysFor_insert_MPair [simp]: "keysFor (insert {|X,Y|} H) = keysFor H" |
|
187 |
by (unfold keysFor_def, auto) |
|
188 |
||
189 |
lemma keysFor_insert_Crypt [simp]: |
|
190 |
"keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)" |
|
191 |
by (unfold keysFor_def, auto) |
|
192 |
||
193 |
lemma keysFor_image_Key [simp]: "keysFor (Key`E) = {}" |
|
194 |
by (unfold keysFor_def, auto) |
|
195 |
||
196 |
lemma Crypt_imp_invKey_keysFor: "Crypt K X \<in> H ==> invKey K \<in> keysFor H" |
|
197 |
by (unfold keysFor_def, blast) |
|
198 |
||
199 |
||
200 |
subsection{*Inductive relation "parts"*} |
|
201 |
||
202 |
lemma MPair_parts: |
|
203 |
"[| {|X,Y|} \<in> parts H; |
|
204 |
[| X \<in> parts H; Y \<in> parts H |] ==> P |] ==> P" |
|
205 |
by (blast dest: parts.Fst parts.Snd) |
|
206 |
||
207 |
declare MPair_parts [elim!] parts.Body [dest!] |
|
208 |
text{*NB These two rules are UNSAFE in the formal sense, as they discard the |
|
209 |
compound message. They work well on THIS FILE. |
|
210 |
@{text MPair_parts} is left as SAFE because it speeds up proofs. |
|
211 |
The Crypt rule is normally kept UNSAFE to avoid breaking up certificates.*} |
|
212 |
||
213 |
lemma parts_increasing: "H \<subseteq> parts(H)" |
|
214 |
by blast |
|
215 |
||
216 |
lemmas parts_insertI = subset_insertI [THEN parts_mono, THEN subsetD, standard] |
|
217 |
||
218 |
lemma parts_empty [simp]: "parts{} = {}" |
|
219 |
apply safe |
|
220 |
apply (erule parts.induct, blast+) |
|
221 |
done |
|
222 |
||
223 |
lemma parts_emptyE [elim!]: "X\<in> parts{} ==> P" |
|
224 |
by simp |
|
225 |
||
226 |
(*WARNING: loops if H = {Y}, therefore must not be repeated!*) |
|
227 |
lemma parts_singleton: "X\<in> parts H ==> \<exists>Y\<in>H. X\<in> parts {Y}" |
|
26807
4cd176ea28dc
Replaced blast by fast in proof of parts_singleton, since blast looped
berghofe
parents:
26342
diff
changeset
|
228 |
by (erule parts.induct, fast+) |
14199 | 229 |
|
230 |
||
231 |
subsubsection{*Unions*} |
|
232 |
||
233 |
lemma parts_Un_subset1: "parts(G) \<union> parts(H) \<subseteq> parts(G \<union> H)" |
|
234 |
by (intro Un_least parts_mono Un_upper1 Un_upper2) |
|
235 |
||
236 |
lemma parts_Un_subset2: "parts(G \<union> H) \<subseteq> parts(G) \<union> parts(H)" |
|
237 |
apply (rule subsetI) |
|
238 |
apply (erule parts.induct, blast+) |
|
239 |
done |
|
240 |
||
241 |
lemma parts_Un [simp]: "parts(G \<union> H) = parts(G) \<union> parts(H)" |
|
242 |
by (intro equalityI parts_Un_subset1 parts_Un_subset2) |
|
243 |
||
244 |
lemma parts_insert: "parts (insert X H) = parts {X} \<union> parts H" |
|
245 |
apply (subst insert_is_Un [of _ H]) |
|
246 |
apply (simp only: parts_Un) |
|
247 |
done |
|
248 |
||
249 |
(*TWO inserts to avoid looping. This rewrite is better than nothing. |
|
250 |
Not suitable for Addsimps: its behaviour can be strange.*) |
|
251 |
lemma parts_insert2: |
|
252 |
"parts (insert X (insert Y H)) = parts {X} \<union> parts {Y} \<union> parts H" |
|
253 |
apply (simp add: Un_assoc) |
|
254 |
apply (simp add: parts_insert [symmetric]) |
|
255 |
done |
|
256 |
||
257 |
lemma parts_UN_subset1: "(\<Union>x\<in>A. parts(H x)) \<subseteq> parts(\<Union>x\<in>A. H x)" |
|
258 |
by (intro UN_least parts_mono UN_upper) |
|
259 |
||
260 |
lemma parts_UN_subset2: "parts(\<Union>x\<in>A. H x) \<subseteq> (\<Union>x\<in>A. parts(H x))" |
|
261 |
apply (rule subsetI) |
|
262 |
apply (erule parts.induct, blast+) |
|
263 |
done |
|
264 |
||
265 |
lemma parts_UN [simp]: "parts(\<Union>x\<in>A. H x) = (\<Union>x\<in>A. parts(H x))" |
|
266 |
by (intro equalityI parts_UN_subset1 parts_UN_subset2) |
|
267 |
||
268 |
(*Added to simplify arguments to parts, analz and synth. |
|
269 |
NOTE: the UN versions are no longer used!*) |
|
270 |
||
271 |
||
272 |
text{*This allows @{text blast} to simplify occurrences of |
|
273 |
@{term "parts(G\<union>H)"} in the assumption.*} |
|
274 |
declare parts_Un [THEN equalityD1, THEN subsetD, THEN UnE, elim!] |
|
275 |
||
276 |
||
277 |
lemma parts_insert_subset: "insert X (parts H) \<subseteq> parts(insert X H)" |
|
278 |
by (blast intro: parts_mono [THEN [2] rev_subsetD]) |
|
279 |
||
280 |
subsubsection{*Idempotence and transitivity*} |
|
281 |
||
282 |
lemma parts_partsD [dest!]: "X\<in> parts (parts H) ==> X\<in> parts H" |
|
283 |
by (erule parts.induct, blast+) |
|
284 |
||
285 |
lemma parts_idem [simp]: "parts (parts H) = parts H" |
|
286 |
by blast |
|
287 |
||
288 |
lemma parts_trans: "[| X\<in> parts G; G \<subseteq> parts H |] ==> X\<in> parts H" |
|
289 |
by (drule parts_mono, blast) |
|
290 |
||
291 |
(*Cut*) |
|
292 |
lemma parts_cut: |
|
293 |
"[| Y\<in> parts (insert X G); X\<in> parts H |] ==> Y\<in> parts (G \<union> H)" |
|
294 |
by (erule parts_trans, auto) |
|
295 |
||
296 |
lemma parts_cut_eq [simp]: "X\<in> parts H ==> parts (insert X H) = parts H" |
|
297 |
by (force dest!: parts_cut intro: parts_insertI) |
|
298 |
||
299 |
||
300 |
subsubsection{*Rewrite rules for pulling out atomic messages*} |
|
301 |
||
302 |
lemmas parts_insert_eq_I = equalityI [OF subsetI parts_insert_subset] |
|
303 |
||
304 |
||
305 |
lemma parts_insert_Agent [simp]: |
|
306 |
"parts (insert (Agent agt) H) = insert (Agent agt) (parts H)" |
|
307 |
apply (rule parts_insert_eq_I) |
|
308 |
apply (erule parts.induct, auto) |
|
309 |
done |
|
310 |
||
311 |
lemma parts_insert_Nonce [simp]: |
|
312 |
"parts (insert (Nonce N) H) = insert (Nonce N) (parts H)" |
|
313 |
apply (rule parts_insert_eq_I) |
|
314 |
apply (erule parts.induct, auto) |
|
315 |
done |
|
316 |
||
317 |
lemma parts_insert_Number [simp]: |
|
318 |
"parts (insert (Number N) H) = insert (Number N) (parts H)" |
|
319 |
apply (rule parts_insert_eq_I) |
|
320 |
apply (erule parts.induct, auto) |
|
321 |
done |
|
322 |
||
323 |
lemma parts_insert_Key [simp]: |
|
324 |
"parts (insert (Key K) H) = insert (Key K) (parts H)" |
|
325 |
apply (rule parts_insert_eq_I) |
|
326 |
apply (erule parts.induct, auto) |
|
327 |
done |
|
328 |
||
329 |
lemma parts_insert_Pan [simp]: |
|
330 |
"parts (insert (Pan A) H) = insert (Pan A) (parts H)" |
|
331 |
apply (rule parts_insert_eq_I) |
|
332 |
apply (erule parts.induct, auto) |
|
333 |
done |
|
334 |
||
335 |
lemma parts_insert_Hash [simp]: |
|
336 |
"parts (insert (Hash X) H) = insert (Hash X) (parts H)" |
|
337 |
apply (rule parts_insert_eq_I) |
|
338 |
apply (erule parts.induct, auto) |
|
339 |
done |
|
340 |
||
341 |
lemma parts_insert_Crypt [simp]: |
|
342 |
"parts (insert (Crypt K X) H) = |
|
343 |
insert (Crypt K X) (parts (insert X H))" |
|
344 |
apply (rule equalityI) |
|
345 |
apply (rule subsetI) |
|
346 |
apply (erule parts.induct, auto) |
|
347 |
apply (erule parts.induct) |
|
348 |
apply (blast intro: parts.Body)+ |
|
349 |
done |
|
350 |
||
351 |
lemma parts_insert_MPair [simp]: |
|
352 |
"parts (insert {|X,Y|} H) = |
|
353 |
insert {|X,Y|} (parts (insert X (insert Y H)))" |
|
354 |
apply (rule equalityI) |
|
355 |
apply (rule subsetI) |
|
356 |
apply (erule parts.induct, auto) |
|
357 |
apply (erule parts.induct) |
|
358 |
apply (blast intro: parts.Fst parts.Snd)+ |
|
359 |
done |
|
360 |
||
361 |
lemma parts_image_Key [simp]: "parts (Key`N) = Key`N" |
|
362 |
apply auto |
|
363 |
apply (erule parts.induct, auto) |
|
364 |
done |
|
365 |
||
366 |
lemma parts_image_Pan [simp]: "parts (Pan`A) = Pan`A" |
|
367 |
apply auto |
|
368 |
apply (erule parts.induct, auto) |
|
369 |
done |
|
370 |
||
371 |
||
372 |
(*In any message, there is an upper bound N on its greatest nonce.*) |
|
373 |
lemma msg_Nonce_supply: "\<exists>N. \<forall>n. N\<le>n --> Nonce n \<notin> parts {msg}" |
|
374 |
apply (induct_tac "msg") |
|
375 |
apply (simp_all (no_asm_simp) add: exI parts_insert2) |
|
376 |
(*MPair case: blast_tac works out the necessary sum itself!*) |
|
377 |
prefer 2 apply (blast elim!: add_leE) |
|
378 |
(*Nonce case*) |
|
379 |
apply (rule_tac x = "N + Suc nat" in exI) |
|
380 |
apply (auto elim!: add_leE) |
|
381 |
done |
|
382 |
||
383 |
(* Ditto, for numbers.*) |
|
384 |
lemma msg_Number_supply: "\<exists>N. \<forall>n. N<=n --> Number n \<notin> parts {msg}" |
|
385 |
apply (induct_tac "msg") |
|
386 |
apply (simp_all (no_asm_simp) add: exI parts_insert2) |
|
387 |
prefer 2 apply (blast elim!: add_leE) |
|
388 |
apply (rule_tac x = "N + Suc nat" in exI, auto) |
|
389 |
done |
|
390 |
||
391 |
subsection{*Inductive relation "analz"*} |
|
392 |
||
393 |
text{*Inductive definition of "analz" -- what can be broken down from a set of |
|
394 |
messages, including keys. A form of downward closure. Pairs can |
|
395 |
be taken apart; messages decrypted with known keys.*} |
|
396 |
||
23755 | 397 |
inductive_set |
398 |
analz :: "msg set => msg set" |
|
399 |
for H :: "msg set" |
|
400 |
where |
|
14199 | 401 |
Inj [intro,simp] : "X \<in> H ==> X \<in> analz H" |
23755 | 402 |
| Fst: "{|X,Y|} \<in> analz H ==> X \<in> analz H" |
403 |
| Snd: "{|X,Y|} \<in> analz H ==> Y \<in> analz H" |
|
404 |
| Decrypt [dest]: |
|
14199 | 405 |
"[|Crypt K X \<in> analz H; Key(invKey K): analz H|] ==> X \<in> analz H" |
406 |
||
407 |
||
408 |
(*Monotonicity; Lemma 1 of Lowe's paper*) |
|
409 |
lemma analz_mono: "G<=H ==> analz(G) <= analz(H)" |
|
410 |
apply auto |
|
411 |
apply (erule analz.induct) |
|
412 |
apply (auto dest: Fst Snd) |
|
413 |
done |
|
414 |
||
415 |
text{*Making it safe speeds up proofs*} |
|
416 |
lemma MPair_analz [elim!]: |
|
417 |
"[| {|X,Y|} \<in> analz H; |
|
418 |
[| X \<in> analz H; Y \<in> analz H |] ==> P |
|
419 |
|] ==> P" |
|
420 |
by (blast dest: analz.Fst analz.Snd) |
|
421 |
||
422 |
lemma analz_increasing: "H \<subseteq> analz(H)" |
|
423 |
by blast |
|
424 |
||
425 |
lemma analz_subset_parts: "analz H \<subseteq> parts H" |
|
426 |
apply (rule subsetI) |
|
427 |
apply (erule analz.induct, blast+) |
|
428 |
done |
|
429 |
||
430 |
lemmas analz_into_parts = analz_subset_parts [THEN subsetD, standard] |
|
431 |
||
432 |
lemmas not_parts_not_analz = analz_subset_parts [THEN contra_subsetD, standard] |
|
433 |
||
434 |
||
435 |
lemma parts_analz [simp]: "parts (analz H) = parts H" |
|
436 |
apply (rule equalityI) |
|
437 |
apply (rule analz_subset_parts [THEN parts_mono, THEN subset_trans], simp) |
|
438 |
apply (blast intro: analz_increasing [THEN parts_mono, THEN subsetD]) |
|
439 |
done |
|
440 |
||
441 |
lemma analz_parts [simp]: "analz (parts H) = parts H" |
|
442 |
apply auto |
|
443 |
apply (erule analz.induct, auto) |
|
444 |
done |
|
445 |
||
446 |
lemmas analz_insertI = subset_insertI [THEN analz_mono, THEN [2] rev_subsetD, standard] |
|
447 |
||
448 |
subsubsection{*General equational properties*} |
|
449 |
||
450 |
lemma analz_empty [simp]: "analz{} = {}" |
|
451 |
apply safe |
|
452 |
apply (erule analz.induct, blast+) |
|
453 |
done |
|
454 |
||
455 |
(*Converse fails: we can analz more from the union than from the |
|
456 |
separate parts, as a key in one might decrypt a message in the other*) |
|
457 |
lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)" |
|
458 |
by (intro Un_least analz_mono Un_upper1 Un_upper2) |
|
459 |
||
460 |
lemma analz_insert: "insert X (analz H) \<subseteq> analz(insert X H)" |
|
461 |
by (blast intro: analz_mono [THEN [2] rev_subsetD]) |
|
462 |
||
463 |
subsubsection{*Rewrite rules for pulling out atomic messages*} |
|
464 |
||
465 |
lemmas analz_insert_eq_I = equalityI [OF subsetI analz_insert] |
|
466 |
||
467 |
lemma analz_insert_Agent [simp]: |
|
468 |
"analz (insert (Agent agt) H) = insert (Agent agt) (analz H)" |
|
469 |
apply (rule analz_insert_eq_I) |
|
470 |
apply (erule analz.induct, auto) |
|
471 |
done |
|
472 |
||
473 |
lemma analz_insert_Nonce [simp]: |
|
474 |
"analz (insert (Nonce N) H) = insert (Nonce N) (analz H)" |
|
475 |
apply (rule analz_insert_eq_I) |
|
476 |
apply (erule analz.induct, auto) |
|
477 |
done |
|
478 |
||
479 |
lemma analz_insert_Number [simp]: |
|
480 |
"analz (insert (Number N) H) = insert (Number N) (analz H)" |
|
481 |
apply (rule analz_insert_eq_I) |
|
482 |
apply (erule analz.induct, auto) |
|
483 |
done |
|
484 |
||
485 |
lemma analz_insert_Hash [simp]: |
|
486 |
"analz (insert (Hash X) H) = insert (Hash X) (analz H)" |
|
487 |
apply (rule analz_insert_eq_I) |
|
488 |
apply (erule analz.induct, auto) |
|
489 |
done |
|
490 |
||
491 |
(*Can only pull out Keys if they are not needed to decrypt the rest*) |
|
492 |
lemma analz_insert_Key [simp]: |
|
493 |
"K \<notin> keysFor (analz H) ==> |
|
494 |
analz (insert (Key K) H) = insert (Key K) (analz H)" |
|
495 |
apply (unfold keysFor_def) |
|
496 |
apply (rule analz_insert_eq_I) |
|
497 |
apply (erule analz.induct, auto) |
|
498 |
done |
|
499 |
||
500 |
lemma analz_insert_MPair [simp]: |
|
501 |
"analz (insert {|X,Y|} H) = |
|
502 |
insert {|X,Y|} (analz (insert X (insert Y H)))" |
|
503 |
apply (rule equalityI) |
|
504 |
apply (rule subsetI) |
|
505 |
apply (erule analz.induct, auto) |
|
506 |
apply (erule analz.induct) |
|
507 |
apply (blast intro: analz.Fst analz.Snd)+ |
|
508 |
done |
|
509 |
||
510 |
(*Can pull out enCrypted message if the Key is not known*) |
|
511 |
lemma analz_insert_Crypt: |
|
512 |
"Key (invKey K) \<notin> analz H |
|
513 |
==> analz (insert (Crypt K X) H) = insert (Crypt K X) (analz H)" |
|
514 |
apply (rule analz_insert_eq_I) |
|
515 |
apply (erule analz.induct, auto) |
|
516 |
done |
|
517 |
||
518 |
lemma analz_insert_Pan [simp]: |
|
519 |
"analz (insert (Pan A) H) = insert (Pan A) (analz H)" |
|
520 |
apply (rule analz_insert_eq_I) |
|
521 |
apply (erule analz.induct, auto) |
|
522 |
done |
|
523 |
||
524 |
lemma lemma1: "Key (invKey K) \<in> analz H ==> |
|
525 |
analz (insert (Crypt K X) H) \<subseteq> |
|
526 |
insert (Crypt K X) (analz (insert X H))" |
|
527 |
apply (rule subsetI) |
|
23755 | 528 |
apply (erule_tac x = x in analz.induct, auto) |
14199 | 529 |
done |
530 |
||
531 |
lemma lemma2: "Key (invKey K) \<in> analz H ==> |
|
532 |
insert (Crypt K X) (analz (insert X H)) \<subseteq> |
|
533 |
analz (insert (Crypt K X) H)" |
|
534 |
apply auto |
|
23755 | 535 |
apply (erule_tac x = x in analz.induct, auto) |
14199 | 536 |
apply (blast intro: analz_insertI analz.Decrypt) |
537 |
done |
|
538 |
||
539 |
lemma analz_insert_Decrypt: |
|
540 |
"Key (invKey K) \<in> analz H ==> |
|
541 |
analz (insert (Crypt K X) H) = |
|
542 |
insert (Crypt K X) (analz (insert X H))" |
|
543 |
by (intro equalityI lemma1 lemma2) |
|
544 |
||
545 |
(*Case analysis: either the message is secure, or it is not! |
|
546 |
Effective, but can cause subgoals to blow up! |
|
547 |
Use with split_if; apparently split_tac does not cope with patterns |
|
548 |
such as "analz (insert (Crypt K X) H)" *) |
|
549 |
lemma analz_Crypt_if [simp]: |
|
550 |
"analz (insert (Crypt K X) H) = |
|
551 |
(if (Key (invKey K) \<in> analz H) |
|
552 |
then insert (Crypt K X) (analz (insert X H)) |
|
553 |
else insert (Crypt K X) (analz H))" |
|
554 |
by (simp add: analz_insert_Crypt analz_insert_Decrypt) |
|
555 |
||
556 |
||
557 |
(*This rule supposes "for the sake of argument" that we have the key.*) |
|
558 |
lemma analz_insert_Crypt_subset: |
|
559 |
"analz (insert (Crypt K X) H) \<subseteq> |
|
560 |
insert (Crypt K X) (analz (insert X H))" |
|
561 |
apply (rule subsetI) |
|
562 |
apply (erule analz.induct, auto) |
|
563 |
done |
|
564 |
||
565 |
lemma analz_image_Key [simp]: "analz (Key`N) = Key`N" |
|
566 |
apply auto |
|
567 |
apply (erule analz.induct, auto) |
|
568 |
done |
|
569 |
||
570 |
lemma analz_image_Pan [simp]: "analz (Pan`A) = Pan`A" |
|
571 |
apply auto |
|
572 |
apply (erule analz.induct, auto) |
|
573 |
done |
|
574 |
||
575 |
||
576 |
subsubsection{*Idempotence and transitivity*} |
|
577 |
||
578 |
lemma analz_analzD [dest!]: "X\<in> analz (analz H) ==> X\<in> analz H" |
|
579 |
by (erule analz.induct, blast+) |
|
580 |
||
581 |
lemma analz_idem [simp]: "analz (analz H) = analz H" |
|
582 |
by blast |
|
583 |
||
584 |
lemma analz_trans: "[| X\<in> analz G; G \<subseteq> analz H |] ==> X\<in> analz H" |
|
585 |
by (drule analz_mono, blast) |
|
586 |
||
587 |
(*Cut; Lemma 2 of Lowe*) |
|
588 |
lemma analz_cut: "[| Y\<in> analz (insert X H); X\<in> analz H |] ==> Y\<in> analz H" |
|
589 |
by (erule analz_trans, blast) |
|
590 |
||
591 |
(*Cut can be proved easily by induction on |
|
592 |
"Y: analz (insert X H) ==> X: analz H --> Y: analz H" |
|
593 |
*) |
|
594 |
||
595 |
(*This rewrite rule helps in the simplification of messages that involve |
|
596 |
the forwarding of unknown components (X). Without it, removing occurrences |
|
597 |
of X can be very complicated. *) |
|
598 |
lemma analz_insert_eq: "X\<in> analz H ==> analz (insert X H) = analz H" |
|
599 |
by (blast intro: analz_cut analz_insertI) |
|
600 |
||
601 |
||
602 |
text{*A congruence rule for "analz"*} |
|
603 |
||
604 |
lemma analz_subset_cong: |
|
605 |
"[| analz G \<subseteq> analz G'; analz H \<subseteq> analz H' |
|
606 |
|] ==> analz (G \<union> H) \<subseteq> analz (G' \<union> H')" |
|
607 |
apply clarify |
|
608 |
apply (erule analz.induct) |
|
609 |
apply (best intro: analz_mono [THEN subsetD])+ |
|
610 |
done |
|
611 |
||
612 |
lemma analz_cong: |
|
613 |
"[| analz G = analz G'; analz H = analz H' |
|
614 |
|] ==> analz (G \<union> H) = analz (G' \<union> H')" |
|
615 |
by (intro equalityI analz_subset_cong, simp_all) |
|
616 |
||
617 |
lemma analz_insert_cong: |
|
618 |
"analz H = analz H' ==> analz(insert X H) = analz(insert X H')" |
|
619 |
by (force simp only: insert_def intro!: analz_cong) |
|
620 |
||
621 |
(*If there are no pairs or encryptions then analz does nothing*) |
|
622 |
lemma analz_trivial: |
|
623 |
"[| \<forall>X Y. {|X,Y|} \<notin> H; \<forall>X K. Crypt K X \<notin> H |] ==> analz H = H" |
|
624 |
apply safe |
|
625 |
apply (erule analz.induct, blast+) |
|
626 |
done |
|
627 |
||
628 |
(*These two are obsolete (with a single Spy) but cost little to prove...*) |
|
629 |
lemma analz_UN_analz_lemma: |
|
630 |
"X\<in> analz (\<Union>i\<in>A. analz (H i)) ==> X\<in> analz (\<Union>i\<in>A. H i)" |
|
631 |
apply (erule analz.induct) |
|
632 |
apply (blast intro: analz_mono [THEN [2] rev_subsetD])+ |
|
633 |
done |
|
634 |
||
635 |
lemma analz_UN_analz [simp]: "analz (\<Union>i\<in>A. analz (H i)) = analz (\<Union>i\<in>A. H i)" |
|
636 |
by (blast intro: analz_UN_analz_lemma analz_mono [THEN [2] rev_subsetD]) |
|
637 |
||
638 |
||
639 |
subsection{*Inductive relation "synth"*} |
|
640 |
||
641 |
text{*Inductive definition of "synth" -- what can be built up from a set of |
|
642 |
messages. A form of upward closure. Pairs can be built, messages |
|
643 |
encrypted with known keys. Agent names are public domain. |
|
644 |
Numbers can be guessed, but Nonces cannot be.*} |
|
645 |
||
23755 | 646 |
inductive_set |
647 |
synth :: "msg set => msg set" |
|
648 |
for H :: "msg set" |
|
649 |
where |
|
14199 | 650 |
Inj [intro]: "X \<in> H ==> X \<in> synth H" |
23755 | 651 |
| Agent [intro]: "Agent agt \<in> synth H" |
652 |
| Number [intro]: "Number n \<in> synth H" |
|
653 |
| Hash [intro]: "X \<in> synth H ==> Hash X \<in> synth H" |
|
654 |
| MPair [intro]: "[|X \<in> synth H; Y \<in> synth H|] ==> {|X,Y|} \<in> synth H" |
|
655 |
| Crypt [intro]: "[|X \<in> synth H; Key(K) \<in> H|] ==> Crypt K X \<in> synth H" |
|
14199 | 656 |
|
657 |
(*Monotonicity*) |
|
658 |
lemma synth_mono: "G<=H ==> synth(G) <= synth(H)" |
|
659 |
apply auto |
|
660 |
apply (erule synth.induct) |
|
661 |
apply (auto dest: Fst Snd Body) |
|
662 |
done |
|
663 |
||
664 |
(*NO Agent_synth, as any Agent name can be synthesized. Ditto for Number*) |
|
665 |
inductive_cases Nonce_synth [elim!]: "Nonce n \<in> synth H" |
|
666 |
inductive_cases Key_synth [elim!]: "Key K \<in> synth H" |
|
667 |
inductive_cases Hash_synth [elim!]: "Hash X \<in> synth H" |
|
668 |
inductive_cases MPair_synth [elim!]: "{|X,Y|} \<in> synth H" |
|
669 |
inductive_cases Crypt_synth [elim!]: "Crypt K X \<in> synth H" |
|
670 |
inductive_cases Pan_synth [elim!]: "Pan A \<in> synth H" |
|
671 |
||
672 |
||
673 |
lemma synth_increasing: "H \<subseteq> synth(H)" |
|
674 |
by blast |
|
675 |
||
676 |
subsubsection{*Unions*} |
|
677 |
||
678 |
(*Converse fails: we can synth more from the union than from the |
|
679 |
separate parts, building a compound message using elements of each.*) |
|
680 |
lemma synth_Un: "synth(G) \<union> synth(H) \<subseteq> synth(G \<union> H)" |
|
681 |
by (intro Un_least synth_mono Un_upper1 Un_upper2) |
|
682 |
||
683 |
lemma synth_insert: "insert X (synth H) \<subseteq> synth(insert X H)" |
|
684 |
by (blast intro: synth_mono [THEN [2] rev_subsetD]) |
|
685 |
||
686 |
subsubsection{*Idempotence and transitivity*} |
|
687 |
||
688 |
lemma synth_synthD [dest!]: "X\<in> synth (synth H) ==> X\<in> synth H" |
|
689 |
by (erule synth.induct, blast+) |
|
690 |
||
691 |
lemma synth_idem: "synth (synth H) = synth H" |
|
692 |
by blast |
|
693 |
||
694 |
lemma synth_trans: "[| X\<in> synth G; G \<subseteq> synth H |] ==> X\<in> synth H" |
|
695 |
by (drule synth_mono, blast) |
|
696 |
||
697 |
(*Cut; Lemma 2 of Lowe*) |
|
698 |
lemma synth_cut: "[| Y\<in> synth (insert X H); X\<in> synth H |] ==> Y\<in> synth H" |
|
699 |
by (erule synth_trans, blast) |
|
700 |
||
701 |
lemma Agent_synth [simp]: "Agent A \<in> synth H" |
|
702 |
by blast |
|
703 |
||
704 |
lemma Number_synth [simp]: "Number n \<in> synth H" |
|
705 |
by blast |
|
706 |
||
707 |
lemma Nonce_synth_eq [simp]: "(Nonce N \<in> synth H) = (Nonce N \<in> H)" |
|
708 |
by blast |
|
709 |
||
710 |
lemma Key_synth_eq [simp]: "(Key K \<in> synth H) = (Key K \<in> H)" |
|
711 |
by blast |
|
712 |
||
713 |
lemma Crypt_synth_eq [simp]: "Key K \<notin> H ==> (Crypt K X \<in> synth H) = (Crypt K X \<in> H)" |
|
714 |
by blast |
|
715 |
||
716 |
lemma Pan_synth_eq [simp]: "(Pan A \<in> synth H) = (Pan A \<in> H)" |
|
717 |
by blast |
|
718 |
||
719 |
lemma keysFor_synth [simp]: |
|
720 |
"keysFor (synth H) = keysFor H \<union> invKey`{K. Key K \<in> H}" |
|
721 |
by (unfold keysFor_def, blast) |
|
722 |
||
723 |
||
724 |
subsubsection{*Combinations of parts, analz and synth*} |
|
725 |
||
726 |
lemma parts_synth [simp]: "parts (synth H) = parts H \<union> synth H" |
|
727 |
apply (rule equalityI) |
|
728 |
apply (rule subsetI) |
|
729 |
apply (erule parts.induct) |
|
730 |
apply (blast intro: synth_increasing [THEN parts_mono, THEN subsetD] |
|
731 |
parts.Fst parts.Snd parts.Body)+ |
|
732 |
done |
|
733 |
||
734 |
lemma analz_analz_Un [simp]: "analz (analz G \<union> H) = analz (G \<union> H)" |
|
735 |
apply (intro equalityI analz_subset_cong)+ |
|
736 |
apply simp_all |
|
737 |
done |
|
738 |
||
739 |
lemma analz_synth_Un [simp]: "analz (synth G \<union> H) = analz (G \<union> H) \<union> synth G" |
|
740 |
apply (rule equalityI) |
|
741 |
apply (rule subsetI) |
|
742 |
apply (erule analz.induct) |
|
743 |
prefer 5 apply (blast intro: analz_mono [THEN [2] rev_subsetD]) |
|
744 |
apply (blast intro: analz.Fst analz.Snd analz.Decrypt)+ |
|
745 |
done |
|
746 |
||
747 |
lemma analz_synth [simp]: "analz (synth H) = analz H \<union> synth H" |
|
748 |
apply (cut_tac H = "{}" in analz_synth_Un) |
|
749 |
apply (simp (no_asm_use)) |
|
750 |
done |
|
751 |
||
752 |
||
753 |
subsubsection{*For reasoning about the Fake rule in traces*} |
|
754 |
||
755 |
lemma parts_insert_subset_Un: "X\<in> G ==> parts(insert X H) \<subseteq> parts G \<union> parts H" |
|
756 |
by (rule subset_trans [OF parts_mono parts_Un_subset2], blast) |
|
757 |
||
758 |
(*More specifically for Fake. Very occasionally we could do with a version |
|
759 |
of the form parts{X} \<subseteq> synth (analz H) \<union> parts H *) |
|
760 |
lemma Fake_parts_insert: "X \<in> synth (analz H) ==> |
|
761 |
parts (insert X H) \<subseteq> synth (analz H) \<union> parts H" |
|
762 |
apply (drule parts_insert_subset_Un) |
|
763 |
apply (simp (no_asm_use)) |
|
764 |
apply blast |
|
765 |
done |
|
766 |
||
767 |
lemma Fake_parts_insert_in_Un: |
|
768 |
"[|Z \<in> parts (insert X H); X: synth (analz H)|] |
|
769 |
==> Z \<in> synth (analz H) \<union> parts H"; |
|
770 |
by (blast dest: Fake_parts_insert [THEN subsetD, dest]) |
|
771 |
||
772 |
(*H is sometimes (Key ` KK \<union> spies evs), so can't put G=H*) |
|
773 |
lemma Fake_analz_insert: |
|
774 |
"X\<in> synth (analz G) ==> |
|
775 |
analz (insert X H) \<subseteq> synth (analz G) \<union> analz (G \<union> H)" |
|
776 |
apply (rule subsetI) |
|
777 |
apply (subgoal_tac "x \<in> analz (synth (analz G) \<union> H) ") |
|
778 |
prefer 2 apply (blast intro: analz_mono [THEN [2] rev_subsetD] analz_mono [THEN synth_mono, THEN [2] rev_subsetD]) |
|
779 |
apply (simp (no_asm_use)) |
|
780 |
apply blast |
|
781 |
done |
|
782 |
||
783 |
lemma analz_conj_parts [simp]: |
|
784 |
"(X \<in> analz H & X \<in> parts H) = (X \<in> analz H)" |
|
785 |
by (blast intro: analz_subset_parts [THEN subsetD]) |
|
786 |
||
787 |
lemma analz_disj_parts [simp]: |
|
788 |
"(X \<in> analz H | X \<in> parts H) = (X \<in> parts H)" |
|
789 |
by (blast intro: analz_subset_parts [THEN subsetD]) |
|
790 |
||
791 |
(*Without this equation, other rules for synth and analz would yield |
|
792 |
redundant cases*) |
|
793 |
lemma MPair_synth_analz [iff]: |
|
794 |
"({|X,Y|} \<in> synth (analz H)) = |
|
795 |
(X \<in> synth (analz H) & Y \<in> synth (analz H))" |
|
796 |
by blast |
|
797 |
||
798 |
lemma Crypt_synth_analz: |
|
799 |
"[| Key K \<in> analz H; Key (invKey K) \<in> analz H |] |
|
800 |
==> (Crypt K X \<in> synth (analz H)) = (X \<in> synth (analz H))" |
|
801 |
by blast |
|
802 |
||
803 |
||
804 |
lemma Hash_synth_analz [simp]: |
|
805 |
"X \<notin> synth (analz H) |
|
806 |
==> (Hash{|X,Y|} \<in> synth (analz H)) = (Hash{|X,Y|} \<in> analz H)" |
|
807 |
by blast |
|
808 |
||
809 |
||
810 |
(*We do NOT want Crypt... messages broken up in protocols!!*) |
|
811 |
declare parts.Body [rule del] |
|
812 |
||
813 |
||
814 |
text{*Rewrites to push in Key and Crypt messages, so that other messages can |
|
815 |
be pulled out using the @{text analz_insert} rules*} |
|
816 |
||
27225 | 817 |
lemmas pushKeys [standard] = |
818 |
insert_commute [of "Key K" "Agent C"] |
|
819 |
insert_commute [of "Key K" "Nonce N"] |
|
820 |
insert_commute [of "Key K" "Number N"] |
|
821 |
insert_commute [of "Key K" "Pan PAN"] |
|
822 |
insert_commute [of "Key K" "Hash X"] |
|
823 |
insert_commute [of "Key K" "MPair X Y"] |
|
824 |
insert_commute [of "Key K" "Crypt X K'"] |
|
14199 | 825 |
|
27225 | 826 |
lemmas pushCrypts [standard] = |
827 |
insert_commute [of "Crypt X K" "Agent C"] |
|
828 |
insert_commute [of "Crypt X K" "Nonce N"] |
|
829 |
insert_commute [of "Crypt X K" "Number N"] |
|
830 |
insert_commute [of "Crypt X K" "Pan PAN"] |
|
831 |
insert_commute [of "Crypt X K" "Hash X'"] |
|
832 |
insert_commute [of "Crypt X K" "MPair X' Y"] |
|
14199 | 833 |
|
834 |
text{*Cannot be added with @{text "[simp]"} -- messages should not always be |
|
835 |
re-ordered.*} |
|
836 |
lemmas pushes = pushKeys pushCrypts |
|
837 |
||
838 |
||
839 |
subsection{*Tactics useful for many protocol proofs*} |
|
14218 | 840 |
(*<*) |
14199 | 841 |
ML |
842 |
{* |
|
24123 | 843 |
structure MessageSET = |
844 |
struct |
|
14199 | 845 |
|
846 |
(*Prove base case (subgoal i) and simplify others. A typical base case |
|
847 |
concerns Crypt K X \<notin> Key`shrK`bad and cannot be proved by rewriting |
|
848 |
alone.*) |
|
849 |
fun prove_simple_subgoals_tac i = |
|
26342 | 850 |
CLASIMPSET' (fn (cs, ss) => force_tac (cs, ss addsimps [@{thm image_eq_UN}])) i THEN |
851 |
ALLGOALS (SIMPSET' asm_simp_tac) |
|
14199 | 852 |
|
853 |
(*Analysis of Fake cases. Also works for messages that forward unknown parts, |
|
854 |
but this application is no longer necessary if analz_insert_eq is used. |
|
855 |
Abstraction over i is ESSENTIAL: it delays the dereferencing of claset |
|
856 |
DEPENDS UPON "X" REFERRING TO THE FRADULENT MESSAGE *) |
|
857 |
||
858 |
(*Apply rules to break down assumptions of the form |
|
859 |
Y \<in> parts(insert X H) and Y \<in> analz(insert X H) |
|
860 |
*) |
|
861 |
val Fake_insert_tac = |
|
24123 | 862 |
dresolve_tac [impOfSubs @{thm Fake_analz_insert}, |
863 |
impOfSubs @{thm Fake_parts_insert}] THEN' |
|
864 |
eresolve_tac [asm_rl, @{thm synth.Inj}]; |
|
14199 | 865 |
|
866 |
fun Fake_insert_simp_tac ss i = |
|
867 |
REPEAT (Fake_insert_tac i) THEN asm_full_simp_tac ss i; |
|
868 |
||
869 |
fun atomic_spy_analz_tac (cs,ss) = SELECT_GOAL |
|
870 |
(Fake_insert_simp_tac ss 1 |
|
871 |
THEN |
|
872 |
IF_UNSOLVED (Blast.depth_tac |
|
24123 | 873 |
(cs addIs [@{thm analz_insertI}, |
874 |
impOfSubs @{thm analz_subset_parts}]) 4 1)) |
|
14199 | 875 |
|
876 |
(*The explicit claset and simpset arguments help it work with Isar*) |
|
877 |
fun gen_spy_analz_tac (cs,ss) i = |
|
878 |
DETERM |
|
879 |
(SELECT_GOAL |
|
880 |
(EVERY |
|
881 |
[ (*push in occurrences of X...*) |
|
882 |
(REPEAT o CHANGED) |
|
27239 | 883 |
(res_inst_tac (Simplifier.the_context ss) |
27147 | 884 |
[(("x", 1), "X")] (insert_commute RS ssubst) 1), |
14199 | 885 |
(*...allowing further simplifications*) |
886 |
simp_tac ss 1, |
|
887 |
REPEAT (FIRSTGOAL (resolve_tac [allI,impI,notI,conjI,iffI])), |
|
888 |
DEPTH_SOLVE (atomic_spy_analz_tac (cs,ss) 1)]) i) |
|
889 |
||
26342 | 890 |
val spy_analz_tac = CLASIMPSET' gen_spy_analz_tac; |
24123 | 891 |
|
892 |
end |
|
14199 | 893 |
*} |
14218 | 894 |
(*>*) |
895 |
||
14199 | 896 |
|
897 |
(*By default only o_apply is built-in. But in the presence of eta-expansion |
|
898 |
this means that some terms displayed as (f o g) will be rewritten, and others |
|
899 |
will not!*) |
|
900 |
declare o_def [simp] |
|
901 |
||
902 |
||
903 |
lemma Crypt_notin_image_Key [simp]: "Crypt K X \<notin> Key ` A" |
|
904 |
by auto |
|
905 |
||
906 |
lemma Hash_notin_image_Key [simp] :"Hash X \<notin> Key ` A" |
|
907 |
by auto |
|
908 |
||
909 |
lemma synth_analz_mono: "G<=H ==> synth (analz(G)) <= synth (analz(H))" |
|
910 |
by (simp add: synth_mono analz_mono) |
|
911 |
||
912 |
lemma Fake_analz_eq [simp]: |
|
913 |
"X \<in> synth(analz H) ==> synth (analz (insert X H)) = synth (analz H)" |
|
914 |
apply (drule Fake_analz_insert[of _ _ "H"]) |
|
915 |
apply (simp add: synth_increasing[THEN Un_absorb2]) |
|
916 |
apply (drule synth_mono) |
|
917 |
apply (simp add: synth_idem) |
|
918 |
apply (blast intro: synth_analz_mono [THEN [2] rev_subsetD]) |
|
919 |
done |
|
920 |
||
921 |
text{*Two generalizations of @{text analz_insert_eq}*} |
|
922 |
lemma gen_analz_insert_eq [rule_format]: |
|
923 |
"X \<in> analz H ==> ALL G. H \<subseteq> G --> analz (insert X G) = analz G"; |
|
924 |
by (blast intro: analz_cut analz_insertI analz_mono [THEN [2] rev_subsetD]) |
|
925 |
||
926 |
lemma synth_analz_insert_eq [rule_format]: |
|
927 |
"X \<in> synth (analz H) |
|
928 |
==> ALL G. H \<subseteq> G --> (Key K \<in> analz (insert X G)) = (Key K \<in> analz G)"; |
|
929 |
apply (erule synth.induct) |
|
930 |
apply (simp_all add: gen_analz_insert_eq subset_trans [OF _ subset_insertI]) |
|
931 |
done |
|
932 |
||
933 |
lemma Fake_parts_sing: |
|
934 |
"X \<in> synth (analz H) ==> parts{X} \<subseteq> synth (analz H) \<union> parts H"; |
|
935 |
apply (rule subset_trans) |
|
936 |
apply (erule_tac [2] Fake_parts_insert) |
|
937 |
apply (simp add: parts_mono) |
|
938 |
done |
|
939 |
||
940 |
lemmas Fake_parts_sing_imp_Un = Fake_parts_sing [THEN [2] rev_subsetD] |
|
941 |
||
942 |
method_setup spy_analz = {* |
|
30549 | 943 |
Scan.succeed (fn ctxt => |
30510
4120fc59dd85
unified type Proof.method and pervasive METHOD combinators;
wenzelm
parents:
29888
diff
changeset
|
944 |
SIMPLE_METHOD' (MessageSET.gen_spy_analz_tac (local_clasimpset_of ctxt))) *} |
14199 | 945 |
"for proving the Fake case when analz is involved" |
946 |
||
947 |
method_setup atomic_spy_analz = {* |
|
30549 | 948 |
Scan.succeed (fn ctxt => |
30510
4120fc59dd85
unified type Proof.method and pervasive METHOD combinators;
wenzelm
parents:
29888
diff
changeset
|
949 |
SIMPLE_METHOD' (MessageSET.atomic_spy_analz_tac (local_clasimpset_of ctxt))) *} |
14199 | 950 |
"for debugging spy_analz" |
951 |
||
952 |
method_setup Fake_insert_simp = {* |
|
30549 | 953 |
Scan.succeed (fn ctxt => |
30510
4120fc59dd85
unified type Proof.method and pervasive METHOD combinators;
wenzelm
parents:
29888
diff
changeset
|
954 |
SIMPLE_METHOD' (MessageSET.Fake_insert_simp_tac (local_simpset_of ctxt))) *} |
14199 | 955 |
"for debugging spy_analz" |
956 |
||
957 |
end |