| author | Fabian Huch <huch@in.tum.de> | 
| Tue, 06 Aug 2024 15:00:37 +0200 | |
| changeset 80645 | a1dce0cc6c26 | 
| parent 76340 | fdb91b733b65 | 
| child 80768 | c7723cc15de8 | 
| permissions | -rw-r--r-- | 
| 41141 
ad923cdd4a5d
added example to exercise higher-order reasoning with Sledgehammer and Metis
 blanchet parents: 
39260diff
changeset | 1 | (* Title: HOL/Metis_Examples/Message.thy | 
| 43197 | 2 | Author: Lawrence C. Paulson, Cambridge University Computer Laboratory | 
| 41144 | 3 | Author: Jasmin Blanchette, TU Muenchen | 
| 23449 | 4 | |
| 43197 | 5 | Metis example featuring message authentication. | 
| 23449 | 6 | *) | 
| 7 | ||
| 63167 | 8 | section \<open>Metis Example Featuring Message Authentication\<close> | 
| 43197 | 9 | |
| 36553 | 10 | theory Message | 
| 11 | imports Main | |
| 12 | begin | |
| 23449 | 13 | |
| 50705 
0e943b33d907
use new skolemizer for reconstructing skolemization steps in Isar proofs (because the old skolemizer messes up the order of the Skolem arguments)
 blanchet parents: 
46075diff
changeset | 14 | declare [[metis_new_skolem]] | 
| 42103 
6066a35f6678
Metis examples use the new Skolemizer to test it
 blanchet parents: 
41144diff
changeset | 15 | |
| 23449 | 16 | lemma strange_Un_eq [simp]: "A \<union> (B \<union> A) = B \<union> A" | 
| 36911 | 17 | by (metis Un_commute Un_left_absorb) | 
| 23449 | 18 | |
| 42463 | 19 | type_synonym key = nat | 
| 23449 | 20 | |
| 21 | consts | |
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 22 | all_symmetric :: bool \<comment> \<open>true if all keys are symmetric\<close> | 
| 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 23 | invKey :: "key=>key" \<comment> \<open>inverse of a symmetric key\<close> | 
| 23449 | 24 | |
| 25 | specification (invKey) | |
| 26 | invKey [simp]: "invKey (invKey K) = K" | |
| 27 | invKey_symmetric: "all_symmetric --> invKey = id" | |
| 36553 | 28 | by (metis id_apply) | 
| 23449 | 29 | |
| 30 | ||
| 63167 | 31 | text\<open>The inverse of a symmetric key is itself; that of a public key | 
| 32 | is the private key and vice versa\<close> | |
| 23449 | 33 | |
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35109diff
changeset | 34 | definition symKeys :: "key set" where | 
| 23449 | 35 |   "symKeys == {K. invKey K = K}"
 | 
| 36 | ||
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 37 | datatype \<comment> \<open>We allow any number of friendly agents\<close> | 
| 23449 | 38 | agent = Server | Friend nat | Spy | 
| 39 | ||
| 58310 | 40 | datatype | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 41 | msg = Agent agent \<comment> \<open>Agent names\<close> | 
| 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 42 | | Number nat \<comment> \<open>Ordinary integers, timestamps, ...\<close> | 
| 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 43 | | Nonce nat \<comment> \<open>Unguessable nonces\<close> | 
| 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 44 | | Key key \<comment> \<open>Crypto keys\<close> | 
| 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 45 | | Hash msg \<comment> \<open>Hashing\<close> | 
| 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 46 | | MPair msg msg \<comment> \<open>Compound messages\<close> | 
| 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 47 | | Crypt key msg \<comment> \<open>Encryption, public- or shared-key\<close> | 
| 23449 | 48 | |
| 49 | ||
| 63167 | 50 | text\<open>Concrete syntax: messages appear as \<open>\<lbrace>A,B,NA\<rbrace>\<close>, etc...\<close> | 
| 23449 | 51 | syntax | 
| 35109 | 52 |   "_MTuple"      :: "['a, args] => 'a * 'b"       ("(2\<lbrace>_,/ _\<rbrace>)")
 | 
| 23449 | 53 | translations | 
| 61984 | 54 | "\<lbrace>x, y, z\<rbrace>" == "\<lbrace>x, \<lbrace>y, z\<rbrace>\<rbrace>" | 
| 55 | "\<lbrace>x, y\<rbrace>" == "CONST MPair x y" | |
| 23449 | 56 | |
| 57 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35109diff
changeset | 58 | definition HPair :: "[msg,msg] => msg" ("(4Hash[_] /_)" [0, 1000]) where
 | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 59 | \<comment> \<open>Message Y paired with a MAC computed with the help of X\<close> | 
| 61984 | 60 | "Hash[X] Y == \<lbrace> Hash\<lbrace>X,Y\<rbrace>, Y\<rbrace>" | 
| 23449 | 61 | |
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35109diff
changeset | 62 | definition keysFor :: "msg set => key set" where | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
63167diff
changeset | 63 | \<comment> \<open>Keys useful to decrypt elements of a message set\<close> | 
| 23449 | 64 |   "keysFor H == invKey ` {K. \<exists>X. Crypt K X \<in> H}"
 | 
