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