| author | huffman | 
| Thu, 25 Aug 2011 14:25:19 -0700 | |
| changeset 44525 | fbb777aec0d4 | 
| parent 44174 | d1d79f0e1ea6 | 
| child 45605 | a89b4bc311a5 | 
| permissions | -rw-r--r-- | 
| 37936 | 1  | 
(* Title: HOL/Auth/Message.thy  | 
| 1839 | 2  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
3  | 
Copyright 1996 University of Cambridge  | 
|
4  | 
||
5  | 
Datatypes of agents and messages;  | 
|
| 1913 | 6  | 
Inductive relations "parts", "analz" and "synth"  | 
| 1839 | 7  | 
*)  | 
8  | 
||
| 13956 | 9  | 
header{*Theory of Agents and Messages for Security Protocols*}
 | 
10  | 
||
| 
27105
 
5f139027c365
slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
 
haftmann 
parents: 
26807 
diff
changeset
 | 
11  | 
theory Message  | 
| 
 
5f139027c365
slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
 
haftmann 
parents: 
26807 
diff
changeset
 | 
12  | 
imports Main  | 
| 
 
5f139027c365
slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
 
haftmann 
parents: 
26807 
diff
changeset
 | 
13  | 
begin  | 
| 11189 | 14  | 
|
15  | 
(*Needed occasionally with spy_analz_tac, e.g. in analz_insert_Key_newK*)  | 
|
| 13926 | 16  | 
lemma [simp] : "A \<union> (B \<union> A) = B \<union> A"  | 
| 11189 | 17  | 
by blast  | 
| 1839 | 18  | 
|
| 41774 | 19  | 
type_synonym  | 
| 1839 | 20  | 
key = nat  | 
21  | 
||
22  | 
consts  | 
|
| 
14126
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
23  | 
  all_symmetric :: bool        --{*true if all keys are symmetric*}
 | 
| 
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
24  | 
  invKey        :: "key=>key"  --{*inverse of a symmetric key*}
 | 
| 
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
25  | 
|
| 
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
26  | 
specification (invKey)  | 
| 14181 | 27  | 
invKey [simp]: "invKey (invKey K) = K"  | 
28  | 
invKey_symmetric: "all_symmetric --> invKey = id"  | 
|
| 
14126
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
29  | 
by (rule exI [of _ id], auto)  | 
| 1839 | 30  | 
|
| 
14126
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
31  | 
|
| 
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
32  | 
text{*The inverse of a symmetric key is itself; that of a public key
 | 
| 
 
28824746d046
Tidying and replacement of some axioms by specifications
 
paulson 
parents: 
13956 
diff
changeset
 | 
33  | 
is the private key and vice versa*}  | 
| 1839 | 34  | 
|
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35109 
diff
changeset
 | 
35  | 
definition symKeys :: "key set" where  | 
| 
11230
 
756c5034f08b
misc tidying; changing the predicate isSymKey to the set symKeys
 
paulson 
parents: 
11192 
diff
changeset
 | 
36  | 
  "symKeys == {K. invKey K = K}"
 | 
| 1839 | 37  | 
|
| 16818 | 38  | 
datatype  --{*We allow any number of friendly agents*}
 | 
| 2032 | 39  | 
agent = Server | Friend nat | Spy  | 
| 1839 | 40  | 
|
| 3668 | 41  | 
datatype  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32149 
diff
changeset
 | 
42  | 
     msg = Agent  agent     --{*Agent names*}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
43  | 
         | Number nat       --{*Ordinary integers, timestamps, ...*}
 | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
44  | 
         | Nonce  nat       --{*Unguessable nonces*}
 | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
45  | 
         | Key    key       --{*Crypto keys*}
 | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32149 
diff
changeset
 | 
46  | 
         | Hash   msg       --{*Hashing*}
 | 
| 
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32149 
diff
changeset
 | 
47  | 
         | MPair  msg msg   --{*Compound messages*}
 | 
| 
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32149 
diff
changeset
 | 
48  | 
         | Crypt  key msg   --{*Encryption, public- or shared-key*}
 | 
| 1839 | 49  | 
|
| 5234 | 50  | 
|
| 16818 | 51  | 
text{*Concrete syntax: messages appear as {|A,B,NA|}, etc...*}
 | 
| 5234 | 52  | 
syntax  | 
| 35109 | 53  | 
  "_MTuple"      :: "['a, args] => 'a * 'b"       ("(2{|_,/ _|})")
 | 
| 1839 | 54  | 
|
| 9686 | 55  | 
syntax (xsymbols)  | 
| 35109 | 56  | 
  "_MTuple"      :: "['a, args] => 'a * 'b"       ("(2\<lbrace>_,/ _\<rbrace>)")
 | 
| 9686 | 57  | 
|
| 1839 | 58  | 
translations  | 
59  | 
  "{|x, y, z|}"   == "{|x, {|y, z|}|}"
 | 
|
| 35054 | 60  | 
  "{|x, y|}"      == "CONST MPair x y"
 | 
| 1839 | 61  | 
|
62  | 
||
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35109 
diff
changeset
 | 
63  | 
definition HPair :: "[msg,msg] => msg" ("(4Hash[_] /_)" [0, 1000]) where
 | 
| 16818 | 64  | 
    --{*Message Y paired with a MAC computed with the help of X*}
 | 
| 
2516
 
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
 
paulson 
parents: 
2484 
diff
changeset
 | 
65  | 
    "Hash[X] Y == {| Hash{|X,Y|}, Y|}"
 | 
| 2484 | 66  | 
|
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
35109 
diff
changeset
 | 
67  | 
definition keysFor :: "msg set => key set" where  | 
| 16818 | 68  | 
    --{*Keys useful to decrypt elements of a message set*}
 | 
| 11192 | 69  | 
  "keysFor H == invKey ` {K. \<exists>X. Crypt K X \<in> H}"
 | 