| 65 | ||
| 66 | ||
| 63167 | 67 | subsubsection\<open>Inductive Definition of All Parts" of a Message\<close> | 
| 23449 | 68 | |
| 23755 | 69 | inductive_set | 
| 70 | parts :: "msg set => msg set" | |
| 71 | for H :: "msg set" | |
| 72 | where | |
| 23449 | 73 | Inj [intro]: "X \<in> H ==> X \<in> parts H" | 
| 61984 | 74 | | Fst: "\<lbrace>X,Y\<rbrace> \<in> parts H ==> X \<in> parts H" | 
| 75 | | Snd: "\<lbrace>X,Y\<rbrace> \<in> parts H ==> Y \<in> parts H" | |
| 23755 | 76 | | Body: "Crypt K X \<in> parts H ==> X \<in> parts H" | 
| 23449 | 77 | |
| 78 | lemma parts_mono: "G \<subseteq> H ==> parts(G) \<subseteq> parts(H)" | |
| 79 | apply auto | |
| 36553 | 80 | apply (erule parts.induct) | 
| 69712 | 81 | apply (metis parts.Inj rev_subsetD) | 
| 36553 | 82 | apply (metis parts.Fst) | 
| 83 | apply (metis parts.Snd) | |
| 84 | by (metis parts.Body) | |
| 23449 | 85 | |
| 63167 | 86 | text\<open>Equations hold because constructors are injective.\<close> | 
| 67613 | 87 | lemma Friend_image_eq [simp]: "(Friend x \<in> Friend`A) = (x\<in>A)" | 
| 39260 | 88 | by (metis agent.inject image_iff) | 
| 23449 | 89 | |
| 36553 | 90 | lemma Key_image_eq [simp]: "(Key x \<in> Key`A) = (x \<in> A)" | 
| 91 | by (metis image_iff msg.inject(4)) | |
| 23449 | 92 | |
| 36553 | 93 | lemma Nonce_Key_image_eq [simp]: "Nonce x \<notin> Key`A" | 
| 94 | by (metis image_iff msg.distinct(23)) | |
| 23449 | 95 | |
| 96 | ||
| 63167 | 97 | subsubsection\<open>Inverse of keys\<close> | 
| 23449 | 98 | |
| 36553 | 99 | lemma invKey_eq [simp]: "(invKey K = invKey K') = (K = K')" | 
| 23449 | 100 | by (metis invKey) | 
| 101 | ||
| 102 | ||
| 63167 | 103 | subsection\<open>keysFor operator\<close> | 
| 23449 | 104 | |
| 105 | lemma keysFor_empty [simp]: "keysFor {} = {}"
 | |
| 106 | by (unfold keysFor_def, blast) | |
| 107 | ||
| 108 | lemma keysFor_Un [simp]: "keysFor (H \<union> H') = keysFor H \<union> keysFor H'" | |
| 109 | by (unfold keysFor_def, blast) | |
| 110 | ||
| 111 | lemma keysFor_UN [simp]: "keysFor (\<Union>i\<in>A. H i) = (\<Union>i\<in>A. keysFor (H i))" | |
| 112 | by (unfold keysFor_def, blast) | |
| 113 | ||
| 63167 | 114 | text\<open>Monotonicity\<close> | 
| 23449 | 115 | lemma keysFor_mono: "G \<subseteq> H ==> keysFor(G) \<subseteq> keysFor(H)" | 
| 116 | by (unfold keysFor_def, blast) | |
| 117 | ||
| 118 | lemma keysFor_insert_Agent [simp]: "keysFor (insert (Agent A) H) = keysFor H" | |
| 119 | by (unfold keysFor_def, auto) | |
| 120 | ||
| 121 | lemma keysFor_insert_Nonce [simp]: "keysFor (insert (Nonce N) H) = keysFor H" | |
| 122 | by (unfold keysFor_def, auto) | |
| 123 | ||
| 124 | lemma keysFor_insert_Number [simp]: "keysFor (insert (Number N) H) = keysFor H" | |
| 125 | by (unfold keysFor_def, auto) | |
| 126 | ||
| 127 | lemma keysFor_insert_Key [simp]: "keysFor (insert (Key K) H) = keysFor H" | |
| 128 | by (unfold keysFor_def, auto) | |
| 129 | ||
| 130 | lemma keysFor_insert_Hash [simp]: "keysFor (insert (Hash X) H) = keysFor H" | |
| 131 | by (unfold keysFor_def, auto) | |
| 132 | ||
| 61984 | 133 | lemma keysFor_insert_MPair [simp]: "keysFor (insert \<lbrace>X,Y\<rbrace> H) = keysFor H" | 
| 23449 | 134 | by (unfold keysFor_def, auto) | 
| 135 | ||
| 43197 | 136 | lemma keysFor_insert_Crypt [simp]: | 
| 23449 | 137 | "keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)" | 
| 138 | by (unfold keysFor_def, auto) | |
| 139 | ||
| 140 | lemma keysFor_image_Key [simp]: "keysFor (Key`E) = {}"
 | |
| 141 | by (unfold keysFor_def, auto) | |
| 142 | ||
| 143 | lemma Crypt_imp_invKey_keysFor: "Crypt K X \<in> H ==> invKey K \<in> keysFor H" | |
| 144 | by (unfold keysFor_def, blast) | |
| 145 | ||
| 146 | ||
| 63167 | 147 | subsection\<open>Inductive relation "parts"\<close> | 
| 23449 | 148 | |
| 149 | lemma MPair_parts: | |
| 61984 | 150 | "[| \<lbrace>X,Y\<rbrace> \<in> parts H; | 
| 23449 | 151 | [| X \<in> parts H; Y \<in> parts H |] ==> P |] ==> P" | 
| 43197 | 152 | by (blast dest: parts.Fst parts.Snd) | 
| 23449 | 153 | |
| 36553 | 154 | declare MPair_parts [elim!] parts.Body [dest!] | 
| 63167 | 155 | text\<open>NB These two rules are UNSAFE in the formal sense, as they discard the | 
| 43197 | 156 | compound message. They work well on THIS FILE. | 
| 63167 | 157 | \<open>MPair_parts\<close> is left as SAFE because it speeds up proofs. | 
| 158 | The Crypt rule is normally kept UNSAFE to avoid breaking up certificates.\<close> | |
| 23449 | 159 | |
| 160 | lemma parts_increasing: "H \<subseteq> parts(H)" | |
| 161 | by blast | |
| 162 | ||
| 45605 | 163 | lemmas parts_insertI = subset_insertI [THEN parts_mono, THEN subsetD] | 
| 23449 | 164 | |
| 165 | lemma parts_empty [simp]: "parts{} = {}"
 | |
| 166 | apply safe | |
| 167 | apply (erule parts.induct) | |
| 168 | apply blast+ | |
| 169 | done | |
| 170 | ||
| 171 | lemma parts_emptyE [elim!]: "X\<in> parts{} ==> P"
 | |
| 172 | by simp | |
| 173 | ||
| 63167 | 174 | text\<open>WARNING: loops if H = {Y}, therefore must not be repeated!\<close>
 | 
| 23449 | 175 | lemma parts_singleton: "X\<in> parts H ==> \<exists>Y\<in>H. X\<in> parts {Y}"
 | 
| 176 | apply (erule parts.induct) | |
| 26807 
4cd176ea28dc
Replaced blast by fast in proof of parts_singleton, since blast looped
 berghofe parents: 
