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