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