25710diff
changeset | 177 | apply fast+ | 
| 23449 | 178 | done | 
| 179 | ||
| 180 | ||
| 63167 | 181 | subsubsection\<open>Unions\<close> | 
| 23449 | 182 | |
| 183 | lemma parts_Un_subset1: "parts(G) \<union> parts(H) \<subseteq> parts(G \<union> H)" | |
| 184 | by (intro Un_least parts_mono Un_upper1 Un_upper2) | |
| 185 | ||
| 186 | lemma parts_Un_subset2: "parts(G \<union> H) \<subseteq> parts(G) \<union> parts(H)" | |
| 187 | apply (rule subsetI) | |
| 188 | apply (erule parts.induct, blast+) | |
| 189 | done | |
| 190 | ||
| 191 | lemma parts_Un [simp]: "parts(G \<union> H) = parts(G) \<union> parts(H)" | |
| 192 | by (intro equalityI parts_Un_subset1 parts_Un_subset2) | |
| 193 | ||
| 194 | lemma parts_insert: "parts (insert X H) = parts {X} \<union> parts H"
 | |
| 195 | apply (subst insert_is_Un [of _ H]) | |
| 196 | apply (simp only: parts_Un) | |
| 197 | done | |
| 198 | ||
| 199 | lemma parts_insert2: | |
| 200 |      "parts (insert X (insert Y H)) = parts {X} \<union> parts {Y} \<union> parts H"
 | |
| 25710 
4cdf7de81e1b
Replaced refs by config params; finer critical section in mets method
 paulson parents: 
25457diff
changeset | 201 | by (metis Un_commute Un_empty_left Un_empty_right Un_insert_left Un_insert_right parts_Un) | 
| 23449 | 202 | |
| 203 | ||
| 204 | lemma parts_UN_subset1: "(\<Union>x\<in>A. parts(H x)) \<subseteq> parts(\<Union>x\<in>A. H x)" | |
| 205 | by (intro UN_least parts_mono UN_upper) | |
| 206 | ||
| 207 | lemma parts_UN_subset2: "parts(\<Union>x\<in>A. H x) \<subseteq> (\<Union>x\<in>A. parts(H x))" | |
| 208 | apply (rule subsetI) | |
| 209 | apply (erule parts.induct, blast+) | |
| 210 | done | |
| 211 | ||
| 212 | ||
| 63167 | 213 | text\<open>This allows \<open>blast\<close> to simplify occurrences of | 
| 69597 | 214 | \<^term>\<open>parts(G\<union>H)\<close> in the assumption.\<close> | 
| 43197 | 215 | lemmas in_parts_UnE = parts_Un [THEN equalityD1, THEN subsetD, THEN UnE] | 
| 23449 | 216 | declare in_parts_UnE [elim!] | 
| 217 | ||
| 218 | lemma parts_insert_subset: "insert X (parts H) \<subseteq> parts(insert X H)" | |
| 219 | by (blast intro: parts_mono [THEN [2] rev_subsetD]) | |
| 220 | ||
| 63167 | 221 | subsubsection\<open>Idempotence and transitivity\<close> | 
| 23449 | 222 | |
| 223 | lemma parts_partsD [dest!]: "X\<in> parts (parts H) ==> X\<in> parts H" | |
| 224 | by (erule parts.induct, blast+) | |
| 225 | ||
| 226 | lemma parts_idem [simp]: "parts (parts H) = parts H" | |
| 227 | by blast | |
| 228 | ||
| 229 | lemma parts_subset_iff [simp]: "(parts G \<subseteq> parts H) = (G \<subseteq> parts H)" | |
| 43197 | 230 | apply (rule iffI) | 
| 23449 | 231 | apply (metis Un_absorb1 Un_subset_iff parts_Un parts_increasing) | 
| 25710 
4cdf7de81e1b
Replaced refs by config params; finer critical section in mets method
 paulson parents: 
25457diff
changeset | 232 | apply (metis parts_idem parts_mono) | 
| 23449 | 233 | done | 
| 234 | ||
| 235 | lemma parts_trans: "[| X\<in> parts G; G \<subseteq> parts H |] ==> X\<in> parts H" | |
| 45503 | 236 | by (blast dest: parts_mono) | 
| 23449 | 237 | |
| 46075 
0054a9513b37
reintroduced "metis" call taken out after reintroducing "set" as a constructor, and added two "metis" calls that used to be too slow
 blanchet parents: 
45970diff
changeset | 238 | lemma parts_cut: "[|Y\<in> parts (insert X G); X\<in> parts H|] ==> Y\<in> parts(G \<union> H)" | 
| 
0054a9513b37
reintroduced "metis" call taken out after reintroducing "set" as a constructor, and added two "metis" calls that used to be too slow
 blanchet parents: 
45970diff
changeset | 239 | by (metis (no_types) Un_insert_left Un_insert_right insert_absorb le_supE | 
| 
0054a9513b37
reintroduced "metis" call taken out after reintroducing "set" as a constructor, and added two "metis" calls that used to be too slow
 blanchet parents: 
45970diff
changeset | 240 | parts_Un parts_idem parts_increasing parts_trans) | 
| 23449 | 241 | |
| 63167 | 242 | subsubsection\<open>Rewrite rules for pulling out atomic messages\<close> | 
| 23449 | 243 | |
| 244 | lemmas parts_insert_eq_I = equalityI [OF subsetI parts_insert_subset] | |
| 245 | ||
| 246 | ||
| 247 | lemma parts_insert_Agent [simp]: | |
| 248 | "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)" | |
| 43197 | 249 | apply (rule parts_insert_eq_I) | 
| 250 | apply (erule parts.induct, auto) | |
| 23449 | 251 | done | 
| 252 | ||
| 253 | lemma parts_insert_Nonce [simp]: | |
| 254 | "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)" | |
| 43197 | 255 | apply (rule parts_insert_eq_I) | 
| 256 | apply (erule parts.induct, auto) | |
| 23449 | 257 | done | 
| 258 | ||
| 259 | lemma parts_insert_Number [simp]: | |
| 260 | "parts (insert (Number N) H) = insert (Number N) (parts H)" | |
| 43197 | 261 | apply (rule parts_insert_eq_I) | 
| 262 | apply (erule parts.induct, auto) | |
| 23449 | 263 | done | 
| 264 | ||
| 265 | lemma parts_insert_Key [simp]: | |
| 266 | "parts (insert (Key K) H) = insert (Key K) (parts H)" | |
| 43197 | 267 | apply (rule parts_insert_eq_I) | 
| 268 | apply (erule parts.induct, auto) | |
| 23449 | 269 | done | 
| 270 | ||
| 271 | lemma parts_insert_Hash [simp]: | |
| 272 | "parts (insert (Hash X) H) = insert (Hash X) (parts H)" | |
| 43197 | 273 | apply (rule parts_insert_eq_I) | 
| 274 | apply (erule parts.induct, auto) | |
| 23449 | 275 | done | 
| 276 | ||
| 277 | lemma parts_insert_Crypt [simp]: | |
| 43197 | 278 | "parts (insert (Crypt K X) H) = | 
| 23449 | 279 | insert (Crypt K X) (parts (insert X H))" | 
| 280 | apply (rule equalityI) | |
| 281 | apply (rule subsetI) | |
| 282 | apply (erule parts.induct, auto) | |
| 283 | apply (blast intro: parts.Body) | |
| 284 | done | |
| 285 | ||
| 286 | lemma parts_insert_MPair [simp]: | |
| 61984 | 287 | "parts (insert \<lbrace>X,Y\<rbrace> H) = | 
| 288 | insert \<lbrace>X,Y\<rbrace> (parts (insert X (insert Y H)))" | |
| 23449 | 289 | apply (rule equalityI) | 
| 290 | apply (rule subsetI) | |
| 291 | apply (erule parts.induct, auto) | |
| 292 | apply (blast intro: parts.Fst parts.Snd)+ | |
| 293 | done | |
| 294 | ||
| 295 | lemma parts_image_Key [simp]: "parts (Key`N) = Key`N" | |
| 296 | apply auto | |
| 297 | apply (erule parts.induct, auto) | |
| 298 | done | |
| 299 | ||
| 300 | lemma msg_Nonce_supply: "\<exists>N. \<forall>n. N\<le>n --> Nonce n \<notin> parts {msg}"
 | |