| 1839 | 70  | 
|
| 16818 | 71  | 
|
72  | 
subsubsection{*Inductive Definition of All Parts" of a Message*}
 | 
|
| 1839 | 73  | 
|
| 23746 | 74  | 
inductive_set  | 
75  | 
parts :: "msg set => msg set"  | 
|
76  | 
for H :: "msg set"  | 
|
77  | 
where  | 
|
| 11192 | 78  | 
Inj [intro]: "X \<in> H ==> X \<in> parts H"  | 
| 23746 | 79  | 
  | Fst:         "{|X,Y|}   \<in> parts H ==> X \<in> parts H"
 | 
80  | 
  | Snd:         "{|X,Y|}   \<in> parts H ==> Y \<in> parts H"
 | 
|
81  | 
| Body: "Crypt K X \<in> parts H ==> X \<in> parts H"  | 
|
| 11189 | 82  | 
|
83  | 
||
| 16818 | 84  | 
text{*Monotonicity*}
 | 
85  | 
lemma parts_mono: "G \<subseteq> H ==> parts(G) \<subseteq> parts(H)"  | 
|
| 11189 | 86  | 
apply auto  | 
87  | 
apply (erule parts.induct)  | 
|
| 16818 | 88  | 
apply (blast dest: parts.Fst parts.Snd parts.Body)+  | 
| 11189 | 89  | 
done  | 
| 1839 | 90  | 
|
91  | 
||
| 16818 | 92  | 
text{*Equations hold because constructors are injective.*}
 | 
| 13926 | 93  | 
lemma Friend_image_eq [simp]: "(Friend x \<in> Friend`A) = (x:A)"  | 
94  | 
by auto  | 
|
95  | 
||
96  | 
lemma Key_image_eq [simp]: "(Key x \<in> Key`A) = (x\<in>A)"  | 
|
97  | 
by auto  | 
|
98  | 
||
99  | 
lemma Nonce_Key_image_eq [simp]: "(Nonce x \<notin> Key`A)"  | 
|
100  | 
by auto  | 
|
101  | 
||
102  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
103  | 
subsubsection{*Inverse of keys *}
 | 
| 13926 | 104  | 
|
105  | 
lemma invKey_eq [simp]: "(invKey K = invKey K') = (K=K')"  | 
|
| 28698 | 106  | 
by (metis invKey)  | 
| 13926 | 107  | 
|
108  | 
||
109  | 
subsection{*keysFor operator*}
 | 
|
110  | 
||
111  | 
lemma keysFor_empty [simp]: "keysFor {} = {}"
 | 
|
112  | 
by (unfold keysFor_def, blast)  | 
|
113  | 
||
114  | 
lemma keysFor_Un [simp]: "keysFor (H \<union> H') = keysFor H \<union> keysFor H'"  | 
|
115  | 
by (unfold keysFor_def, blast)  | 
|
116  | 
||
117  | 
lemma keysFor_UN [simp]: "keysFor (\<Union>i\<in>A. H i) = (\<Union>i\<in>A. keysFor (H i))"  | 
|
118  | 
by (unfold keysFor_def, blast)  | 
|
119  | 
||
| 16818 | 120  | 
text{*Monotonicity*}
 | 
121  | 
lemma keysFor_mono: "G \<subseteq> H ==> keysFor(G) \<subseteq> keysFor(H)"  | 
|
| 13926 | 122  | 
by (unfold keysFor_def, blast)  | 
123  | 
||
124  | 
lemma keysFor_insert_Agent [simp]: "keysFor (insert (Agent A) H) = keysFor H"  | 
|
125  | 
by (unfold keysFor_def, auto)  | 
|
126  | 
||
127  | 
lemma keysFor_insert_Nonce [simp]: "keysFor (insert (Nonce N) H) = keysFor H"  | 
|
128  | 
by (unfold keysFor_def, auto)  | 
|
129  | 
||
130  | 
lemma keysFor_insert_Number [simp]: "keysFor (insert (Number N) H) = keysFor H"  | 
|
131  | 
by (unfold keysFor_def, auto)  | 
|
132  | 
||
133  | 
lemma keysFor_insert_Key [simp]: "keysFor (insert (Key K) H) = keysFor H"  | 
|
134  | 
by (unfold keysFor_def, auto)  | 
|
135  | 
||
136  | 
lemma keysFor_insert_Hash [simp]: "keysFor (insert (Hash X) H) = keysFor H"  | 
|
137  | 
by (unfold keysFor_def, auto)  | 
|
138  | 
||
139  | 
lemma keysFor_insert_MPair [simp]: "keysFor (insert {|X,Y|} H) = keysFor H"
 | 
|
140  | 
by (unfold keysFor_def, auto)  | 
|
141  | 
||
142  | 
lemma keysFor_insert_Crypt [simp]:  | 
|
143  | 
"keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)"  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
144  | 
by (unfold keysFor_def, auto)  | 
| 13926 | 145  | 
|
146  | 
lemma keysFor_image_Key [simp]: "keysFor (Key`E) = {}"
 | 
|
147  | 
by (unfold keysFor_def, auto)  | 
|
148  | 
||
149  | 
lemma Crypt_imp_invKey_keysFor: "Crypt K X \<in> H ==> invKey K \<in> keysFor H"  | 
|
150  | 
by (unfold keysFor_def, blast)  | 
|
151  | 
||
152  | 
||
153  | 
subsection{*Inductive relation "parts"*}
 | 
|
154  | 
||
155  | 
lemma MPair_parts:  | 
|
156  | 
     "[| {|X,Y|} \<in> parts H;        
 | 
|
157  | 
[| X \<in> parts H; Y \<in> parts H |] ==> P |] ==> P"  | 
|
158  | 
by (blast dest: parts.Fst parts.Snd)  | 
|
159  | 
||
160  | 
declare MPair_parts [elim!] parts.Body [dest!]  | 
|
161  | 
text{*NB These two rules are UNSAFE in the formal sense, as they discard the
 | 
|
162  | 
compound message. They work well on THIS FILE.  | 
|
163  | 
  @{text MPair_parts} is left as SAFE because it speeds up proofs.
 | 
|
164  | 
The Crypt rule is normally kept UNSAFE to avoid breaking up certificates.*}  | 
|
165  | 
||
166  | 
lemma parts_increasing: "H \<subseteq> parts(H)"  | 
|
167  | 
by blast  | 
|
168  | 
||
169  | 
lemmas parts_insertI = subset_insertI [THEN parts_mono, THEN subsetD, standard]  | 
|
170  | 
||
171  | 
lemma parts_empty [simp]: "parts{} = {}"
 | 
|
172  | 
apply safe  | 
|
173  | 
apply (erule parts.induct, blast+)  | 
|
174  | 
done  | 
|
175  | 
||
176  | 
lemma parts_emptyE [elim!]: "X\<in> parts{} ==> P"
 | 
|
177  | 
by simp  | 
|
178  | 
||
| 16818 | 179  | 
text{*WARNING: loops if H = {Y}, therefore must not be repeated!*}
 | 
| 13926 | 180  | 
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
 | 
181  | 
by (erule parts.induct, fast+)  | 
| 13926 | 182  | 
|
183  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
184  | 
subsubsection{*Unions *}
 | 
| 13926 | 185  | 
|
186  | 
lemma parts_Un_subset1: "parts(G) \<union> parts(H) \<subseteq> parts(G \<union> H)"  | 
|
187  | 
by (intro Un_least parts_mono Un_upper1 Un_upper2)  | 
|
188  | 
||
189  | 
lemma parts_Un_subset2: "parts(G \<union> H) \<subseteq> parts(G) \<union> parts(H)"  | 
|
190  | 
apply (rule subsetI)  | 
|
191  | 
apply (erule parts.induct, blast+)  | 
|
192  | 
done  | 
|
193  | 
||
194  | 
lemma parts_Un [simp]: "parts(G \<union> H) = parts(G) \<union> parts(H)"  | 
|
195  | 
by (intro equalityI parts_Un_subset1 parts_Un_subset2)  | 
|
196  | 
||
197  | 
lemma parts_insert: "parts (insert X H) = parts {X} \<union> parts H"
 | 
|
| 34185 | 198  | 
by (metis insert_is_Un parts_Un)  | 
| 13926 | 199  | 
|
| 16818 | 200  | 
text{*TWO inserts to avoid looping.  This rewrite is better than nothing.
 | 
201  | 
Not suitable for Addsimps: its behaviour can be strange.*}  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
202  | 
lemma parts_insert2:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
203  | 
     "parts (insert X (insert Y H)) = parts {X} \<union> parts {Y} \<union> parts H"
 | 
| 34185 | 204  | 
by (metis Un_commute Un_empty_right Un_insert_right insert_is_Un parts_Un)  | 
| 13926 | 205  | 
|
206  | 
lemma parts_UN_subset1: "(\<Union>x\<in>A. parts(H x)) \<subseteq> parts(\<Union>x\<in>A. H x)"  | 
|
207  | 
by (intro UN_least parts_mono UN_upper)  | 
|
208  | 
||
209  | 
lemma parts_UN_subset2: "parts(\<Union>x\<in>A. H x) \<subseteq> (\<Union>x\<in>A. parts(H x))"  | 
|
210  | 
apply (rule subsetI)  | 
|
211  | 
apply (erule parts.induct, blast+)  | 
|
212  | 
done  | 
|
213  | 
||
214  | 
lemma parts_UN [simp]: "parts(\<Union>x\<in>A. H x) = (\<Union>x\<in>A. parts(H x))"  | 
|
215  | 
by (intro equalityI parts_UN_subset1 parts_UN_subset2)  | 
|
216  | 
||
| 16818 | 217  | 
text{*Added to simplify arguments to parts, analz and synth.
 | 
218  | 
NOTE: the UN versions are no longer used!*}  | 
|
| 13926 | 219  | 
|
220  | 
||
221  | 
text{*This allows @{text blast} to simplify occurrences of 
 | 
|
222  | 
  @{term "parts(G\<union>H)"} in the assumption.*}
 | 
|
| 17729 | 223  | 
lemmas in_parts_UnE = parts_Un [THEN equalityD1, THEN subsetD, THEN UnE]  | 
224  | 
declare in_parts_UnE [elim!]  | 
|
| 13926 | 225  | 
|
226  | 
||
227  | 
lemma parts_insert_subset: "insert X (parts H) \<subseteq> parts(insert X H)"  | 
|
228  | 
by (blast intro: parts_mono [THEN [2] rev_subsetD])  | 
|
229  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
230  | 
subsubsection{*Idempotence and transitivity *}
 | 
