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