| 43197 | 301 | apply (induct_tac "msg") | 
| 23449 | 302 | apply (simp_all add: parts_insert2) | 
| 303 | apply (metis Suc_n_not_le_n) | |
| 304 | apply (metis le_trans linorder_linear) | |
| 305 | done | |
| 306 | ||
| 63167 | 307 | subsection\<open>Inductive relation "analz"\<close> | 
| 23449 | 308 | |
| 63167 | 309 | text\<open>Inductive definition of "analz" -- what can be broken down from a set of | 
| 23449 | 310 | messages, including keys. A form of downward closure. Pairs can | 
| 63167 | 311 | be taken apart; messages decrypted with known keys.\<close> | 
| 23449 | 312 | |
| 23755 | 313 | inductive_set | 
| 314 | analz :: "msg set => msg set" | |
| 315 | for H :: "msg set" | |
| 316 | where | |
| 23449 | 317 | Inj [intro,simp] : "X \<in> H ==> X \<in> analz H" | 
| 61984 | 318 | | Fst: "\<lbrace>X,Y\<rbrace> \<in> analz H ==> X \<in> analz H" | 
| 319 | | Snd: "\<lbrace>X,Y\<rbrace> \<in> analz H ==> Y \<in> analz H" | |
| 43197 | 320 | | Decrypt [dest]: | 
| 67613 | 321 | "[|Crypt K X \<in> analz H; Key(invKey K) \<in> analz H|] ==> X \<in> analz H" | 
| 23449 | 322 | |
| 323 | ||
| 63167 | 324 | text\<open>Monotonicity; Lemma 1 of Lowe's paper\<close> | 
| 23449 | 325 | lemma analz_mono: "G\<subseteq>H ==> analz(G) \<subseteq> analz(H)" | 
| 326 | apply auto | |
| 43197 | 327 | apply (erule analz.induct) | 
| 328 | apply (auto dest: analz.Fst analz.Snd) | |
| 23449 | 329 | done | 
| 330 | ||
| 63167 | 331 | text\<open>Making it safe speeds up proofs\<close> | 
| 23449 | 332 | lemma MPair_analz [elim!]: | 
| 61984 | 333 | "[| \<lbrace>X,Y\<rbrace> \<in> analz H; | 
| 43197 | 334 | [| X \<in> analz H; Y \<in> analz H |] ==> P | 
| 23449 | 335 | |] ==> P" | 
| 336 | by (blast dest: analz.Fst analz.Snd) | |
| 337 | ||
| 338 | lemma analz_increasing: "H \<subseteq> analz(H)" | |
| 339 | by blast | |
| 340 | ||
| 341 | lemma analz_subset_parts: "analz H \<subseteq> parts H" | |
| 342 | apply (rule subsetI) | |
| 343 | apply (erule analz.induct, blast+) | |
| 344 | done | |
| 345 | ||
| 45605 | 346 | lemmas analz_into_parts = analz_subset_parts [THEN subsetD] | 
| 23449 | 347 | |
| 45605 | 348 | lemmas not_parts_not_analz = analz_subset_parts [THEN contra_subsetD] | 
| 23449 | 349 | |
| 350 | lemma parts_analz [simp]: "parts (analz H) = parts H" | |
| 351 | apply (rule equalityI) | |
| 352 | apply (metis analz_subset_parts parts_subset_iff) | |
| 353 | apply (metis analz_increasing parts_mono) | |
| 354 | done | |
| 355 | ||
| 356 | ||
| 357 | lemma analz_parts [simp]: "analz (parts H) = parts H" | |
| 358 | apply auto | |
| 359 | apply (erule analz.induct, auto) | |
| 360 | done | |
| 361 | ||
| 45605 | 362 | lemmas analz_insertI = subset_insertI [THEN analz_mono, THEN [2] rev_subsetD] | 
| 23449 | 363 | |
| 63167 | 364 | subsubsection\<open>General equational properties\<close> | 
| 23449 | 365 | |
| 366 | lemma analz_empty [simp]: "analz{} = {}"
 | |
