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