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