| 367 | apply safe | |
| 368 | apply (erule analz.induct, blast+) | |
| 369 | done | |
| 370 | ||
| 63167 | 371 | text\<open>Converse fails: we can analz more from the union than from the | 
| 372 | separate parts, as a key in one might decrypt a message in the other\<close> | |
| 23449 | 373 | lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)" | 
| 374 | by (intro Un_least analz_mono Un_upper1 Un_upper2) | |
| 375 | ||
| 376 | lemma analz_insert: "insert X (analz H) \<subseteq> analz(insert X H)" | |
| 377 | by (blast intro: analz_mono [THEN [2] rev_subsetD]) | |
| 378 | ||
| 63167 | 379 | subsubsection\<open>Rewrite rules for pulling out atomic messages\<close> | 
| 23449 | 380 | |
| 381 | lemmas analz_insert_eq_I = equalityI [OF subsetI analz_insert] | |
| 382 | ||
| 383 | lemma analz_insert_Agent [simp]: | |
| 384 | "analz (insert (Agent agt) H) = insert (Agent agt) (analz H)" | |
| 43197 | 385 | apply (rule analz_insert_eq_I) | 
| 386 | apply (erule analz.induct, auto) | |
| 23449 | 387 | done | 
| 388 | ||
| 389 | lemma analz_insert_Nonce [simp]: | |
| 390 | "analz (insert (Nonce N) H) = insert (Nonce N) (analz H)" | |
| 43197 | 391 | apply (rule analz_insert_eq_I) | 
| 392 | apply (erule analz.induct, auto) | |
| 23449 | 393 | done | 
| 394 | ||
| 395 | lemma analz_insert_Number [simp]: | |
| 396 | "analz (insert (Number N) H) = insert (Number N) (analz H)" | |
| 43197 | 397 | apply (rule analz_insert_eq_I) | 
| 398 | apply (erule analz.induct, auto) | |
| 23449 | 399 | done | 
| 400 | ||
| 401 | lemma analz_insert_Hash [simp]: | |
| 402 | "analz (insert (Hash X) H) = insert (Hash X) (analz H)" | |
| 43197 | 403 | apply (rule analz_insert_eq_I) | 
| 404 | apply (erule analz.induct, auto) | |
| 23449 | 405 | done | 
| 406 | ||
| 63167 | 407 | text\<open>Can only pull out Keys if they are not needed to decrypt the rest\<close> | 
| 43197 | 408 | lemma analz_insert_Key [simp]: | 
| 409 | "K \<notin> keysFor (analz H) ==> | |
| 23449 | 410 | analz (insert (Key K) H) = insert (Key K) (analz H)" | 
| 411 | apply (unfold keysFor_def) | |
| 43197 | 412 | apply (rule analz_insert_eq_I) | 
| 413 | apply (erule analz.induct, auto) | |
| 23449 | 414 | done | 
| 415 | ||
| 416 | lemma analz_insert_MPair [simp]: | |
| 61984 | 417 | "analz (insert \<lbrace>X,Y\<rbrace> H) = | 
| 418 | insert \<lbrace>X,Y\<rbrace> (analz (insert X (insert Y H)))" | |
| 23449 | 419 | apply (rule equalityI) | 
| 420 | apply (rule subsetI) | |
| 421 | apply (erule analz.induct, auto) | |
| 422 | apply (erule analz.induct) | |
| 423 | apply (blast intro: analz.Fst analz.Snd)+ | |
| 424 | done | |
| 425 | ||
| 63167 | 426 | text\<open>Can pull out enCrypted message if the Key is not known\<close> | 
| 23449 | 427 | lemma analz_insert_Crypt: | 
| 43197 | 428 | "Key (invKey K) \<notin> analz H | 
| 23449 | 429 | ==> analz (insert (Crypt K X) H) = insert (Crypt K X) (analz H)" | 
| 43197 | 430 | apply (rule analz_insert_eq_I) | 
| 431 | apply (erule analz.induct, auto) | |
| 23449 | 432 | |
| 433 | done | |
| 434 | ||
| 43197 | 435 | lemma lemma1: "Key (invKey K) \<in> analz H ==> | 
| 436 | analz (insert (Crypt K X) H) \<subseteq> | |
| 437 | insert (Crypt K X) (analz (insert X H))" | |
| 23449 | 438 | apply (rule subsetI) | 
| 23755 | 439 | apply (erule_tac x = x in analz.induct, auto) | 
| 23449 | 440 | done | 
| 441 | ||
| 43197 | 442 | lemma lemma2: "Key (invKey K) \<in> analz H ==> | 
| 443 | insert (Crypt K X) (analz (insert X H)) \<subseteq> | |
| 23449 | 444 | analz (insert (Crypt K X) H)" | 
| 445 | apply auto | |
| 23755 | 446 | apply (erule_tac x = x in analz.induct, auto) | 
| 23449 | 447 | apply (blast intro: analz_insertI analz.Decrypt) | 
| 448 | done | |
| 449 | ||
| 450 | lemma analz_insert_Decrypt: | |
| 43197 | 451 | "Key (invKey K) \<in> analz H ==> | 
| 452 | analz (insert (Crypt K X) H) = | |
| 23449 | 453 | insert (Crypt K X) (analz (insert X H))" | 
| 454 | by (intro equalityI lemma1 lemma2) | |
| 455 | ||
| 63167 | 456 | text\<open>Case analysis: either the message is secure, or it is not! Effective, | 
| 457 | but can cause subgoals to blow up! Use with \<open>if_split\<close>; apparently | |
| 69597 | 458 | \<open>split_tac\<close> does not cope with patterns such as \<^term>\<open>analz (insert | 
| 459 | (Crypt K X) H)\<close>\<close> | |
| 23449 | 460 | lemma analz_Crypt_if [simp]: | 
| 43197 | 461 | "analz (insert (Crypt K X) H) = | 
| 462 | (if (Key (invKey K) \<in> analz H) | |
| 463 | then insert (Crypt K X) (analz (insert X H)) | |
| 23449 | 464 | else insert (Crypt K X) (analz H))" | 
| 465 | by (simp add: analz_insert_Crypt analz_insert_Decrypt) | |
| 466 | ||
| 467 | ||
| 63167 | 468 | text\<open>This rule supposes "for the sake of argument" that we have the key.\<close> | 
| 23449 | 469 | lemma analz_insert_Crypt_subset: | 
| 43197 | 470 | "analz (insert (Crypt K X) H) \<subseteq> | 
| 23449 | 471 | insert (Crypt K X) (analz (insert X H))" | 
| 472 | apply (rule subsetI) | |
| 473 | apply (erule analz.induct, auto) | |
| 474 | done | |
| 475 | ||
| 476 | ||
| 477 | lemma analz_image_Key [simp]: "analz (Key`N) = Key`N" | |
| 478 | apply auto | |
| 479 | apply (erule analz.induct, auto) | |
| 480 | done | |
| 481 | ||
| 482 | ||
| 63167 | 483 | subsubsection\<open>Idempotence and transitivity\<close> | 
| 23449 | 484 | |
| 485 | lemma analz_analzD [dest!]: "X\<in> analz (analz H) ==> X\<in> analz H" | |
| 486 | by (erule analz.induct, blast+) | |
| 487 | ||
| 488 | lemma analz_idem [simp]: "analz (analz H) = analz H" | |
| 489 | by blast | |
| 490 | ||
| 491 | lemma analz_subset_iff [simp]: "(analz G \<subseteq> analz H) = (G \<subseteq> analz H)" | |
| 492 | apply (rule iffI) | |
| 43197 | 493 | apply (iprover intro: subset_trans analz_increasing) | 
| 494 | apply (frule analz_mono, simp) | |
| 23449 | 495 | done | 
| 496 | ||
| 497 | lemma analz_trans: "[| X\<in> analz G; G \<subseteq> analz H |] ==> X\<in> analz H" | |
| 498 | by (drule analz_mono, blast) | |
| 499 | ||
| 500 | ||
| 36553 | 501 | declare analz_trans[intro] | 
| 502 | ||
| 23449 | 503 | lemma analz_cut: "[| Y\<in> analz (insert X H); X\<in> analz H |] ==> Y\<in> analz H" | 
| 46075 
0054a9513b37
reintroduced "metis" call taken out after reintroducing "set" as a constructor, and added two "metis" calls that used to be too slow
 blanchet parents: 
