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