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