45970diff
changeset | 504 | by (metis analz_idem analz_increasing analz_mono insert_absorb insert_mono insert_subset) | 
| 23449 | 505 | |
| 63167 | 506 | text\<open>This rewrite rule helps in the simplification of messages that involve | 
| 23449 | 507 | the forwarding of unknown components (X). Without it, removing occurrences | 
| 63167 | 508 | of X can be very complicated.\<close> | 
| 23449 | 509 | lemma analz_insert_eq: "X\<in> analz H ==> analz (insert X H) = analz H" | 
| 510 | by (blast intro: analz_cut analz_insertI) | |
| 511 | ||
| 512 | ||
| 63167 | 513 | text\<open>A congruence rule for "analz"\<close> | 
| 23449 | 514 | |
| 515 | lemma analz_subset_cong: | |
| 43197 | 516 | "[| analz G \<subseteq> analz G'; analz H \<subseteq> analz H' |] | 
| 23449 | 517 | ==> analz (G \<union> H) \<subseteq> analz (G' \<union> H')" | 
| 518 | apply simp | |
| 519 | apply (metis Un_absorb2 Un_commute Un_subset_iff Un_upper1 Un_upper2 analz_mono) | |
| 520 | done | |
| 521 | ||
| 522 | ||
| 523 | lemma analz_cong: | |
| 43197 | 524 | "[| analz G = analz G'; analz H = analz H' | 
| 23449 | 525 | |] ==> analz (G \<union> H) = analz (G' \<union> H')" | 
| 43197 | 526 | by (intro equalityI analz_subset_cong, simp_all) | 
| 23449 | 527 | |
| 528 | lemma analz_insert_cong: | |
| 529 | "analz H = analz H' ==> analz(insert X H) = analz(insert X H')" | |
| 530 | by (force simp only: insert_def intro!: analz_cong) | |
| 531 | ||
| 63167 | 532 | text\<open>If there are no pairs or encryptions then analz does nothing\<close> | 
| 23449 | 533 | lemma analz_trivial: | 
| 61984 | 534 | "[| \<forall>X Y. \<lbrace>X,Y\<rbrace> \<notin> H; \<forall>X K. Crypt K X \<notin> H |] ==> analz H = H" | 
| 23449 | 535 | apply safe | 
| 536 | apply (erule analz.induct, blast+) | |
| 537 | done | |
| 538 | ||
| 539 | ||
| 63167 | 540 | subsection\<open>Inductive relation "synth"\<close> | 
| 23449 | 541 | |
| 63167 | 542 | text\<open>Inductive definition of "synth" -- what can be built up from a set of | 
| 23449 | 543 | messages. A form of upward closure. Pairs can be built, messages | 
| 544 | encrypted with known keys. Agent names are public domain. | |
| 63167 | 545 | Numbers can be guessed, but Nonces cannot be.\<close> | 
| 23449 | 546 | |
| 23755 | 547 | inductive_set | 
| 548 | synth :: "msg set => msg set" | |
| 549 | for H :: "msg set" | |
| 550 | where | |
| 23449 | 551 | Inj [intro]: "X \<in> H ==> X \<in> synth H" | 
| 23755 | 552 | | Agent [intro]: "Agent agt \<in> synth H" | 
| 553 | | Number [intro]: "Number n \<in> synth H" | |
| 554 | | Hash [intro]: "X \<in> synth H ==> Hash X \<in> synth H" | |
| 61984 | 555 | | MPair [intro]: "[|X \<in> synth H; Y \<in> synth H|] ==> \<lbrace>X,Y\<rbrace> \<in> synth H" | 
| 23755 | 556 | | Crypt [intro]: "[|X \<in> synth H; Key(K) \<in> H|] ==> Crypt K X \<in> synth H" | 
| 23449 | 557 | |
| 63167 | 558 | text\<open>Monotonicity\<close> | 
| 23449 | 559 | lemma synth_mono: "G\<subseteq>H ==> synth(G) \<subseteq> synth(H)" | 
| 43197 | 560 | by (auto, erule synth.induct, auto) | 
| 23449 | 561 | |
| 63167 | 562 | text\<open>NO \<open>Agent_synth\<close>, as any Agent name can be synthesized. | 
| 69597 | 563 | The same holds for \<^term>\<open>Number\<close>\<close> | 
| 23449 | 564 | inductive_cases Nonce_synth [elim!]: "Nonce n \<in> synth H" | 
| 565 | inductive_cases Key_synth [elim!]: "Key K \<in> synth H" | |
| 566 | inductive_cases Hash_synth [elim!]: "Hash X \<in> synth H" | |
| 61984 | 567 | inductive_cases MPair_synth [elim!]: "\<lbrace>X,Y\<rbrace> \<in> synth H" | 
| 23449 | 568 | inductive_cases Crypt_synth [elim!]: "Crypt K X \<in> synth H" | 
| 569 | ||
| 570 | ||
| 571 | lemma synth_increasing: "H \<subseteq> synth(H)" | |
| 572 | by blast | |
| 573 | ||
| 63167 | 574 | subsubsection\<open>Unions\<close> | 
| 23449 | 575 | |
| 63167 | 576 | text\<open>Converse fails: we can synth more from the union than from the | 
| 577 | separate parts, building a compound message using elements of each.\<close> | |
| 23449 | 578 | lemma synth_Un: "synth(G) \<union> synth(H) \<subseteq> synth(G \<union> H)" | 
| 579 | by (intro Un_least synth_mono Un_upper1 Un_upper2) | |
| 580 | ||
| 581 | lemma synth_insert: "insert X (synth H) \<subseteq> synth(insert X H)" | |
| 582 | by (metis insert_iff insert_subset subset_insertI synth.Inj synth_mono) | |
| 583 | ||
| 63167 | 584 | subsubsection\<open>Idempotence and transitivity\<close> | 
| 23449 | 585 | |
| 586 | lemma synth_synthD [dest!]: "X\<in> synth (synth H) ==> X\<in> synth H" | |
| 587 | by (erule synth.induct, blast+) | |
| 588 | ||
| 589 | lemma synth_idem: "synth (synth H) = synth H" | |
| 590 | by blast | |
| 591 | ||
| 592 | lemma synth_subset_iff [simp]: "(synth G \<subseteq> synth H) = (G \<subseteq> synth H)" | |
| 593 | apply (rule iffI) | |
| 43197 | 594 | apply (iprover intro: subset_trans synth_increasing) | 
| 595 | apply (frule synth_mono, simp add: synth_idem) | |
| 23449 | 596 | done | 
| 597 | ||
| 598 | lemma synth_trans: "[| X\<in> synth G; G \<subseteq> synth H |] ==> X\<in> synth H" | |
| 599 | by (drule synth_mono, blast) | |
| 600 | ||
| 601 | lemma synth_cut: "[| Y\<in> synth (insert X H); X\<in> synth H |] ==> Y\<in> synth H" | |
| 602 | by (metis insert_absorb insert_mono insert_subset synth_idem synth_increasing synth_mono) | |
| 603 | ||
| 604 | lemma Agent_synth [simp]: "Agent A \<in> synth H" | |
| 605 | by blast | |
| 606 | ||
| 607 | lemma Number_synth [simp]: "Number n \<in> synth H" | |
| 608 | by blast | |
| 609 | ||
| 610 | lemma Nonce_synth_eq [simp]: "(Nonce N \<in> synth H) = (Nonce N \<in> H)" | |
| 611 | by blast | |
| 612 | ||
| 613 | lemma Key_synth_eq [simp]: "(Key K \<in> synth H) = (Key K \<in> H)" | |
| 614 | by blast | |
| 615 | ||
| 616 | lemma Crypt_synth_eq [simp]: | |
| 617 | "Key K \<notin> H ==> (Crypt K X \<in> synth H) = (Crypt K X \<in> H)" | |
| 618 | by blast | |
| 619 | ||
| 620 | ||
| 43197 | 621 | lemma keysFor_synth [simp]: | 
| 23449 | 622 |     "keysFor (synth H) = keysFor H \<union> invKey`{K. Key K \<in> H}"
 | 