| 13926 | 231  | 
|
232  | 
lemma parts_partsD [dest!]: "X\<in> parts (parts H) ==> X\<in> parts H"  | 
|
233  | 
by (erule parts.induct, blast+)  | 
|
234  | 
||
235  | 
lemma parts_idem [simp]: "parts (parts H) = parts H"  | 
|
236  | 
by blast  | 
|
237  | 
||
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
238  | 
lemma parts_subset_iff [simp]: "(parts G \<subseteq> parts H) = (G \<subseteq> parts H)"  | 
| 
35566
 
3c01f5ad1d34
Simplified a couple of proofs and corrected a comment
 
paulson 
parents: 
35416 
diff
changeset
 | 
239  | 
by (metis parts_idem parts_increasing parts_mono subset_trans)  | 
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
240  | 
|
| 13926 | 241  | 
lemma parts_trans: "[| X\<in> parts G; G \<subseteq> parts H |] ==> X\<in> parts H"  | 
| 
41693
 
47532fe9e075
Introduction of metis calls and other cosmetic modifications.
 
paulson 
parents: 
39216 
diff
changeset
 | 
242  | 
by (metis parts_subset_iff set_mp)  | 
| 13926 | 243  | 
|
| 16818 | 244  | 
text{*Cut*}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
245  | 
lemma parts_cut:  | 
| 18492 | 246  | 
"[| Y\<in> parts (insert X G); X\<in> parts H |] ==> Y\<in> parts (G \<union> H)"  | 
247  | 
by (blast intro: parts_trans)  | 
|
248  | 
||
| 13926 | 249  | 
lemma parts_cut_eq [simp]: "X\<in> parts H ==> parts (insert X H) = parts H"  | 
| 
41693
 
47532fe9e075
Introduction of metis calls and other cosmetic modifications.
 
paulson 
parents: 
39216 
diff
changeset
 | 
250  | 
by (metis insert_absorb parts_idem parts_insert)  | 
| 13926 | 251  | 
|
252  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
253  | 
subsubsection{*Rewrite rules for pulling out atomic messages *}
 | 
