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