author | haftmann |
Wed, 08 Sep 2010 19:21:46 +0200 | |
changeset 39246 | 9e58f0499f57 |
parent 35418 | 83b0f75810f0 |
child 41775 | 6214816d79d3 |
permissions | -rw-r--r-- |
13508 | 1 |
(****************************************************************************** |
2 |
date: november 2001 |
|
3 |
author: Frederic Blanqui |
|
4 |
email: blanqui@lri.fr |
|
5 |
webpage: http://www.lri.fr/~blanqui/ |
|
6 |
||
7 |
University of Cambridge, Computer Laboratory |
|
8 |
William Gates Building, JJ Thomson Avenue |
|
9 |
Cambridge CB3 0FD, United Kingdom |
|
10 |
******************************************************************************) |
|
11 |
||
12 |
header {*Extensions to Standard Theories*} |
|
13 |
||
32695 | 14 |
theory Extensions |
15 |
imports "../Event" |
|
16 |
begin |
|
13508 | 17 |
|
18 |
subsection{*Extensions to Theory @{text Set}*} |
|
19 |
||
20 |
lemma eq: "[| !!x. x:A ==> x:B; !!x. x:B ==> x:A |] ==> A=B" |
|
21 |
by auto |
|
22 |
||
23 |
lemma insert_Un: "P ({x} Un A) ==> P (insert x A)" |
|
24 |
by simp |
|
25 |
||
26 |
lemma in_sub: "x:A ==> {x}<=A" |
|
27 |
by auto |
|
28 |
||
29 |
||
30 |
subsection{*Extensions to Theory @{text List}*} |
|
31 |
||
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18557
diff
changeset
|
32 |
subsubsection{*"remove l x" erase the first element of "l" equal to "x"*} |
13508 | 33 |
|
39246 | 34 |
primrec remove :: "'a list => 'a => 'a list" where |
35 |
"remove [] y = []" | |
|
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18557
diff
changeset
|
36 |
"remove (x#xs) y = (if x=y then xs else x # remove xs y)" |
13508 | 37 |
|
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18557
diff
changeset
|
38 |
lemma set_remove: "set (remove l x) <= set l" |
13508 | 39 |
by (induct l, auto) |
40 |
||
41 |
subsection{*Extensions to Theory @{text Message}*} |
|
42 |
||
43 |
subsubsection{*declarations for tactics*} |
|
44 |
||
45 |
declare analz_subset_parts [THEN subsetD, dest] |
|
46 |
declare image_eq_UN [simp] |
|
47 |
declare parts_insert2 [simp] |
|
48 |
declare analz_cut [dest] |
|
49 |
declare split_if_asm [split] |
|
50 |
declare analz_insertI [intro] |
|
51 |
declare Un_Diff [simp] |
|
52 |
||
53 |
subsubsection{*extract the agent number of an Agent message*} |
|
54 |
||
35418 | 55 |
primrec agt_nb :: "msg => agent" where |
13508 | 56 |
"agt_nb (Agent A) = A" |
57 |
||
58 |
subsubsection{*messages that are pairs*} |
|
59 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
60 |
definition is_MPair :: "msg => bool" where |
13508 | 61 |
"is_MPair X == EX Y Z. X = {|Y,Z|}" |
62 |
||
63 |
declare is_MPair_def [simp] |
|
64 |
||
65 |
lemma MPair_is_MPair [iff]: "is_MPair {|X,Y|}" |
|
66 |
by simp |
|
67 |
||
68 |
lemma Agent_isnt_MPair [iff]: "~ is_MPair (Agent A)" |
|
69 |
by simp |
|
70 |
||
71 |
lemma Number_isnt_MPair [iff]: "~ is_MPair (Number n)" |
|
72 |
by simp |
|
73 |
||
74 |
lemma Key_isnt_MPair [iff]: "~ is_MPair (Key K)" |
|
75 |
by simp |
|
76 |
||
77 |
lemma Nonce_isnt_MPair [iff]: "~ is_MPair (Nonce n)" |
|
78 |
by simp |
|
79 |
||
80 |
lemma Hash_isnt_MPair [iff]: "~ is_MPair (Hash X)" |
|
81 |
by simp |
|
82 |
||
83 |
lemma Crypt_isnt_MPair [iff]: "~ is_MPair (Crypt K X)" |
|
84 |
by simp |
|
85 |
||
20768 | 86 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
20768
diff
changeset
|
87 |
not_MPair :: "msg => bool" where |
20768 | 88 |
"not_MPair X == ~ is_MPair X" |
13508 | 89 |
|
90 |
lemma is_MPairE: "[| is_MPair X ==> P; not_MPair X ==> P |] ==> P" |
|
91 |
by auto |
|
92 |
||
93 |
declare is_MPair_def [simp del] |
|
94 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
95 |
definition has_no_pair :: "msg set => bool" where |
13508 | 96 |
"has_no_pair H == ALL X Y. {|X,Y|} ~:H" |
97 |
||
98 |
declare has_no_pair_def [simp] |
|
99 |
||
100 |
subsubsection{*well-foundedness of messages*} |
|
101 |
||
102 |
lemma wf_Crypt1 [iff]: "Crypt K X ~= X" |
|
103 |
by (induct X, auto) |
|
104 |
||
105 |
lemma wf_Crypt2 [iff]: "X ~= Crypt K X" |
|
106 |
by (induct X, auto) |
|
107 |
||
108 |
lemma parts_size: "X:parts {Y} ==> X=Y | size X < size Y" |
|
109 |
by (erule parts.induct, auto) |
|
110 |
||
111 |
lemma wf_Crypt_parts [iff]: "Crypt K X ~:parts {X}" |
|
112 |
by (auto dest: parts_size) |
|
113 |
||
114 |
subsubsection{*lemmas on keysFor*} |
|
115 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
116 |
definition usekeys :: "msg set => key set" where |
13508 | 117 |
"usekeys G == {K. EX Y. Crypt K Y:G}" |
118 |
||
119 |
lemma finite_keysFor [intro]: "finite G ==> finite (keysFor G)" |
|
120 |
apply (simp add: keysFor_def) |
|
121 |
apply (rule finite_UN_I, auto) |
|
122 |
apply (erule finite_induct, auto) |
|
123 |
apply (case_tac "EX K X. x = Crypt K X", clarsimp) |
|
124 |
apply (subgoal_tac "{Ka. EX Xa. (Ka=K & Xa=X) | Crypt Ka Xa:F} |
|
125 |
= insert K (usekeys F)", auto simp: usekeys_def) |
|
126 |
by (subgoal_tac "{K. EX X. Crypt K X = x | Crypt K X:F} = usekeys F", |
|
127 |
auto simp: usekeys_def) |
|
128 |
||
129 |
subsubsection{*lemmas on parts*} |
|
130 |
||
131 |
lemma parts_sub: "[| X:parts G; G<=H |] ==> X:parts H" |
|
132 |
by (auto dest: parts_mono) |
|
133 |
||
134 |
lemma parts_Diff [dest]: "X:parts (G - H) ==> X:parts G" |
|
135 |
by (erule parts_sub, auto) |
|
136 |
||
137 |
lemma parts_Diff_notin: "[| Y ~:H; Nonce n ~:parts (H - {Y}) |] |
|
138 |
==> Nonce n ~:parts H" |
|
139 |
by simp |
|
140 |
||
141 |
lemmas parts_insert_substI = parts_insert [THEN ssubst] |
|
142 |
lemmas parts_insert_substD = parts_insert [THEN sym, THEN ssubst] |
|
143 |
||
144 |
lemma finite_parts_msg [iff]: "finite (parts {X})" |
|
145 |
by (induct X, auto) |
|
146 |
||
147 |
lemma finite_parts [intro]: "finite H ==> finite (parts H)" |
|
148 |
apply (erule finite_induct, simp) |
|
149 |
by (rule parts_insert_substI, simp) |
|
150 |
||
151 |
lemma parts_parts: "[| X:parts {Y}; Y:parts G |] ==> X:parts G" |
|
17689
a04b5b43625e
streamlined theory; conformance to recent publication
paulson
parents:
16417
diff
changeset
|
152 |
by (frule parts_cut, auto) |
a04b5b43625e
streamlined theory; conformance to recent publication
paulson
parents:
16417
diff
changeset
|
153 |
|
13508 | 154 |
|
155 |
lemma parts_parts_parts: "[| X:parts {Y}; Y:parts {Z}; Z:parts G |] ==> X:parts G" |
|
156 |
by (auto dest: parts_parts) |
|
157 |
||
158 |
lemma parts_parts_Crypt: "[| Crypt K X:parts G; Nonce n:parts {X} |] |
|
159 |
==> Nonce n:parts G" |
|
160 |
by (blast intro: parts.Body dest: parts_parts) |
|
161 |
||
162 |
subsubsection{*lemmas on synth*} |
|
163 |
||
164 |
lemma synth_sub: "[| X:synth G; G<=H |] ==> X:synth H" |
|
165 |
by (auto dest: synth_mono) |
|
166 |
||
167 |
lemma Crypt_synth [rule_format]: "[| X:synth G; Key K ~:G |] ==> |
|
168 |
Crypt K Y:parts {X} --> Crypt K Y:parts G" |
|
169 |
by (erule synth.induct, auto dest: parts_sub) |
|
170 |
||
171 |
subsubsection{*lemmas on analz*} |
|
172 |
||
173 |
lemma analz_UnI1 [intro]: "X:analz G ==> X:analz (G Un H)" |
|
32695 | 174 |
by (subgoal_tac "G <= G Un H") (blast dest: analz_mono)+ |
13508 | 175 |
|
176 |
lemma analz_sub: "[| X:analz G; G <= H |] ==> X:analz H" |
|
177 |
by (auto dest: analz_mono) |
|
178 |
||
179 |
lemma analz_Diff [dest]: "X:analz (G - H) ==> X:analz G" |
|
180 |
by (erule analz.induct, auto) |
|
181 |
||
182 |
lemmas in_analz_subset_cong = analz_subset_cong [THEN subsetD] |
|
183 |
||
184 |
lemma analz_eq: "A=A' ==> analz A = analz A'" |
|
185 |
by auto |
|
186 |
||
187 |
lemmas insert_commute_substI = insert_commute [THEN ssubst] |
|
188 |
||
14307 | 189 |
lemma analz_insertD: |
190 |
"[| Crypt K Y:H; Key (invKey K):H |] ==> analz (insert Y H) = analz H" |
|
191 |
by (blast intro: analz.Decrypt analz_insert_eq) |
|
13508 | 192 |
|
193 |
lemma must_decrypt [rule_format,dest]: "[| X:analz H; has_no_pair H |] ==> |
|
194 |
X ~:H --> (EX K Y. Crypt K Y:H & Key (invKey K):H)" |
|
195 |
by (erule analz.induct, auto) |
|
196 |
||
197 |
lemma analz_needs_only_finite: "X:analz H ==> EX G. G <= H & finite G" |
|
198 |
by (erule analz.induct, auto) |
|
199 |
||
200 |
lemma notin_analz_insert: "X ~:analz (insert Y G) ==> X ~:analz G" |
|
201 |
by auto |
|
202 |
||
203 |
subsubsection{*lemmas on parts, synth and analz*} |
|
204 |
||
205 |
lemma parts_invKey [rule_format,dest]:"X:parts {Y} ==> |
|
206 |
X:analz (insert (Crypt K Y) H) --> X ~:analz H --> Key (invKey K):analz H" |
|
26809
da662ff93503
- Instantiated parts_insert_substD to avoid problems with HO unification
berghofe
parents:
21404
diff
changeset
|
207 |
by (erule parts.induct, (fastsimp dest: parts.Fst parts.Snd parts.Body)+) |
13508 | 208 |
|
209 |
lemma in_analz: "Y:analz H ==> EX X. X:H & Y:parts {X}" |
|
210 |
by (erule analz.induct, auto intro: parts.Fst parts.Snd parts.Body) |
|
211 |
||
212 |
lemmas in_analz_subset_parts = analz_subset_parts [THEN subsetD] |
|
213 |
||
214 |
lemma Crypt_synth_insert: "[| Crypt K X:parts (insert Y H); |
|
215 |
Y:synth (analz H); Key K ~:analz H |] ==> Crypt K X:parts H" |
|
26809
da662ff93503
- Instantiated parts_insert_substD to avoid problems with HO unification
berghofe
parents:
21404
diff
changeset
|
216 |
apply (drule parts_insert_substD [where P="%S. Crypt K X : S"], clarify) |
13508 | 217 |
apply (frule in_sub) |
218 |
apply (frule parts_mono) |
|
219 |
by auto |
|
220 |
||
221 |
subsubsection{*greatest nonce used in a message*} |
|
222 |
||
35418 | 223 |
fun greatest_msg :: "msg => nat" |
224 |
where |
|
225 |
"greatest_msg (Nonce n) = n" |
|
226 |
| "greatest_msg {|X,Y|} = max (greatest_msg X) (greatest_msg Y)" |
|
227 |
| "greatest_msg (Crypt K X) = greatest_msg X" |
|
228 |
| "greatest_msg other = 0" |
|
13508 | 229 |
|
230 |
lemma greatest_msg_is_greatest: "Nonce n:parts {X} ==> n <= greatest_msg X" |
|
20217
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents:
19233
diff
changeset
|
231 |
by (induct X, auto) |
13508 | 232 |
|
233 |
subsubsection{*sets of keys*} |
|
234 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
235 |
definition keyset :: "msg set => bool" where |
13508 | 236 |
"keyset G == ALL X. X:G --> (EX K. X = Key K)" |
237 |
||
238 |
lemma keyset_in [dest]: "[| keyset G; X:G |] ==> EX K. X = Key K" |
|
239 |
by (auto simp: keyset_def) |
|
240 |
||
241 |
lemma MPair_notin_keyset [simp]: "keyset G ==> {|X,Y|} ~:G" |
|
242 |
by auto |
|
243 |
||
244 |
lemma Crypt_notin_keyset [simp]: "keyset G ==> Crypt K X ~:G" |
|
245 |
by auto |
|
246 |
||
247 |
lemma Nonce_notin_keyset [simp]: "keyset G ==> Nonce n ~:G" |
|
248 |
by auto |
|
249 |
||
250 |
lemma parts_keyset [simp]: "keyset G ==> parts G = G" |
|
251 |
by (auto, erule parts.induct, auto) |
|
252 |
||
253 |
subsubsection{*keys a priori necessary for decrypting the messages of G*} |
|
254 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
255 |
definition keysfor :: "msg set => msg set" where |
13508 | 256 |
"keysfor G == Key ` keysFor (parts G)" |
257 |
||
258 |
lemma keyset_keysfor [iff]: "keyset (keysfor G)" |
|
259 |
by (simp add: keyset_def keysfor_def, blast) |
|
260 |
||
261 |
lemma keyset_Diff_keysfor [simp]: "keyset H ==> keyset (H - keysfor G)" |
|
262 |
by (auto simp: keyset_def) |
|
263 |
||
264 |
lemma keysfor_Crypt: "Crypt K X:parts G ==> Key (invKey K):keysfor G" |
|
265 |
by (auto simp: keysfor_def Crypt_imp_invKey_keysFor) |
|
266 |
||
267 |
lemma no_key_no_Crypt: "Key K ~:keysfor G ==> Crypt (invKey K) X ~:parts G" |
|
268 |
by (auto dest: keysfor_Crypt) |
|
269 |
||
270 |
lemma finite_keysfor [intro]: "finite G ==> finite (keysfor G)" |
|
271 |
by (auto simp: keysfor_def intro: finite_UN_I) |
|
272 |
||
273 |
subsubsection{*only the keys necessary for G are useful in analz*} |
|
274 |
||
275 |
lemma analz_keyset: "keyset H ==> |
|
276 |
analz (G Un H) = H - keysfor G Un (analz (G Un (H Int keysfor G)))" |
|
277 |
apply (rule eq) |
|
278 |
apply (erule analz.induct, blast) |
|
18557
60a0f9caa0a2
Provers/classical: stricter checks to ensure that supplied intro, dest and
paulson
parents:
17689
diff
changeset
|
279 |
apply (simp, blast) |
60a0f9caa0a2
Provers/classical: stricter checks to ensure that supplied intro, dest and
paulson
parents:
17689
diff
changeset
|
280 |
apply (simp, blast) |
13508 | 281 |
apply (case_tac "Key (invKey K):H - keysfor G", clarsimp) |
282 |
apply (drule_tac X=X in no_key_no_Crypt) |
|
283 |
by (auto intro: analz_sub) |
|
284 |
||
285 |
lemmas analz_keyset_substD = analz_keyset [THEN sym, THEN ssubst] |
|
286 |
||
287 |
||
288 |
subsection{*Extensions to Theory @{text Event}*} |
|
289 |
||
290 |
||
291 |
subsubsection{*general protocol properties*} |
|
292 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
293 |
definition is_Says :: "event => bool" where |
13508 | 294 |
"is_Says ev == (EX A B X. ev = Says A B X)" |
295 |
||
296 |
lemma is_Says_Says [iff]: "is_Says (Says A B X)" |
|
297 |
by (simp add: is_Says_def) |
|
298 |
||
299 |
(* one could also require that Gets occurs after Says |
|
300 |
but this is sufficient for our purpose *) |
|
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
301 |
definition Gets_correct :: "event list set => bool" where |
13508 | 302 |
"Gets_correct p == ALL evs B X. evs:p --> Gets B X:set evs |
303 |
--> (EX A. Says A B X:set evs)" |
|
304 |
||
305 |
lemma Gets_correct_Says: "[| Gets_correct p; Gets B X # evs:p |] |
|
306 |
==> EX A. Says A B X:set evs" |
|
307 |
apply (simp add: Gets_correct_def) |
|
308 |
by (drule_tac x="Gets B X # evs" in spec, auto) |
|
309 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
310 |
definition one_step :: "event list set => bool" where |
13508 | 311 |
"one_step p == ALL evs ev. ev#evs:p --> evs:p" |
312 |
||
313 |
lemma one_step_Cons [dest]: "[| one_step p; ev#evs:p |] ==> evs:p" |
|
314 |
by (unfold one_step_def, blast) |
|
315 |
||
316 |
lemma one_step_app: "[| evs@evs':p; one_step p; []:p |] ==> evs':p" |
|
317 |
by (induct evs, auto) |
|
318 |
||
319 |
lemma trunc: "[| evs @ evs':p; one_step p |] ==> evs':p" |
|
320 |
by (induct evs, auto) |
|
321 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
322 |
definition has_only_Says :: "event list set => bool" where |
13508 | 323 |
"has_only_Says p == ALL evs ev. evs:p --> ev:set evs |
324 |
--> (EX A B X. ev = Says A B X)" |
|
325 |
||
326 |
lemma has_only_SaysD: "[| ev:set evs; evs:p; has_only_Says p |] |
|
327 |
==> EX A B X. ev = Says A B X" |
|
328 |
by (unfold has_only_Says_def, blast) |
|
329 |
||
330 |
lemma in_has_only_Says [dest]: "[| has_only_Says p; evs:p; ev:set evs |] |
|
331 |
==> EX A B X. ev = Says A B X" |
|
332 |
by (auto simp: has_only_Says_def) |
|
333 |
||
334 |
lemma has_only_Says_imp_Gets_correct [simp]: "has_only_Says p |
|
335 |
==> Gets_correct p" |
|
336 |
by (auto simp: has_only_Says_def Gets_correct_def) |
|
337 |
||
338 |
subsubsection{*lemma on knows*} |
|
339 |
||
340 |
lemma Says_imp_spies2: "Says A B {|X,Y|}:set evs ==> Y:parts (spies evs)" |
|
341 |
by (drule Says_imp_spies, drule parts.Inj, drule parts.Snd, simp) |
|
342 |
||
343 |
lemma Says_not_parts: "[| Says A B X:set evs; Y ~:parts (spies evs) |] |
|
344 |
==> Y ~:parts {X}" |
|
345 |
by (auto dest: Says_imp_spies parts_parts) |
|
346 |
||
347 |
subsubsection{*knows without initState*} |
|
348 |
||
39246 | 349 |
primrec knows' :: "agent => event list => msg set" where |
350 |
knows'_Nil: "knows' A [] = {}" | |
|
351 |
knows'_Cons0: |
|
14307 | 352 |
"knows' A (ev # evs) = ( |
353 |
if A = Spy then ( |
|
354 |
case ev of |
|
355 |
Says A' B X => insert X (knows' A evs) |
|
356 |
| Gets A' X => knows' A evs |
|
357 |
| Notes A' X => if A':bad then insert X (knows' A evs) else knows' A evs |
|
358 |
) else ( |
|
359 |
case ev of |
|
360 |
Says A' B X => if A=A' then insert X (knows' A evs) else knows' A evs |
|
361 |
| Gets A' X => if A=A' then insert X (knows' A evs) else knows' A evs |
|
362 |
| Notes A' X => if A=A' then insert X (knows' A evs) else knows' A evs |
|
363 |
))" |
|
13508 | 364 |
|
20768 | 365 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
20768
diff
changeset
|
366 |
spies' :: "event list => msg set" where |
20768 | 367 |
"spies' == knows' Spy" |
13508 | 368 |
|
369 |
subsubsection{*decomposition of knows into knows' and initState*} |
|
370 |
||
371 |
lemma knows_decomp: "knows A evs = knows' A evs Un (initState A)" |
|
372 |
by (induct evs, auto split: event.split simp: knows.simps) |
|
373 |
||
374 |
lemmas knows_decomp_substI = knows_decomp [THEN ssubst] |
|
375 |
lemmas knows_decomp_substD = knows_decomp [THEN sym, THEN ssubst] |
|
376 |
||
377 |
lemma knows'_sub_knows: "knows' A evs <= knows A evs" |
|
378 |
by (auto simp: knows_decomp) |
|
379 |
||
380 |
lemma knows'_Cons: "knows' A (ev#evs) = knows' A [ev] Un knows' A evs" |
|
381 |
by (induct ev, auto) |
|
382 |
||
383 |
lemmas knows'_Cons_substI = knows'_Cons [THEN ssubst] |
|
384 |
lemmas knows'_Cons_substD = knows'_Cons [THEN sym, THEN ssubst] |
|
385 |
||
386 |
lemma knows_Cons: "knows A (ev#evs) = initState A Un knows' A [ev] |
|
387 |
Un knows A evs" |
|
388 |
apply (simp only: knows_decomp) |
|
389 |
apply (rule_tac s="(knows' A [ev] Un knows' A evs) Un initState A" in trans) |
|
14307 | 390 |
apply (simp only: knows'_Cons [of A ev evs] Un_ac) |
391 |
apply blast |
|
392 |
done |
|
393 |
||
13508 | 394 |
|
395 |
lemmas knows_Cons_substI = knows_Cons [THEN ssubst] |
|
396 |
lemmas knows_Cons_substD = knows_Cons [THEN sym, THEN ssubst] |
|
397 |
||
398 |
lemma knows'_sub_spies': "[| evs:p; has_only_Says p; one_step p |] |
|
399 |
==> knows' A evs <= spies' evs" |
|
400 |
by (induct evs, auto split: event.splits) |
|
401 |
||
402 |
subsubsection{*knows' is finite*} |
|
403 |
||
404 |
lemma finite_knows' [iff]: "finite (knows' A evs)" |
|
405 |
by (induct evs, auto split: event.split simp: knows.simps) |
|
406 |
||
407 |
subsubsection{*monotonicity of knows*} |
|
408 |
||
409 |
lemma knows_sub_Cons: "knows A evs <= knows A (ev#evs)" |
|
13596 | 410 |
by(cases A, induct evs, auto simp: knows.simps split:event.split) |
13508 | 411 |
|
412 |
lemma knows_ConsI: "X:knows A evs ==> X:knows A (ev#evs)" |
|
413 |
by (auto dest: knows_sub_Cons [THEN subsetD]) |
|
414 |
||
415 |
lemma knows_sub_app: "knows A evs <= knows A (evs @ evs')" |
|
416 |
apply (induct evs, auto) |
|
417 |
apply (simp add: knows_decomp) |
|
418 |
by (case_tac a, auto simp: knows.simps) |
|
419 |
||
420 |
subsubsection{*maximum knowledge an agent can have |
|
421 |
includes messages sent to the agent*} |
|
422 |
||
39246 | 423 |
primrec knows_max' :: "agent => event list => msg set" where |
424 |
knows_max'_def_Nil: "knows_max' A [] = {}" | |
|
13508 | 425 |
knows_max'_def_Cons: "knows_max' A (ev # evs) = ( |
426 |
if A=Spy then ( |
|
427 |
case ev of |
|
428 |
Says A' B X => insert X (knows_max' A evs) |
|
429 |
| Gets A' X => knows_max' A evs |
|
430 |
| Notes A' X => |
|
431 |
if A':bad then insert X (knows_max' A evs) else knows_max' A evs |
|
432 |
) else ( |
|
433 |
case ev of |
|
434 |
Says A' B X => |
|
435 |
if A=A' | A=B then insert X (knows_max' A evs) else knows_max' A evs |
|
436 |
| Gets A' X => |
|
437 |
if A=A' then insert X (knows_max' A evs) else knows_max' A evs |
|
438 |
| Notes A' X => |
|
439 |
if A=A' then insert X (knows_max' A evs) else knows_max' A evs |
|
440 |
))" |
|
441 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
442 |
definition knows_max :: "agent => event list => msg set" where |
13508 | 443 |
"knows_max A evs == knows_max' A evs Un initState A" |
444 |
||
20768 | 445 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
20768
diff
changeset
|
446 |
spies_max :: "event list => msg set" where |
20768 | 447 |
"spies_max evs == knows_max Spy evs" |
13508 | 448 |
|
449 |
subsubsection{*basic facts about @{term knows_max}*} |
|
450 |
||
451 |
lemma spies_max_spies [iff]: "spies_max evs = spies evs" |
|
452 |
by (induct evs, auto simp: knows_max_def split: event.splits) |
|
453 |
||
454 |
lemma knows_max'_Cons: "knows_max' A (ev#evs) |
|
455 |
= knows_max' A [ev] Un knows_max' A evs" |
|
456 |
by (auto split: event.splits) |
|
457 |
||
458 |
lemmas knows_max'_Cons_substI = knows_max'_Cons [THEN ssubst] |
|
459 |
lemmas knows_max'_Cons_substD = knows_max'_Cons [THEN sym, THEN ssubst] |
|
460 |
||
461 |
lemma knows_max_Cons: "knows_max A (ev#evs) |
|
462 |
= knows_max' A [ev] Un knows_max A evs" |
|
463 |
apply (simp add: knows_max_def del: knows_max'_def_Cons) |
|
464 |
apply (rule_tac evs1=evs in knows_max'_Cons_substI) |
|
465 |
by blast |
|
466 |
||
467 |
lemmas knows_max_Cons_substI = knows_max_Cons [THEN ssubst] |
|
468 |
lemmas knows_max_Cons_substD = knows_max_Cons [THEN sym, THEN ssubst] |
|
469 |
||
470 |
lemma finite_knows_max' [iff]: "finite (knows_max' A evs)" |
|
471 |
by (induct evs, auto split: event.split) |
|
472 |
||
473 |
lemma knows_max'_sub_spies': "[| evs:p; has_only_Says p; one_step p |] |
|
474 |
==> knows_max' A evs <= spies' evs" |
|
475 |
by (induct evs, auto split: event.splits) |
|
476 |
||
477 |
lemma knows_max'_in_spies' [dest]: "[| evs:p; X:knows_max' A evs; |
|
478 |
has_only_Says p; one_step p |] ==> X:spies' evs" |
|
479 |
by (rule knows_max'_sub_spies' [THEN subsetD], auto) |
|
480 |
||
481 |
lemma knows_max'_app: "knows_max' A (evs @ evs') |
|
482 |
= knows_max' A evs Un knows_max' A evs'" |
|
483 |
by (induct evs, auto split: event.splits) |
|
484 |
||
485 |
lemma Says_to_knows_max': "Says A B X:set evs ==> X:knows_max' B evs" |
|
486 |
by (simp add: in_set_conv_decomp, clarify, simp add: knows_max'_app) |
|
487 |
||
488 |
lemma Says_from_knows_max': "Says A B X:set evs ==> X:knows_max' A evs" |
|
489 |
by (simp add: in_set_conv_decomp, clarify, simp add: knows_max'_app) |
|
490 |
||
491 |
subsubsection{*used without initState*} |
|
492 |
||
39246 | 493 |
primrec used' :: "event list => msg set" where |
494 |
"used' [] = {}" | |
|
13508 | 495 |
"used' (ev # evs) = ( |
496 |
case ev of |
|
497 |
Says A B X => parts {X} Un used' evs |
|
498 |
| Gets A X => used' evs |
|
499 |
| Notes A X => parts {X} Un used' evs |
|
500 |
)" |
|
501 |
||
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
32695
diff
changeset
|
502 |
definition init :: "msg set" where |
13508 | 503 |
"init == used []" |
504 |
||
505 |
lemma used_decomp: "used evs = init Un used' evs" |
|
506 |
by (induct evs, auto simp: init_def split: event.split) |
|
507 |
||
508 |
lemma used'_sub_app: "used' evs <= used' (evs@evs')" |
|
509 |
by (induct evs, auto split: event.split) |
|
510 |
||
511 |
lemma used'_parts [rule_format]: "X:used' evs ==> Y:parts {X} --> Y:used' evs" |
|
512 |
apply (induct evs, simp) |
|
513 |
apply (case_tac a, simp_all) |
|
514 |
apply (blast dest: parts_trans)+; |
|
515 |
done |
|
516 |
||
517 |
subsubsection{*monotonicity of used*} |
|
518 |
||
519 |
lemma used_sub_Cons: "used evs <= used (ev#evs)" |
|
520 |
by (induct evs, (induct ev, auto)+) |
|
521 |
||
522 |
lemma used_ConsI: "X:used evs ==> X:used (ev#evs)" |
|
523 |
by (auto dest: used_sub_Cons [THEN subsetD]) |
|
524 |
||
525 |
lemma notin_used_ConsD: "X ~:used (ev#evs) ==> X ~:used evs" |
|
526 |
by (auto dest: used_sub_Cons [THEN subsetD]) |
|
527 |
||
528 |
lemma used_appD [dest]: "X:used (evs @ evs') ==> X:used evs | X:used evs'" |
|
529 |
by (induct evs, auto, case_tac a, auto) |
|
530 |
||
531 |
lemma used_ConsD: "X:used (ev#evs) ==> X:used [ev] | X:used evs" |
|
532 |
by (case_tac ev, auto) |
|
533 |
||
534 |
lemma used_sub_app: "used evs <= used (evs@evs')" |
|
535 |
by (auto simp: used_decomp dest: used'_sub_app [THEN subsetD]) |
|
536 |
||
537 |
lemma used_appIL: "X:used evs ==> X:used (evs' @ evs)" |
|
538 |
by (induct evs', auto intro: used_ConsI) |
|
539 |
||
540 |
lemma used_appIR: "X:used evs ==> X:used (evs @ evs')" |
|
541 |
by (erule used_sub_app [THEN subsetD]) |
|
542 |
||
543 |
lemma used_parts: "[| X:parts {Y}; Y:used evs |] ==> X:used evs" |
|
544 |
apply (auto simp: used_decomp dest: used'_parts) |
|
545 |
by (auto simp: init_def used_Nil dest: parts_trans) |
|
546 |
||
547 |
lemma parts_Says_used: "[| Says A B X:set evs; Y:parts {X} |] ==> Y:used evs" |
|
548 |
by (induct evs, simp_all, safe, auto intro: used_ConsI) |
|
549 |
||
550 |
lemma parts_used_app: "X:parts {Y} ==> X:used (evs @ Says A B Y # evs')" |
|
551 |
apply (drule_tac evs="[Says A B Y]" in used_parts, simp, blast) |
|
552 |
apply (drule_tac evs'=evs' in used_appIR) |
|
553 |
apply (drule_tac evs'=evs in used_appIL) |
|
554 |
by simp |
|
555 |
||
556 |
subsubsection{*lemmas on used and knows*} |
|
557 |
||
558 |
lemma initState_used: "X:parts (initState A) ==> X:used evs" |
|
559 |
by (induct evs, auto simp: used.simps split: event.split) |
|
560 |
||
561 |
lemma Says_imp_used: "Says A B X:set evs ==> parts {X} <= used evs" |
|
562 |
by (induct evs, auto intro: used_ConsI) |
|
563 |
||
564 |
lemma not_used_not_spied: "X ~:used evs ==> X ~:parts (spies evs)" |
|
565 |
by (induct evs, auto simp: used_Nil) |
|
566 |
||
567 |
lemma not_used_not_parts: "[| Y ~:used evs; Says A B X:set evs |] |
|
568 |
==> Y ~:parts {X}" |
|
569 |
by (induct evs, auto intro: used_ConsI) |
|
570 |
||
571 |
lemma not_used_parts_false: "[| X ~:used evs; Y:parts (spies evs) |] |
|
572 |
==> X ~:parts {Y}" |
|
573 |
by (auto dest: parts_parts) |
|
574 |
||
575 |
lemma known_used [rule_format]: "[| evs:p; Gets_correct p; one_step p |] |
|
576 |
==> X:parts (knows A evs) --> X:used evs" |
|
18557
60a0f9caa0a2
Provers/classical: stricter checks to ensure that supplied intro, dest and
paulson
parents:
17689
diff
changeset
|
577 |
apply (case_tac "A=Spy", blast) |
13508 | 578 |
apply (induct evs) |
579 |
apply (simp add: used.simps, blast) |
|
15236
f289e8ba2bb3
Proofs needed to be updated because induction now preserves name of
nipkow
parents:
14307
diff
changeset
|
580 |
apply (frule_tac ev=a and evs=evs in one_step_Cons, simp, clarify) |
13508 | 581 |
apply (drule_tac P="%G. X:parts G" in knows_Cons_substD, safe) |
582 |
apply (erule initState_used) |
|
583 |
apply (case_tac a, auto) |
|
15236
f289e8ba2bb3
Proofs needed to be updated because induction now preserves name of
nipkow
parents:
14307
diff
changeset
|
584 |
apply (drule_tac B=A and X=msg and evs=evs in Gets_correct_Says) |
13508 | 585 |
by (auto dest: Says_imp_used intro: used_ConsI) |
586 |
||
587 |
lemma known_max_used [rule_format]: "[| evs:p; Gets_correct p; one_step p |] |
|
588 |
==> X:parts (knows_max A evs) --> X:used evs" |
|
589 |
apply (case_tac "A=Spy") |
|
18557
60a0f9caa0a2
Provers/classical: stricter checks to ensure that supplied intro, dest and
paulson
parents:
17689
diff
changeset
|
590 |
apply force |
13508 | 591 |
apply (induct evs) |
592 |
apply (simp add: knows_max_def used.simps, blast) |
|
15236
f289e8ba2bb3
Proofs needed to be updated because induction now preserves name of
nipkow
parents:
14307
diff
changeset
|
593 |
apply (frule_tac ev=a and evs=evs in one_step_Cons, simp, clarify) |
13508 | 594 |
apply (drule_tac P="%G. X:parts G" in knows_max_Cons_substD, safe) |
595 |
apply (case_tac a, auto) |
|
15236
f289e8ba2bb3
Proofs needed to be updated because induction now preserves name of
nipkow
parents:
14307
diff
changeset
|
596 |
apply (drule_tac B=A and X=msg and evs=evs in Gets_correct_Says) |
13508 | 597 |
by (auto simp: knows_max'_Cons dest: Says_imp_used intro: used_ConsI) |
598 |
||
599 |
lemma not_used_not_known: "[| evs:p; X ~:used evs; |
|
600 |
Gets_correct p; one_step p |] ==> X ~:parts (knows A evs)" |
|
601 |
by (case_tac "A=Spy", auto dest: not_used_not_spied known_used) |
|
602 |
||
603 |
lemma not_used_not_known_max: "[| evs:p; X ~:used evs; |
|
604 |
Gets_correct p; one_step p |] ==> X ~:parts (knows_max A evs)" |
|
605 |
by (case_tac "A=Spy", auto dest: not_used_not_spied known_max_used) |
|
606 |
||
607 |
subsubsection{*a nonce or key in a message cannot equal a fresh nonce or key*} |
|
608 |
||
609 |
lemma Nonce_neq [dest]: "[| Nonce n' ~:used evs; |
|
610 |
Says A B X:set evs; Nonce n:parts {X} |] ==> n ~= n'" |
|
611 |
by (drule not_used_not_spied, auto dest: Says_imp_knows_Spy parts_sub) |
|
612 |
||
613 |
lemma Key_neq [dest]: "[| Key n' ~:used evs; |
|
614 |
Says A B X:set evs; Key n:parts {X} |] ==> n ~= n'" |
|
615 |
by (drule not_used_not_spied, auto dest: Says_imp_knows_Spy parts_sub) |
|
616 |
||
617 |
subsubsection{*message of an event*} |
|
618 |
||
35418 | 619 |
primrec msg :: "event => msg" |
620 |
where |
|
621 |
"msg (Says A B X) = X" |
|
622 |
| "msg (Gets A X) = X" |
|
623 |
| "msg (Notes A X) = X" |
|
13508 | 624 |
|
625 |
lemma used_sub_parts_used: "X:used (ev # evs) ==> X:parts {msg ev} Un used evs" |
|
626 |
by (induct ev, auto) |
|
627 |
||
628 |
||
629 |
||
630 |
end |