| 13926 | 254  | 
|
255  | 
lemmas parts_insert_eq_I = equalityI [OF subsetI parts_insert_subset]  | 
|
256  | 
||
257  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
258  | 
lemma parts_insert_Agent [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
259  | 
"parts (insert (Agent agt) H) = insert (Agent agt) (parts H)"  | 
| 13926 | 260  | 
apply (rule parts_insert_eq_I)  | 
261  | 
apply (erule parts.induct, auto)  | 
|
262  | 
done  | 
|
263  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
264  | 
lemma parts_insert_Nonce [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
265  | 
"parts (insert (Nonce N) H) = insert (Nonce N) (parts H)"  | 
| 13926 | 266  | 
apply (rule parts_insert_eq_I)  | 
267  | 
apply (erule parts.induct, auto)  | 
|
268  | 
done  | 
|
269  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
270  | 
lemma parts_insert_Number [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
271  | 
"parts (insert (Number N) H) = insert (Number N) (parts H)"  | 
| 13926 | 272  | 
apply (rule parts_insert_eq_I)  | 
273  | 
apply (erule parts.induct, auto)  | 
|
274  | 
done  | 
|
275  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
276  | 
lemma parts_insert_Key [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
277  | 
"parts (insert (Key K) H) = insert (Key K) (parts H)"  | 
| 13926 | 278  | 
apply (rule parts_insert_eq_I)  | 
279  | 
apply (erule parts.induct, auto)  | 
|
280  | 
done  | 
|
281  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
282  | 
lemma parts_insert_Hash [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
283  | 
"parts (insert (Hash X) H) = insert (Hash X) (parts H)"  | 
| 13926 | 284  | 
apply (rule parts_insert_eq_I)  | 
285  | 
apply (erule parts.induct, auto)  | 
|
286  | 
done  | 
|
287  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
288  | 
lemma parts_insert_Crypt [simp]:  | 
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
289  | 
"parts (insert (Crypt K X) H) = insert (Crypt K X) (parts (insert X H))"  | 
| 13926 | 290  | 
apply (rule equalityI)  | 
291  | 
apply (rule subsetI)  | 
|
292  | 
apply (erule parts.induct, auto)  | 
|
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
293  | 
apply (blast intro: parts.Body)  | 
| 13926 | 294  | 
done  | 
295  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
296  | 
lemma parts_insert_MPair [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
297  | 
     "parts (insert {|X,Y|} H) =  
 | 
| 13926 | 298  | 
          insert {|X,Y|} (parts (insert X (insert Y H)))"
 | 
299  | 
apply (rule equalityI)  | 
|
300  | 
apply (rule subsetI)  | 
|
301  | 
apply (erule parts.induct, auto)  | 
|
302  | 
apply (blast intro: parts.Fst parts.Snd)+  | 
|
303  | 
done  | 
|
304  | 
||
305  | 
lemma parts_image_Key [simp]: "parts (Key`N) = Key`N"  | 
|
306  | 
apply auto  | 
|
307  | 
apply (erule parts.induct, auto)  | 
|
308  | 
done  | 
|
309  | 
||
310  | 
||
| 16818 | 311  | 
text{*In any message, there is an upper bound N on its greatest nonce.*}
 | 
| 13926 | 312  | 
lemma msg_Nonce_supply: "\<exists>N. \<forall>n. N\<le>n --> Nonce n \<notin> parts {msg}"
 | 
| 
27105
 
5f139027c365
slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
 
haftmann 
parents: 
26807 
diff
changeset
 | 
313  | 
apply (induct msg)  | 
| 13926 | 314  | 
apply (simp_all (no_asm_simp) add: exI parts_insert2)  | 
| 16818 | 315  | 
txt{*Nonce case*}
 | 
| 34185 | 316  | 
apply (metis Suc_n_not_le_n)  | 
317  | 
txt{*MPair case: metis works out the necessary sum itself!*}
 | 
|
318  | 
apply (metis le_trans nat_le_linear)  | 
|
| 13926 | 319  | 
done  | 
320  | 
||
321  | 
||
322  | 
subsection{*Inductive relation "analz"*}
 | 
|
323  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
324  | 
text{*Inductive definition of "analz" -- what can be broken down from a set of
 | 
| 1839 | 325  | 
messages, including keys. A form of downward closure. Pairs can  | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
326  | 
be taken apart; messages decrypted with known keys. *}  | 
| 1839 | 327  | 
|
| 23746 | 328  | 
inductive_set  | 
329  | 
analz :: "msg set => msg set"  | 
|
330  | 
for H :: "msg set"  | 
|
331  | 
where  | 
|
| 11192 | 332  | 
Inj [intro,simp] : "X \<in> H ==> X \<in> analz H"  | 
| 23746 | 333  | 
  | Fst:     "{|X,Y|} \<in> analz H ==> X \<in> analz H"
 | 
334  | 
  | Snd:     "{|X,Y|} \<in> analz H ==> Y \<in> analz H"
 | 
|
335  | 
| Decrypt [dest]:  | 
|
| 11192 | 336  | 
"[|Crypt K X \<in> analz H; Key(invKey K): analz H|] ==> X \<in> analz H"  | 
| 1839 | 337  | 
|
338  | 
||
| 16818 | 339  | 
text{*Monotonicity; Lemma 1 of Lowe's paper*}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
340  | 
lemma analz_mono: "G\<subseteq>H ==> analz(G) \<subseteq> analz(H)"  | 
| 11189 | 341  | 
apply auto  | 
342  | 
apply (erule analz.induct)  | 
|
| 16818 | 343  | 
apply (auto dest: analz.Fst analz.Snd)  | 
| 11189 | 344  | 
done  | 
345  | 
||
| 13926 | 346  | 
text{*Making it safe speeds up proofs*}
 | 
347  | 
lemma MPair_analz [elim!]:  | 
|
348  | 
     "[| {|X,Y|} \<in> analz H;        
 | 
|
349  | 
[| X \<in> analz H; Y \<in> analz H |] ==> P  | 
|
350  | 
|] ==> P"  | 
|
351  | 
by (blast dest: analz.Fst analz.Snd)  | 
|
352  | 
||
353  | 
lemma analz_increasing: "H \<subseteq> analz(H)"  | 
|
354  | 
by blast  | 
|
355  | 
||
356  | 
lemma analz_subset_parts: "analz H \<subseteq> parts H"  | 
|
357  | 
apply (rule subsetI)  | 
|
358  | 
apply (erule analz.induct, blast+)  | 
|
359  | 
done  | 
|
360  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
361  | 
lemmas analz_into_parts = analz_subset_parts [THEN subsetD, standard]  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
362  | 
|
| 13926 | 363  | 
lemmas not_parts_not_analz = analz_subset_parts [THEN contra_subsetD, standard]  | 
364  | 
||
365  | 
||
366  | 
lemma parts_analz [simp]: "parts (analz H) = parts H"  | 
|
| 34185 | 367  | 
by (metis analz_increasing analz_subset_parts equalityI parts_mono parts_subset_iff)  | 
| 13926 | 368  | 
|
369  | 
lemma analz_parts [simp]: "analz (parts H) = parts H"  | 
|
370  | 
apply auto  | 
|
371  | 
apply (erule analz.induct, auto)  | 
|
372  | 
done  | 
|
373  | 
||
374  | 
lemmas analz_insertI = subset_insertI [THEN analz_mono, THEN [2] rev_subsetD, standard]  | 
|
375  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
376  | 
subsubsection{*General equational properties *}
 | 
| 13926 | 377  | 
|
378  | 
lemma analz_empty [simp]: "analz{} = {}"
 | 
|
379  | 
apply safe  | 
|
380  | 
apply (erule analz.induct, blast+)  | 
|
381  | 
done  | 
|
382  | 
||
| 16818 | 383  | 
text{*Converse fails: we can analz more from the union than from the 
 | 
384  | 
separate parts, as a key in one might decrypt a message in the other*}  | 
|
| 13926 | 385  | 
lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)"  | 
386  | 
by (intro Un_least analz_mono Un_upper1 Un_upper2)  | 
|
387  | 
||
388  | 
lemma analz_insert: "insert X (analz H) \<subseteq> analz(insert X H)"  | 
|
389  | 
by (blast intro: analz_mono [THEN [2] rev_subsetD])  | 
|
390  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
391  | 
subsubsection{*Rewrite rules for pulling out atomic messages *}
 | 
| 13926 | 392  | 
|
393  | 
lemmas analz_insert_eq_I = equalityI [OF subsetI analz_insert]  | 
|
394  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
395  | 
lemma analz_insert_Agent [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
396  | 
"analz (insert (Agent agt) H) = insert (Agent agt) (analz H)"  | 
| 13926 | 397  | 
apply (rule analz_insert_eq_I)  | 
398  | 
apply (erule analz.induct, auto)  | 
|
399  | 
done  | 
|
400  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
401  | 
lemma analz_insert_Nonce [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
402  | 
"analz (insert (Nonce N) H) = insert (Nonce N) (analz H)"  | 
| 13926 | 403  | 
apply (rule analz_insert_eq_I)  | 
404  | 
apply (erule analz.induct, auto)  | 
|
405  | 
done  | 
|
406  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
407  | 
lemma analz_insert_Number [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
408  | 
"analz (insert (Number N) H) = insert (Number N) (analz H)"  | 
| 13926 | 409  | 
apply (rule analz_insert_eq_I)  | 
410  | 
apply (erule analz.induct, auto)  | 
|
411  | 
done  | 
|
412  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
413  | 
lemma analz_insert_Hash [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
414  | 
"analz (insert (Hash X) H) = insert (Hash X) (analz H)"  | 
| 13926 | 415  | 
apply (rule analz_insert_eq_I)  | 
416  | 
apply (erule analz.induct, auto)  | 
|
417  | 
done  | 
|
418  | 
||
| 16818 | 419  | 
text{*Can only pull out Keys if they are not needed to decrypt the rest*}
 | 
| 13926 | 420  | 
lemma analz_insert_Key [simp]:  | 
421  | 
"K \<notin> keysFor (analz H) ==>  | 
|
422  | 
analz (insert (Key K) H) = insert (Key K) (analz H)"  | 
|
423  | 
apply (unfold keysFor_def)  | 
|
424  | 
apply (rule analz_insert_eq_I)  | 
|
425  | 
apply (erule analz.induct, auto)  | 
|
426  | 
done  | 
|
427  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
428  | 
lemma analz_insert_MPair [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
429  | 
     "analz (insert {|X,Y|} H) =  
 | 
| 13926 | 430  | 
          insert {|X,Y|} (analz (insert X (insert Y H)))"
 | 
431  | 
apply (rule equalityI)  | 
|
432  | 
apply (rule subsetI)  | 
|
433  | 
apply (erule analz.induct, auto)  | 
|
434  | 
apply (erule analz.induct)  | 
|
435  | 
apply (blast intro: analz.Fst analz.Snd)+  | 
|
436  | 
done  | 
|
437  | 
||
| 16818 | 438  | 
text{*Can pull out enCrypted message if the Key is not known*}
 | 
| 13926 | 439  | 
lemma analz_insert_Crypt:  | 
440  | 
"Key (invKey K) \<notin> analz H  | 
|
441  | 
==> analz (insert (Crypt K X) H) = insert (Crypt K X) (analz H)"  | 
|
442  | 
apply (rule analz_insert_eq_I)  | 
|
443  | 
apply (erule analz.induct, auto)  | 
|
444  | 
||
445  | 
done  | 
|
446  | 
||
447  | 
lemma lemma1: "Key (invKey K) \<in> analz H ==>  | 
|
448  | 
analz (insert (Crypt K X) H) \<subseteq>  | 
|
449  | 
insert (Crypt K X) (analz (insert X H))"  | 
|
450  | 
apply (rule subsetI)  | 
|
| 23746 | 451  | 
apply (erule_tac x = x in analz.induct, auto)  | 
| 13926 | 452  | 
done  | 
453  | 
||
454  | 
lemma lemma2: "Key (invKey K) \<in> analz H ==>  | 
|
455  | 
insert (Crypt K X) (analz (insert X H)) \<subseteq>  | 
|
456  | 
analz (insert (Crypt K X) H)"  | 
|
457  | 
apply auto  | 
|
| 23746 | 458  | 
apply (erule_tac x = x in analz.induct, auto)  | 
| 13926 | 459  | 
apply (blast intro: analz_insertI analz.Decrypt)  | 
460  | 
done  | 
|
461  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
462  | 
lemma analz_insert_Decrypt:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
463  | 
"Key (invKey K) \<in> analz H ==>  | 
| 13926 | 464  | 
analz (insert (Crypt K X) H) =  | 
465  | 
insert (Crypt K X) (analz (insert X H))"  | 
|
466  | 
by (intro equalityI lemma1 lemma2)  | 
|
467  | 
||
| 16818 | 468  | 
text{*Case analysis: either the message is secure, or it is not! Effective,
 | 
469  | 
but can cause subgoals to blow up! Use with @{text "split_if"}; apparently
 | 
|
470  | 
@{text "split_tac"} does not cope with patterns such as @{term"analz (insert
 | 
|
471  | 
(Crypt K X) H)"} *}  | 
|
| 13926 | 472  | 
lemma analz_Crypt_if [simp]:  | 
473  | 
"analz (insert (Crypt K X) H) =  | 
|
474  | 
(if (Key (invKey K) \<in> analz H)  | 
|
475  | 
then insert (Crypt K X) (analz (insert X H))  | 
|
476  | 
else insert (Crypt K X) (analz H))"  | 
|
477  | 
by (simp add: analz_insert_Crypt analz_insert_Decrypt)  | 
|
478  | 
||
479  | 
||
| 16818 | 480  | 
text{*This rule supposes "for the sake of argument" that we have the key.*}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
481  | 
lemma analz_insert_Crypt_subset:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
482  | 
"analz (insert (Crypt K X) H) \<subseteq>  | 
| 13926 | 483  | 
insert (Crypt K X) (analz (insert X H))"  | 
484  | 
apply (rule subsetI)  | 
|
485  | 
apply (erule analz.induct, auto)  | 
|
486  | 
done  | 
|
487  | 
||
488  | 
||
489  | 
lemma analz_image_Key [simp]: "analz (Key`N) = Key`N"  | 
|
490  | 
apply auto  | 
|
491  | 
apply (erule analz.induct, auto)  | 
|
492  | 
done  | 
|
493  | 
||
494  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
495  | 
subsubsection{*Idempotence and transitivity *}
 | 
| 13926 | 496  | 
|
497  | 
lemma analz_analzD [dest!]: "X\<in> analz (analz H) ==> X\<in> analz H"  | 
|
498  | 
by (erule analz.induct, blast+)  | 
|
499  | 
||
500  | 
lemma analz_idem [simp]: "analz (analz H) = analz H"  | 
|
501  | 
by blast  | 
|
502  | 
||
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
503  | 
lemma analz_subset_iff [simp]: "(analz G \<subseteq> analz H) = (G \<subseteq> analz H)"  | 
| 34185 | 504  | 
by (metis analz_idem analz_increasing analz_mono subset_trans)  | 
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
505  | 
|
| 13926 | 506  | 
lemma analz_trans: "[| X\<in> analz G; G \<subseteq> analz H |] ==> X\<in> analz H"  | 
507  | 
by (drule analz_mono, blast)  | 
|
508  | 
||
| 16818 | 509  | 
text{*Cut; Lemma 2 of Lowe*}
 | 
| 13926 | 510  | 
lemma analz_cut: "[| Y\<in> analz (insert X H); X\<in> analz H |] ==> Y\<in> analz H"  | 
511  | 
by (erule analz_trans, blast)  | 
|
512  | 
||
513  | 
(*Cut can be proved easily by induction on  | 
|
514  | 
"Y: analz (insert X H) ==> X: analz H --> Y: analz H"  | 
|
515  | 
*)  | 
|
516  | 
||
| 16818 | 517  | 
text{*This rewrite rule helps in the simplification of messages that involve
 | 
| 13926 | 518  | 
the forwarding of unknown components (X). Without it, removing occurrences  | 
| 16818 | 519  | 
of X can be very complicated. *}  | 
| 13926 | 520  | 
lemma analz_insert_eq: "X\<in> analz H ==> analz (insert X H) = analz H"  | 
| 
41693
 
47532fe9e075
Introduction of metis calls and other cosmetic modifications.
 
paulson 
parents: 
39216 
diff
changeset
 | 
521  | 
by (metis analz_cut analz_insert_eq_I insert_absorb)  | 
| 13926 | 522  | 
|
523  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
524  | 
text{*A congruence rule for "analz" *}
 | 
| 13926 | 525  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
526  | 
lemma analz_subset_cong:  | 
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
527  | 
"[| analz G \<subseteq> analz G'; analz H \<subseteq> analz H' |]  | 
| 
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
528  | 
==> analz (G \<union> H) \<subseteq> analz (G' \<union> H')"  | 
| 
41693
 
47532fe9e075
Introduction of metis calls and other cosmetic modifications.
 
paulson 
parents: 
39216 
diff
changeset
 | 
529  | 
by (metis Un_mono analz_Un analz_subset_iff subset_trans)  | 
| 13926 | 530  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
531  | 
lemma analz_cong:  | 
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
532  | 
"[| analz G = analz G'; analz H = analz H' |]  | 
| 
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
533  | 
==> analz (G \<union> H) = analz (G' \<union> H')"  | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
534  | 
by (intro equalityI analz_subset_cong, simp_all)  | 
| 13926 | 535  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
536  | 
lemma analz_insert_cong:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
537  | 
"analz H = analz H' ==> analz(insert X H) = analz(insert X H')"  | 
| 13926 | 538  | 
by (force simp only: insert_def intro!: analz_cong)  | 
539  | 
||
| 16818 | 540  | 
text{*If there are no pairs or encryptions then analz does nothing*}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
541  | 
lemma analz_trivial:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
542  | 
     "[| \<forall>X Y. {|X,Y|} \<notin> H;  \<forall>X K. Crypt K X \<notin> H |] ==> analz H = H"
 | 
| 13926 | 543  | 
apply safe  | 
544  | 
apply (erule analz.induct, blast+)  | 
|
545  | 
done  | 
|
546  | 
||
| 16818 | 547  | 
text{*These two are obsolete (with a single Spy) but cost little to prove...*}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
548  | 
lemma analz_UN_analz_lemma:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
549  | 
"X\<in> analz (\<Union>i\<in>A. analz (H i)) ==> X\<in> analz (\<Union>i\<in>A. H i)"  | 
| 13926 | 550  | 
apply (erule analz.induct)  | 
551  | 
apply (blast intro: analz_mono [THEN [2] rev_subsetD])+  | 
|
552  | 
done  | 
|
553  | 
||
554  | 
lemma analz_UN_analz [simp]: "analz (\<Union>i\<in>A. analz (H i)) = analz (\<Union>i\<in>A. H i)"  | 
|
555  | 
by (blast intro: analz_UN_analz_lemma analz_mono [THEN [2] rev_subsetD])  | 
|
556  | 
||
557  | 
||
558  | 
subsection{*Inductive relation "synth"*}
 | 
|
559  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
560  | 
text{*Inductive definition of "synth" -- what can be built up from a set of
 | 
| 1839 | 561  | 
messages. A form of upward closure. Pairs can be built, messages  | 
| 3668 | 562  | 
encrypted with known keys. Agent names are public domain.  | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
563  | 
Numbers can be guessed, but Nonces cannot be. *}  | 
| 1839 | 564  | 
|
| 23746 | 565  | 
inductive_set  | 
566  | 
synth :: "msg set => msg set"  | 
|
567  | 
for H :: "msg set"  | 
|
568  | 
where  | 
|
| 11192 | 569  | 
Inj [intro]: "X \<in> H ==> X \<in> synth H"  | 
| 23746 | 570  | 
| Agent [intro]: "Agent agt \<in> synth H"  | 
571  | 
| Number [intro]: "Number n \<in> synth H"  | 
|
572  | 
| Hash [intro]: "X \<in> synth H ==> Hash X \<in> synth H"  | 
|
573  | 
  | MPair  [intro]:   "[|X \<in> synth H;  Y \<in> synth H|] ==> {|X,Y|} \<in> synth H"
 | 
|
574  | 
| Crypt [intro]: "[|X \<in> synth H; Key(K) \<in> H|] ==> Crypt K X \<in> synth H"  | 
|
| 11189 | 575  | 
|
| 16818 | 576  | 
text{*Monotonicity*}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
577  | 
lemma synth_mono: "G\<subseteq>H ==> synth(G) \<subseteq> synth(H)"  | 
| 16818 | 578  | 
by (auto, erule synth.induct, auto)  | 
| 11189 | 579  | 
|
| 16818 | 580  | 
text{*NO @{text Agent_synth}, as any Agent name can be synthesized.  
 | 
581  | 
  The same holds for @{term Number}*}
 | 
|
| 11189 | 582  | 
|
| 39216 | 583  | 
inductive_simps synth_simps [iff]:  | 
584  | 
"Nonce n \<in> synth H"  | 
|
585  | 
"Key K \<in> synth H"  | 
|
586  | 
"Hash X \<in> synth H"  | 
|
587  | 
 "{|X,Y|} \<in> synth H"
 | 
|
588  | 
"Crypt K X \<in> synth H"  | 
|
| 13926 | 589  | 
|
590  | 
lemma synth_increasing: "H \<subseteq> synth(H)"  | 
|
591  | 
by blast  | 
|
592  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
593  | 
subsubsection{*Unions *}
 | 
| 13926 | 594  | 
|
| 16818 | 595  | 
text{*Converse fails: we can synth more from the union than from the 
 | 
596  | 
separate parts, building a compound message using elements of each.*}  | 
|
| 13926 | 597  | 
lemma synth_Un: "synth(G) \<union> synth(H) \<subseteq> synth(G \<union> H)"  | 
598  | 
by (intro Un_least synth_mono Un_upper1 Un_upper2)  | 
|
599  | 
||
600  | 
lemma synth_insert: "insert X (synth H) \<subseteq> synth(insert X H)"  | 
|
601  | 
by (blast intro: synth_mono [THEN [2] rev_subsetD])  | 
|
602  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
603  | 
subsubsection{*Idempotence and transitivity *}
 | 
| 13926 | 604  | 
|
605  | 
lemma synth_synthD [dest!]: "X\<in> synth (synth H) ==> X\<in> synth H"  | 
|
| 39216 | 606  | 
by (erule synth.induct, auto)  | 
| 13926 | 607  | 
|
608  | 
lemma synth_idem: "synth (synth H) = synth H"  | 
|
609  | 
by blast  | 
|
610  | 
||
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
611  | 
lemma synth_subset_iff [simp]: "(synth G \<subseteq> synth H) = (G \<subseteq> synth H)"  | 
| 
35566
 
3c01f5ad1d34
Simplified a couple of proofs and corrected a comment
 
paulson 
parents: 
35416 
diff
changeset
 | 
612  | 
by (metis subset_trans synth_idem synth_increasing synth_mono)  | 
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
613  | 
|
| 13926 | 614  | 
lemma synth_trans: "[| X\<in> synth G; G \<subseteq> synth H |] ==> X\<in> synth H"  | 
615  | 
by (drule synth_mono, blast)  | 
|
616  | 
||
| 16818 | 617  | 
text{*Cut; Lemma 2 of Lowe*}
 | 
| 13926 | 618  | 
lemma synth_cut: "[| Y\<in> synth (insert X H); X\<in> synth H |] ==> Y\<in> synth H"  | 
619  | 
by (erule synth_trans, blast)  | 
|
620  | 
||
621  | 
lemma Agent_synth [simp]: "Agent A \<in> synth H"  | 
|
622  | 
by blast  | 
|
623  | 
||
624  | 
lemma Number_synth [simp]: "Number n \<in> synth H"  | 
|
625  | 
by blast  | 
|
626  | 
||
627  | 
lemma Nonce_synth_eq [simp]: "(Nonce N \<in> synth H) = (Nonce N \<in> H)"  | 
|
628  | 
by blast  | 
|
629  | 
||
630  | 
lemma Key_synth_eq [simp]: "(Key K \<in> synth H) = (Key K \<in> H)"  | 
|
631  | 
by blast  | 
|
632  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
633  | 
lemma Crypt_synth_eq [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
634  | 
"Key K \<notin> H ==> (Crypt K X \<in> synth H) = (Crypt K X \<in> H)"  | 
| 13926 | 635  | 
by blast  | 
636  | 
||
637  | 
||
638  | 
lemma keysFor_synth [simp]:  | 
|
639  | 
    "keysFor (synth H) = keysFor H \<union> invKey`{K. Key K \<in> H}"
 | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
640  | 
by (unfold keysFor_def, blast)  | 
| 13926 | 641  | 
|
642  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
643  | 
subsubsection{*Combinations of parts, analz and synth *}
 | 
| 13926 | 644  | 
|
645  | 
lemma parts_synth [simp]: "parts (synth H) = parts H \<union> synth H"  | 
|
646  | 
apply (rule equalityI)  | 
|
647  | 
apply (rule subsetI)  | 
|
648  | 
apply (erule parts.induct)  | 
|
649  | 
apply (blast intro: synth_increasing [THEN parts_mono, THEN subsetD]  | 
|
650  | 
parts.Fst parts.Snd parts.Body)+  | 
|
651  | 
done  | 
|
652  | 
||
653  | 
lemma analz_analz_Un [simp]: "analz (analz G \<union> H) = analz (G \<union> H)"  | 
|
654  | 
apply (intro equalityI analz_subset_cong)+  | 
|
655  | 
apply simp_all  | 
|
656  | 
done  | 
|
657  | 
||
658  | 
lemma analz_synth_Un [simp]: "analz (synth G \<union> H) = analz (G \<union> H) \<union> synth G"  | 
|
659  | 
apply (rule equalityI)  | 
|
660  | 
apply (rule subsetI)  | 
|
661  | 
apply (erule analz.induct)  | 
|
662  | 
prefer 5 apply (blast intro: analz_mono [THEN [2] rev_subsetD])  | 
|
663  | 
apply (blast intro: analz.Fst analz.Snd analz.Decrypt)+  | 
|
664  | 
done  | 
|
665  | 
||
666  | 
lemma analz_synth [simp]: "analz (synth H) = analz H \<union> synth H"  | 
|
| 34185 | 667  | 
by (metis Un_empty_right analz_synth_Un)  | 
| 13926 | 668  | 
|
669  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
670  | 
subsubsection{*For reasoning about the Fake rule in traces *}
 | 
| 13926 | 671  | 
|
672  | 
lemma parts_insert_subset_Un: "X\<in> G ==> parts(insert X H) \<subseteq> parts G \<union> parts H"  | 
|
| 34185 | 673  | 
by (metis UnCI Un_upper2 insert_subset parts_Un parts_mono)  | 
| 13926 | 674  | 
|
| 
35566
 
3c01f5ad1d34
Simplified a couple of proofs and corrected a comment
 
paulson 
parents: 
35416 
diff
changeset
 | 
675  | 
text{*More specifically for Fake. See also @{text Fake_parts_sing} below *}
 | 
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
676  | 
lemma Fake_parts_insert:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
677  | 
"X \<in> synth (analz H) ==>  | 
| 13926 | 678  | 
parts (insert X H) \<subseteq> synth (analz H) \<union> parts H"  | 
| 34185 | 679  | 
by (metis Un_commute analz_increasing insert_subset parts_analz parts_mono  | 
680  | 
parts_synth synth_mono synth_subset_iff)  | 
|
| 13926 | 681  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
682  | 
lemma Fake_parts_insert_in_Un:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
683  | 
"[|Z \<in> parts (insert X H); X: synth (analz H)|]  | 
| 34185 | 684  | 
==> Z \<in> synth (analz H) \<union> parts H"  | 
685  | 
by (metis Fake_parts_insert set_mp)  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
686  | 
|
| 16818 | 687  | 
text{*@{term H} is sometimes @{term"Key ` KK \<union> spies evs"}, so can't put 
 | 
688  | 
  @{term "G=H"}.*}
 | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
689  | 
lemma Fake_analz_insert:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
690  | 
"X\<in> synth (analz G) ==>  | 
| 13926 | 691  | 
analz (insert X H) \<subseteq> synth (analz G) \<union> analz (G \<union> H)"  | 
692  | 
apply (rule subsetI)  | 
|
| 34185 | 693  | 
apply (subgoal_tac "x \<in> analz (synth (analz G) \<union> H)", force)  | 
694  | 
apply (blast intro: analz_mono [THEN [2] rev_subsetD] analz_mono [THEN synth_mono, THEN [2] rev_subsetD])  | 
|
| 13926 | 695  | 
done  | 
696  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
697  | 
lemma analz_conj_parts [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
698  | 
"(X \<in> analz H & X \<in> parts H) = (X \<in> analz H)"  | 
| 
14145
 
2e31b8cc8788
ZhouGollmann: new example (fair non-repudiation protocol)
 
paulson 
parents: 
14126 
diff
changeset
 | 
699  | 
by (blast intro: analz_subset_parts [THEN subsetD])  | 
| 13926 | 700  | 
|
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
701  | 
lemma analz_disj_parts [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
702  | 
"(X \<in> analz H | X \<in> parts H) = (X \<in> parts H)"  | 
| 
14145
 
2e31b8cc8788
ZhouGollmann: new example (fair non-repudiation protocol)
 
paulson 
parents: 
14126 
diff
changeset
 | 
703  | 
by (blast intro: analz_subset_parts [THEN subsetD])  | 
| 13926 | 704  | 
|
| 16818 | 705  | 
text{*Without this equation, other rules for synth and analz would yield
 | 
706  | 
redundant cases*}  | 
|
| 13926 | 707  | 
lemma MPair_synth_analz [iff]:  | 
708  | 
     "({|X,Y|} \<in> synth (analz H)) =  
 | 
|
709  | 
(X \<in> synth (analz H) & Y \<in> synth (analz H))"  | 
|
710  | 
by blast  | 
|
711  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
712  | 
lemma Crypt_synth_analz:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
713  | 
"[| Key K \<in> analz H; Key (invKey K) \<in> analz H |]  | 
| 13926 | 714  | 
==> (Crypt K X \<in> synth (analz H)) = (X \<in> synth (analz H))"  | 
715  | 
by blast  | 
|
716  | 
||
717  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
718  | 
lemma Hash_synth_analz [simp]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
719  | 
"X \<notin> synth (analz H)  | 
| 13926 | 720  | 
      ==> (Hash{|X,Y|} \<in> synth (analz H)) = (Hash{|X,Y|} \<in> analz H)"
 | 
721  | 
by blast  | 
|
722  | 
||
723  | 
||
724  | 
subsection{*HPair: a combination of Hash and MPair*}
 | 
|
725  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
726  | 
subsubsection{*Freeness *}
 | 
| 13926 | 727  | 
|
728  | 
lemma Agent_neq_HPair: "Agent A ~= Hash[X] Y"  | 
|
729  | 
by (unfold HPair_def, simp)  | 
|
730  | 
||
731  | 
lemma Nonce_neq_HPair: "Nonce N ~= Hash[X] Y"  | 
|
732  | 
by (unfold HPair_def, simp)  | 
|
733  | 
||
734  | 
lemma Number_neq_HPair: "Number N ~= Hash[X] Y"  | 
|
735  | 
by (unfold HPair_def, simp)  | 
|
736  | 
||
737  | 
lemma Key_neq_HPair: "Key K ~= Hash[X] Y"  | 
|
738  | 
by (unfold HPair_def, simp)  | 
|
739  | 
||
740  | 
lemma Hash_neq_HPair: "Hash Z ~= Hash[X] Y"  | 
|
741  | 
by (unfold HPair_def, simp)  | 
|
742  | 
||
743  | 
lemma Crypt_neq_HPair: "Crypt K X' ~= Hash[X] Y"  | 
|
744  | 
by (unfold HPair_def, simp)  | 
|
745  | 
||
746  | 
lemmas HPair_neqs = Agent_neq_HPair Nonce_neq_HPair Number_neq_HPair  | 
|
747  | 
Key_neq_HPair Hash_neq_HPair Crypt_neq_HPair  | 
|
748  | 
||
749  | 
declare HPair_neqs [iff]  | 
|
750  | 
declare HPair_neqs [symmetric, iff]  | 
|
751  | 
||
752  | 
lemma HPair_eq [iff]: "(Hash[X'] Y' = Hash[X] Y) = (X' = X & Y'=Y)"  | 
|
753  | 
by (simp add: HPair_def)  | 
|
754  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
755  | 
lemma MPair_eq_HPair [iff]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
756  | 
     "({|X',Y'|} = Hash[X] Y) = (X' = Hash{|X,Y|} & Y'=Y)"
 | 
| 13926 | 757  | 
by (simp add: HPair_def)  | 
758  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
759  | 
lemma HPair_eq_MPair [iff]:  | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
760  | 
     "(Hash[X] Y = {|X',Y'|}) = (X' = Hash{|X,Y|} & Y'=Y)"
 | 
| 13926 | 761  | 
by (auto simp add: HPair_def)  | 
762  | 
||
763  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
764  | 
subsubsection{*Specialized laws, proved in terms of those for Hash and MPair *}
 | 
| 13926 | 765  | 
|
766  | 
lemma keysFor_insert_HPair [simp]: "keysFor (insert (Hash[X] Y) H) = keysFor H"  | 
|
767  | 
by (simp add: HPair_def)  | 
|
768  | 
||
769  | 
lemma parts_insert_HPair [simp]:  | 
|
770  | 
"parts (insert (Hash[X] Y) H) =  | 
|
771  | 
     insert (Hash[X] Y) (insert (Hash{|X,Y|}) (parts (insert Y H)))"
 | 
|
772  | 
by (simp add: HPair_def)  | 
|
773  | 
||
774  | 
lemma analz_insert_HPair [simp]:  | 
|
775  | 
"analz (insert (Hash[X] Y) H) =  | 
|
776  | 
     insert (Hash[X] Y) (insert (Hash{|X,Y|}) (analz (insert Y H)))"
 | 
|
777  | 
by (simp add: HPair_def)  | 
|
778  | 
||
779  | 
lemma HPair_synth_analz [simp]:  | 
|
780  | 
"X \<notin> synth (analz H)  | 
|
781  | 
==> (Hash[X] Y \<in> synth (analz H)) =  | 
|
782  | 
        (Hash {|X, Y|} \<in> analz H & Y \<in> synth (analz H))"
 | 
|
| 39216 | 783  | 
by (auto simp add: HPair_def)  | 
| 13926 | 784  | 
|
785  | 
||
| 16818 | 786  | 
text{*We do NOT want Crypt... messages broken up in protocols!!*}
 | 
| 13926 | 787  | 
declare parts.Body [rule del]  | 
788  | 
||
789  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
790  | 
text{*Rewrites to push in Key and Crypt messages, so that other messages can
 | 
| 
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
791  | 
    be pulled out using the @{text analz_insert} rules*}
 | 
| 13926 | 792  | 
|
| 27225 | 793  | 
lemmas pushKeys [standard] =  | 
794  | 
insert_commute [of "Key K" "Agent C"]  | 
|
795  | 
insert_commute [of "Key K" "Nonce N"]  | 
|
796  | 
insert_commute [of "Key K" "Number N"]  | 
|
797  | 
insert_commute [of "Key K" "Hash X"]  | 
|
798  | 
insert_commute [of "Key K" "MPair X Y"]  | 
|
799  | 
insert_commute [of "Key K" "Crypt X K'"]  | 
|
| 13926 | 800  | 
|
| 27225 | 801  | 
lemmas pushCrypts [standard] =  | 
802  | 
insert_commute [of "Crypt X K" "Agent C"]  | 
|
803  | 
insert_commute [of "Crypt X K" "Agent C"]  | 
|
804  | 
insert_commute [of "Crypt X K" "Nonce N"]  | 
|
805  | 
insert_commute [of "Crypt X K" "Number N"]  | 
|
806  | 
insert_commute [of "Crypt X K" "Hash X'"]  | 
|
807  | 
insert_commute [of "Crypt X K" "MPair X' Y"]  | 
|
| 13926 | 808  | 
|
809  | 
text{*Cannot be added with @{text "[simp]"} -- messages should not always be
 | 
|
810  | 
re-ordered. *}  | 
|
811  | 
lemmas pushes = pushKeys pushCrypts  | 
|
812  | 
||
813  | 
||
| 
43582
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
814  | 
subsection{*The set of key-free messages*}
 | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
815  | 
|
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
816  | 
(*Note that even the encryption of a key-free message remains key-free.  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
817  | 
This concept is valuable because of the theorem analz_keyfree_into_Un, proved below. *)  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
818  | 
|
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
819  | 
inductive_set  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
820  | 
keyfree :: "msg set"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
821  | 
where  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
822  | 
Agent: "Agent A \<in> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
823  | 
| Number: "Number N \<in> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
824  | 
| Nonce: "Nonce N \<in> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
825  | 
| Hash: "Hash X \<in> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
826  | 
  | MPair:  "[|X \<in> keyfree;  Y \<in> keyfree|] ==> {|X,Y|} \<in> keyfree"
 | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
827  | 
| Crypt: "[|X \<in> keyfree|] ==> Crypt K X \<in> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
828  | 
|
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
829  | 
|
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
830  | 
declare keyfree.intros [intro]  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
831  | 
|
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
832  | 
inductive_cases keyfree_KeyE: "Key K \<in> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
833  | 
inductive_cases keyfree_MPairE: "{|X,Y|} \<in> keyfree"
 | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
834  | 
inductive_cases keyfree_CryptE: "Crypt K X \<in> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
835  | 
|
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
836  | 
lemma parts_keyfree: "parts (keyfree) \<subseteq> keyfree"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
837  | 
by (clarify, erule parts.induct, auto elim!: keyfree_KeyE keyfree_MPairE keyfree_CryptE)  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
838  | 
|
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
839  | 
(*The key-free part of a set of messages can be removed from the scope of the analz operator.*)  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
840  | 
lemma analz_keyfree_into_Un: "\<lbrakk>X \<in> analz (G \<union> H); G \<subseteq> keyfree\<rbrakk> \<Longrightarrow> X \<in> parts G \<union> analz H"  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
841  | 
apply (erule analz.induct, auto)  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
842  | 
apply (blast dest:parts.Body)  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
843  | 
apply (blast dest: parts.Body)  | 
| 
44174
 
d1d79f0e1ea6
make more HOL theories work with separate set type
 
huffman 
parents: 
43582 
diff
changeset
 | 
844  | 
apply (metis Un_absorb2 keyfree_KeyE parts_Un parts_keyfree UnI2)  | 
| 
43582
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
845  | 
done  | 
| 
 
ddca453102ab
keyfree: The set of key-free messages (and associated theorems)
 
paulson 
parents: 
42793 
diff
changeset
 | 
846  | 
|
| 13926 | 847  | 
subsection{*Tactics useful for many protocol proofs*}
 | 
848  | 
ML  | 
|
849  | 
{*
 | 
|
850  | 
(*Analysis of Fake cases. Also works for messages that forward unknown parts,  | 
|
851  | 
but this application is no longer necessary if analz_insert_eq is used.  | 
|
852  | 
Abstraction over i is ESSENTIAL: it delays the dereferencing of claset  | 
|
853  | 
DEPENDS UPON "X" REFERRING TO THE FRADULENT MESSAGE *)  | 
|
854  | 
||
| 
32117
 
0762b9ad83df
Set.thy: prefer = over == where possible; tuned ML setup; dropped (moved) ML legacy
 
haftmann 
parents: 
30607 
diff
changeset
 | 
855  | 
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
 | 
856  | 
|
| 13926 | 857  | 
(*Apply rules to break down assumptions of the form  | 
858  | 
Y \<in> parts(insert X H) and Y \<in> analz(insert X H)  | 
|
859  | 
*)  | 
|
860  | 
val Fake_insert_tac =  | 
|
| 24122 | 861  | 
    dresolve_tac [impOfSubs @{thm Fake_analz_insert},
 | 
862  | 
                  impOfSubs @{thm Fake_parts_insert}] THEN'
 | 
|
863  | 
    eresolve_tac [asm_rl, @{thm synth.Inj}];
 | 
|
| 13926 | 864  | 
|
865  | 
fun Fake_insert_simp_tac ss i =  | 
|
| 42793 | 866  | 
REPEAT (Fake_insert_tac i) THEN asm_full_simp_tac ss i;  | 
| 13926 | 867  | 
|
| 42474 | 868  | 
fun atomic_spy_analz_tac ctxt =  | 
| 42793 | 869  | 
SELECT_GOAL  | 
870  | 
(Fake_insert_simp_tac (simpset_of ctxt) 1 THEN  | 
|
871  | 
IF_UNSOLVED  | 
|
872  | 
(Blast.depth_tac  | 
|
873  | 
        (ctxt addIs [@{thm analz_insertI}, impOfSubs @{thm analz_subset_parts}]) 4 1));
 | 
|
| 13926 | 874  | 
|
| 42474 | 875  | 
fun spy_analz_tac ctxt i =  | 
| 42793 | 876  | 
DETERM  | 
877  | 
(SELECT_GOAL  | 
|
878  | 
(EVERY  | 
|
879  | 
[ (*push in occurrences of X...*)  | 
|
880  | 
(REPEAT o CHANGED)  | 
|
881  | 
           (res_inst_tac ctxt [(("x", 1), "X")] (insert_commute RS ssubst) 1),
 | 
|
882  | 
(*...allowing further simplifications*)  | 
|
883  | 
simp_tac (simpset_of ctxt) 1,  | 
|
884  | 
REPEAT (FIRSTGOAL (resolve_tac [allI,impI,notI,conjI,iffI])),  | 
|
885  | 
DEPTH_SOLVE (atomic_spy_analz_tac ctxt 1)]) i);  | 
|
| 13926 | 886  | 
*}  | 
887  | 
||
| 16818 | 888  | 
text{*By default only @{text o_apply} is built-in.  But in the presence of
 | 
889  | 
eta-expansion this means that some terms displayed as @{term "f o g"} will be
 | 
|
890  | 
rewritten, and others will not!*}  | 
|
| 13926 | 891  | 
declare o_def [simp]  | 
892  | 
||
| 11189 | 893  | 
|
| 13922 | 894  | 
lemma Crypt_notin_image_Key [simp]: "Crypt K X \<notin> Key ` A"  | 
895  | 
by auto  | 
|
896  | 
||
897  | 
lemma Hash_notin_image_Key [simp] :"Hash X \<notin> Key ` A"  | 
|
898  | 
by auto  | 
|
899  | 
||
| 
14200
 
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
 
paulson 
parents: 
14181 
diff
changeset
 | 
900  | 
lemma synth_analz_mono: "G\<subseteq>H ==> synth (analz(G)) \<subseteq> synth (analz(H))"  | 
| 
17689
 
a04b5b43625e
streamlined theory; conformance to recent publication
 
paulson 
parents: 
16818 
diff
changeset
 | 
901  | 
by (iprover intro: synth_mono analz_mono)  | 
| 13922 | 902  | 
|
903  | 
lemma Fake_analz_eq [simp]:  | 
|
904  | 
"X \<in> synth(analz H) ==> synth (analz (insert X H)) = synth (analz H)"  | 
|
| 
35566
 
3c01f5ad1d34
Simplified a couple of proofs and corrected a comment
 
paulson 
parents: 
35416 
diff
changeset
 | 
905  | 
by (metis Fake_analz_insert Un_absorb Un_absorb1 Un_commute  | 
| 34185 | 906  | 
subset_insertI synth_analz_mono synth_increasing synth_subset_iff)  | 
| 13922 | 907  | 
|
908  | 
text{*Two generalizations of @{text analz_insert_eq}*}
 | 
|
909  | 
lemma gen_analz_insert_eq [rule_format]:  | 
|
| 
35566
 
3c01f5ad1d34
Simplified a couple of proofs and corrected a comment
 
paulson 
parents: 
35416 
diff
changeset
 | 
910  | 
"X \<in> analz H ==> ALL G. H \<subseteq> G --> analz (insert X G) = analz G"  | 
| 13922 | 911  | 
by (blast intro: analz_cut analz_insertI analz_mono [THEN [2] rev_subsetD])  | 
912  | 
||
913  | 
lemma synth_analz_insert_eq [rule_format]:  | 
|
914  | 
"X \<in> synth (analz H)  | 
|
| 
35566
 
3c01f5ad1d34
Simplified a couple of proofs and corrected a comment
 
paulson 
parents: 
35416 
diff
changeset
 | 
915  | 
==> ALL G. H \<subseteq> G --> (Key K \<in> analz (insert X G)) = (Key K \<in> analz G)"  | 
| 13922 | 916  | 
apply (erule synth.induct)  | 
917  | 
apply (simp_all add: gen_analz_insert_eq subset_trans [OF _ subset_insertI])  | 
|
918  | 
done  | 
|
919  | 
||
920  | 
lemma Fake_parts_sing:  | 
|
| 34185 | 921  | 
     "X \<in> synth (analz H) ==> parts{X} \<subseteq> synth (analz H) \<union> parts H"
 | 
922  | 
by (metis Fake_parts_insert empty_subsetI insert_mono parts_mono subset_trans)  | 
|
| 13922 | 923  | 
|
| 
14145
 
2e31b8cc8788
ZhouGollmann: new example (fair non-repudiation protocol)
 
paulson 
parents: 
14126 
diff
changeset
 | 
924  | 
lemmas Fake_parts_sing_imp_Un = Fake_parts_sing [THEN [2] rev_subsetD]  | 
| 
 
2e31b8cc8788
ZhouGollmann: new example (fair non-repudiation protocol)
 
paulson 
parents: 
14126 
diff
changeset
 | 
925  | 
|
| 11189 | 926  | 
method_setup spy_analz = {*
 | 
| 42474 | 927  | 
Scan.succeed (SIMPLE_METHOD' o spy_analz_tac) *}  | 
| 11189 | 928  | 
"for proving the Fake case when analz is involved"  | 
| 1839 | 929  | 
|
| 11264 | 930  | 
method_setup atomic_spy_analz = {*
 | 
| 42474 | 931  | 
Scan.succeed (SIMPLE_METHOD' o atomic_spy_analz_tac) *}  | 
| 11264 | 932  | 
"for debugging spy_analz"  | 
933  | 
||
934  | 
method_setup Fake_insert_simp = {*
 | 
|
| 42474 | 935  | 
Scan.succeed (SIMPLE_METHOD' o Fake_insert_simp_tac o simpset_of) *}  | 
| 11264 | 936  | 
"for debugging spy_analz"  | 
937  | 
||
| 1839 | 938  | 
end  |