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