| 623 | by (unfold keysFor_def, blast) | |
| 624 | ||
| 625 | ||
| 63167 | 626 | subsubsection\<open>Combinations of parts, analz and synth\<close> | 
| 23449 | 627 | |
| 628 | lemma parts_synth [simp]: "parts (synth H) = parts H \<union> synth H" | |
| 629 | apply (rule equalityI) | |
| 630 | apply (rule subsetI) | |
| 631 | apply (erule parts.induct) | |
| 632 | apply (metis UnCI) | |
| 633 | apply (metis MPair_synth UnCI UnE insert_absorb insert_subset parts.Fst parts_increasing) | |
| 634 | apply (metis MPair_synth UnCI UnE insert_absorb insert_subset parts.Snd parts_increasing) | |
| 635 | apply (metis Body Crypt_synth UnCI UnE insert_absorb insert_subset parts_increasing) | |
| 636 | apply (metis Un_subset_iff parts_increasing parts_mono synth_increasing) | |
| 637 | done | |
| 638 | ||
| 639 | lemma analz_analz_Un [simp]: "analz (analz G \<union> H) = analz (G \<union> H)" | |
| 45503 | 640 | apply (rule equalityI) | 
| 23449 | 641 | apply (metis analz_idem analz_subset_cong order_eq_refl) | 
| 642 | apply (metis analz_increasing analz_subset_cong order_eq_refl) | |
| 643 | done | |
| 644 | ||
| 36553 | 645 | declare analz_mono [intro] analz.Fst [intro] analz.Snd [intro] Un_least [intro] | 
| 646 | ||
| 23449 | 647 | lemma analz_synth_Un [simp]: "analz (synth G \<union> H) = analz (G \<union> H) \<union> synth G" | 
| 648 | apply (rule equalityI) | |
| 649 | apply (rule subsetI) | |
| 650 | apply (erule analz.induct) | |
| 651 | apply (metis UnCI UnE Un_commute analz.Inj) | |
| 45970 
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
 haftmann parents: 
45605diff
changeset | 652 | apply (metis MPair_synth UnCI UnE Un_commute analz.Fst analz.Inj) | 
| 
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
 haftmann parents: 
45605diff
changeset | 653 | apply (metis MPair_synth UnCI UnE Un_commute analz.Inj analz.Snd) | 
| 23449 | 654 | apply (blast intro: analz.Decrypt) | 
| 24759 | 655 | apply blast | 
| 23449 | 656 | done | 
| 657 | ||
| 658 | lemma analz_synth [simp]: "analz (synth H) = analz H \<union> synth H" | |
| 36553 | 659 | proof - | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 660 | have "\<forall>x\<^sub>2 x\<^sub>1. synth x\<^sub>1 \<union> analz (x\<^sub>1 \<union> x\<^sub>2) = analz (synth x\<^sub>1 \<union> x\<^sub>2)" by (metis Un_commute analz_synth_Un) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 661 |   hence "\<forall>x\<^sub>1. synth x\<^sub>1 \<union> analz x\<^sub>1 = analz (synth x\<^sub>1 \<union> {})" by (metis Un_empty_right)
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 662 | hence "\<forall>x\<^sub>1. synth x\<^sub>1 \<union> analz x\<^sub>1 = analz (synth x\<^sub>1)" by (metis Un_empty_right) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 663 | hence "\<forall>x\<^sub>1. analz x\<^sub>1 \<union> synth x\<^sub>1 = analz (synth x\<^sub>1)" by (metis Un_commute) | 
| 36553 | 664 | thus "analz (synth H) = analz H \<union> synth H" by metis | 
| 23449 | 665 | qed | 
| 666 | ||
| 667 | ||
| 63167 | 668 | subsubsection\<open>For reasoning about the Fake rule in traces\<close> | 
| 23449 | 669 | |
| 45970 
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
 haftmann parents: 
