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