author | haftmann |
Thu, 08 Jul 2010 16:19:24 +0200 | |
changeset 37744 | 3daaf23b9ab4 |
parent 35101 | 6ce9177d6b38 |
child 39758 | b8a53e3a0ee2 |
permissions | -rw-r--r-- |
33028 | 1 |
(* Title: HOL/SET_Protocol/Event_SET.thy |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
2 |
Author: Giampaolo Bella |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
3 |
Author: Fabio Massacci |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
4 |
Author: Lawrence C Paulson |
14199 | 5 |
*) |
6 |
||
7 |
header{*Theory of Events for SET*} |
|
8 |
||
33028 | 9 |
theory Event_SET |
10 |
imports Message_SET |
|
11 |
begin |
|
14199 | 12 |
|
13 |
text{*The Root Certification Authority*} |
|
35101 | 14 |
abbreviation "RCA == CA 0" |
14199 | 15 |
|
16 |
||
17 |
text{*Message events*} |
|
18 |
datatype |
|
19 |
event = Says agent agent msg |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
20 |
| Gets agent msg |
14199 | 21 |
| Notes agent msg |
22 |
||
23 |
||
24 |
text{*compromised agents: keys known, Notes visible*} |
|
25 |
consts bad :: "agent set" |
|
26 |
||
27 |
text{*Spy has access to his own key for spoof messages, but RCA is secure*} |
|
28 |
specification (bad) |
|
29 |
Spy_in_bad [iff]: "Spy \<in> bad" |
|
30 |
RCA_not_bad [iff]: "RCA \<notin> bad" |
|
31 |
by (rule exI [of _ "{Spy}"], simp) |
|
32 |
||
33 |
||
34 |
subsection{*Agents' Knowledge*} |
|
35 |
||
36 |
consts (*Initial states of agents -- parameter of the construction*) |
|
37 |
initState :: "agent => msg set" |
|
38 |
knows :: "[agent, event list] => msg set" |
|
39 |
||
40 |
(* Message reception does not extend spy's knowledge because of |
|
41 |
reception invariant enforced by Reception rule in protocol definition*) |
|
42 |
primrec |
|
43 |
||
44 |
knows_Nil: |
|
45 |
"knows A [] = initState A" |
|
46 |
knows_Cons: |
|
47 |
"knows A (ev # evs) = |
|
48 |
(if A = Spy then |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
49 |
(case ev of |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
50 |
Says A' B X => insert X (knows Spy evs) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
51 |
| Gets A' X => knows Spy evs |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
52 |
| Notes A' X => |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
53 |
if A' \<in> bad then insert X (knows Spy evs) else knows Spy evs) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
54 |
else |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
55 |
(case ev of |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
56 |
Says A' B X => |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
57 |
if A'=A then insert X (knows A evs) else knows A evs |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
58 |
| Gets A' X => |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
59 |
if A'=A then insert X (knows A evs) else knows A evs |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
60 |
| Notes A' X => |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
61 |
if A'=A then insert X (knows A evs) else knows A evs))" |
14199 | 62 |
|
63 |
||
64 |
subsection{*Used Messages*} |
|
65 |
||
66 |
consts |
|
67 |
(*Set of items that might be visible to somebody: |
|
68 |
complement of the set of fresh items*) |
|
69 |
used :: "event list => msg set" |
|
70 |
||
71 |
(* As above, message reception does extend used items *) |
|
72 |
primrec |
|
73 |
used_Nil: "used [] = (UN B. parts (initState B))" |
|
74 |
used_Cons: "used (ev # evs) = |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
75 |
(case ev of |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
76 |
Says A B X => parts {X} Un (used evs) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
77 |
| Gets A X => used evs |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30549
diff
changeset
|
78 |
| Notes A X => parts {X} Un (used evs))" |
14199 | 79 |
|
80 |
||
81 |
||
82 |
(* Inserted by default but later removed. This declaration lets the file |
|
83 |
be re-loaded. Addsimps [knows_Cons, used_Nil, *) |
|
84 |
||
85 |
(** Simplifying parts (insert X (knows Spy evs)) |
|
86 |
= parts {X} Un parts (knows Spy evs) -- since general case loops*) |
|
87 |
||
88 |
lemmas parts_insert_knows_A = parts_insert [of _ "knows A evs", standard] |
|
89 |
||
90 |
lemma knows_Spy_Says [simp]: |
|
91 |
"knows Spy (Says A B X # evs) = insert X (knows Spy evs)" |
|
92 |
by auto |
|
93 |
||
94 |
text{*Letting the Spy see "bad" agents' notes avoids redundant case-splits |
|
95 |
on whether @{term "A=Spy"} and whether @{term "A\<in>bad"}*} |
|
96 |
lemma knows_Spy_Notes [simp]: |
|
97 |
"knows Spy (Notes A X # evs) = |
|
98 |
(if A:bad then insert X (knows Spy evs) else knows Spy evs)" |
|
99 |
apply auto |
|
100 |
done |
|
101 |
||
102 |
lemma knows_Spy_Gets [simp]: "knows Spy (Gets A X # evs) = knows Spy evs" |
|
103 |
by auto |
|
104 |
||
105 |
lemma initState_subset_knows: "initState A <= knows A evs" |
|
106 |
apply (induct_tac "evs") |
|
107 |
apply (auto split: event.split) |
|
108 |
done |
|
109 |
||
110 |
lemma knows_Spy_subset_knows_Spy_Says: |
|
111 |
"knows Spy evs <= knows Spy (Says A B X # evs)" |
|
112 |
by auto |
|
113 |
||
114 |
lemma knows_Spy_subset_knows_Spy_Notes: |
|
115 |
"knows Spy evs <= knows Spy (Notes A X # evs)" |
|
116 |
by auto |
|
117 |
||
118 |
lemma knows_Spy_subset_knows_Spy_Gets: |
|
119 |
"knows Spy evs <= knows Spy (Gets A X # evs)" |
|
120 |
by auto |
|
121 |
||
122 |
(*Spy sees what is sent on the traffic*) |
|
123 |
lemma Says_imp_knows_Spy [rule_format]: |
|
124 |
"Says A B X \<in> set evs --> X \<in> knows Spy evs" |
|
125 |
apply (induct_tac "evs") |
|
126 |
apply (auto split: event.split) |
|
127 |
done |
|
128 |
||
129 |
(*Use with addSEs to derive contradictions from old Says events containing |
|
130 |
items known to be fresh*) |
|
131 |
lemmas knows_Spy_partsEs = |
|
132 |
Says_imp_knows_Spy [THEN parts.Inj, THEN revcut_rl, standard] |
|
133 |
parts.Body [THEN revcut_rl, standard] |
|
134 |
||
135 |
||
136 |
subsection{*The Function @{term used}*} |
|
137 |
||
138 |
lemma parts_knows_Spy_subset_used: "parts (knows Spy evs) <= used evs" |
|
139 |
apply (induct_tac "evs") |
|
140 |
apply (auto simp add: parts_insert_knows_A split: event.split) |
|
141 |
done |
|
142 |
||
143 |
lemmas usedI = parts_knows_Spy_subset_used [THEN subsetD, intro] |
|
144 |
||
145 |
lemma initState_subset_used: "parts (initState B) <= used evs" |
|
146 |
apply (induct_tac "evs") |
|
147 |
apply (auto split: event.split) |
|
148 |
done |
|
149 |
||
150 |
lemmas initState_into_used = initState_subset_used [THEN subsetD] |
|
151 |
||
152 |
lemma used_Says [simp]: "used (Says A B X # evs) = parts{X} Un used evs" |
|
153 |
by auto |
|
154 |
||
155 |
lemma used_Notes [simp]: "used (Notes A X # evs) = parts{X} Un used evs" |
|
156 |
by auto |
|
157 |
||
158 |
lemma used_Gets [simp]: "used (Gets A X # evs) = used evs" |
|
159 |
by auto |
|
160 |
||
161 |
||
162 |
lemma Notes_imp_parts_subset_used [rule_format]: |
|
163 |
"Notes A X \<in> set evs --> parts {X} <= used evs" |
|
164 |
apply (induct_tac "evs") |
|
165 |
apply (induct_tac [2] "a", auto) |
|
166 |
done |
|
167 |
||
168 |
text{*NOTE REMOVAL--laws above are cleaner, as they don't involve "case"*} |
|
169 |
declare knows_Cons [simp del] |
|
170 |
used_Nil [simp del] used_Cons [simp del] |
|
171 |
||
172 |
||
173 |
text{*For proving theorems of the form @{term "X \<notin> analz (knows Spy evs) --> P"} |
|
174 |
New events added by induction to "evs" are discarded. Provided |
|
175 |
this information isn't needed, the proof will be much shorter, since |
|
176 |
it will omit complicated reasoning about @{term analz}.*} |
|
177 |
||
178 |
lemmas analz_mono_contra = |
|
179 |
knows_Spy_subset_knows_Spy_Says [THEN analz_mono, THEN contra_subsetD] |
|
180 |
knows_Spy_subset_knows_Spy_Notes [THEN analz_mono, THEN contra_subsetD] |
|
181 |
knows_Spy_subset_knows_Spy_Gets [THEN analz_mono, THEN contra_subsetD] |
|
27225 | 182 |
|
183 |
lemmas analz_impI = impI [where P = "Y \<notin> analz (knows Spy evs)", standard] |
|
184 |
||
14199 | 185 |
ML |
186 |
{* |
|
187 |
val analz_mono_contra_tac = |
|
27225 | 188 |
rtac @{thm analz_impI} THEN' |
189 |
REPEAT1 o (dresolve_tac @{thms analz_mono_contra}) |
|
190 |
THEN' mp_tac |
|
14199 | 191 |
*} |
192 |
||
193 |
method_setup analz_mono_contra = {* |
|
30549 | 194 |
Scan.succeed (K (SIMPLE_METHOD (REPEAT_FIRST analz_mono_contra_tac))) *} |
14199 | 195 |
"for proving theorems of the form X \<notin> analz (knows Spy evs) --> P" |
196 |
||
197 |
end |