45605diff
changeset | 670 | lemma parts_insert_subset_Un: "X \<in> G ==> parts(insert X H) \<subseteq> parts G \<union> parts H" | 
| 36553 | 671 | proof - | 
| 672 | assume "X \<in> G" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 673 | hence "\<forall>x\<^sub>1. G \<subseteq> x\<^sub>1 \<longrightarrow> X \<in> x\<^sub>1 " by auto | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 674 | hence "\<forall>x\<^sub>1. X \<in> G \<union> x\<^sub>1" by (metis Un_upper1) | 
| 36911 | 675 | hence "insert X H \<subseteq> G \<union> H" by (metis Un_upper2 insert_subset) | 
| 676 | hence "parts (insert X H) \<subseteq> parts (G \<union> H)" by (metis parts_mono) | |
| 677 | thus "parts (insert X H) \<subseteq> parts G \<union> parts H" by (metis parts_Un) | |
| 23449 | 678 | qed | 
| 679 | ||
| 680 | lemma Fake_parts_insert: | |
| 43197 | 681 | "X \<in> synth (analz H) ==> | 
| 23449 | 682 | parts (insert X H) \<subseteq> synth (analz H) \<union> parts H" | 
| 36553 | 683 | proof - | 
| 684 | assume A1: "X \<in> synth (analz H)" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 685 | have F1: "\<forall>x\<^sub>1. analz x\<^sub>1 \<union> synth (analz x\<^sub>1) = analz (synth (analz x\<^sub>1))" | 
| 36553 | 686 | by (metis analz_idem analz_synth) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 687 | have F2: "\<forall>x\<^sub>1. parts x\<^sub>1 \<union> synth (analz x\<^sub>1) = parts (synth (analz x\<^sub>1))" | 
| 36553 | 688 | by (metis parts_analz parts_synth) | 
| 45970 
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
 haftmann parents: 
45605diff
changeset | 689 | have F3: "X \<in> synth (analz H)" using A1 by metis | 
| 61076 | 690 | have "\<forall>x\<^sub>2 x\<^sub>1::msg set. x\<^sub>1 \<le> sup x\<^sub>1 x\<^sub>2" by (metis inf_sup_ord(3)) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 691 | hence F4: "\<forall>x\<^sub>1. analz x\<^sub>1 \<subseteq> analz (synth x\<^sub>1)" by (metis analz_synth) | 
| 45970 
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
 haftmann parents: 
45605diff
changeset | 692 | have F5: "X \<in> synth (analz H)" using F3 by metis | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 693 | have "\<forall>x\<^sub>1. analz x\<^sub>1 \<subseteq> synth (analz x\<^sub>1) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 694 | \<longrightarrow> analz (synth (analz x\<^sub>1)) = synth (analz x\<^sub>1)" | 
| 36553 | 695 | using F1 by (metis subset_Un_eq) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 696 | hence F6: "\<forall>x\<^sub>1. analz (synth (analz x\<^sub>1)) = synth (analz x\<^sub>1)" | 
| 36553 | 697 | by (metis synth_increasing) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 698 | have "\<forall>x\<^sub>1. x\<^sub>1 \<subseteq> analz (synth x\<^sub>1)" using F4 by (metis analz_subset_iff) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 699 | hence "\<forall>x\<^sub>1. x\<^sub>1 \<subseteq> analz (synth (analz x\<^sub>1))" by (metis analz_subset_iff) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50705diff
changeset | 700 | hence "\<forall>x\<^sub>1. x\<^sub>1 \<subseteq> synth (analz x\<^sub>1)" using F6 by metis | 
| 36553 | 701 | hence "H \<subseteq> synth (analz H)" by metis | 
| 702 | hence "H \<subseteq> synth (analz H) \<and> X \<in> synth (analz H)" using F5 by metis | |
| 703 | hence "insert X H \<subseteq> synth (analz H)" by (metis insert_subset) | |
| 704 | hence "parts (insert X H) \<subseteq> parts (synth (analz H))" by (metis parts_mono) | |
| 705 | hence "parts (insert X H) \<subseteq> parts H \<union> synth (analz H)" using F2 by metis | |
| 706 | thus "parts (insert X H) \<subseteq> synth (analz H) \<union> parts H" by (metis Un_commute) | |
| 23449 | 707 | qed | 
| 708 | ||
| 709 | lemma Fake_parts_insert_in_Un: | |
| 67613 | 710 | "[|Z \<in> parts (insert X H); X \<in> synth (analz H)|] | 
| 45505 | 711 | ==> Z \<in> synth (analz H) \<union> parts H" | 
| 36553 | 712 | by (blast dest: Fake_parts_insert [THEN subsetD, dest]) | 
| 23449 | 713 | |
| 45970 
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
 haftmann parents: 
45605diff
changeset | 714 | declare synth_mono [intro] | 
| 36553 | 715 | |
| 23449 | 716 | lemma Fake_analz_insert: | 
| 36553 | 717 | "X \<in> synth (analz G) ==> | 
| 23449 | 718 | analz (insert X H) \<subseteq> synth (analz G) \<union> analz (G \<union> H)" | 
| 36553 | 719 | by (metis Un_commute Un_insert_left Un_insert_right Un_upper1 analz_analz_Un | 
| 720 | analz_mono analz_synth_Un insert_absorb) | |
| 23449 | 721 | |
| 722 | lemma Fake_analz_insert_simpler: | |
| 43197 | 723 | "X \<in> synth (analz G) ==> | 
| 23449 | 724 | analz (insert X H) \<subseteq> synth (analz G) \<union> analz (G \<union> H)" | 
| 725 | apply (rule subsetI) | |
| 726 | apply (subgoal_tac "x \<in> analz (synth (analz G) \<union> H) ") | |
| 727 | apply (metis Un_commute analz_analz_Un analz_synth_Un) | |
| 39260 | 728 | by (metis Un_upper1 Un_upper2 analz_mono insert_absorb insert_subset) | 
| 23449 | 729 | |
| 730 | end |