src/HOL/Auth/Message.ML
author paulson
Mon Dec 16 10:41:26 1996 +0100 (1996-12-16)
changeset 2415 46de4b035f00
parent 2373 490ffa16952e
child 2484 596a5b5a68ff
permissions -rw-r--r--
New tactic: prove_unique_tac
paulson@1839
     1
(*  Title:      HOL/Auth/Message
paulson@1839
     2
    ID:         $Id$
paulson@1839
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1839
     4
    Copyright   1996  University of Cambridge
paulson@1839
     5
paulson@1839
     6
Datatypes of agents and messages;
paulson@1913
     7
Inductive relations "parts", "analz" and "synth"
paulson@1839
     8
*)
paulson@1839
     9
paulson@2327
    10
val prems = goal HOL.thy "[| P ==> Q(True); ~P ==> Q(False) |] ==> Q(P)";
paulson@2327
    11
by (case_tac "P" 1);
paulson@2327
    12
by (ALLGOALS (asm_simp_tac (!simpset addsimps prems)));
paulson@2327
    13
val expand_case = result();
paulson@2327
    14
paulson@2327
    15
fun expand_case_tac P i =
paulson@2327
    16
    res_inst_tac [("P",P)] expand_case i THEN
paulson@2327
    17
    Simp_tac (i+1) THEN 
paulson@2327
    18
    Simp_tac i;
paulson@2327
    19
paulson@2327
    20
paulson@2327
    21
paulson@2327
    22
(*GOALS.ML??*)
paulson@2327
    23
fun prlim n = (goals_limit:=n; pr());
paulson@2327
    24
paulson@2327
    25
(*FUN.ML??  WE NEED A NOTION OF INVERSE IMAGE, OR GRAPH!!*)
paulson@2327
    26
goal Set.thy "!!f. B <= range f = (B = f`` {x. f x: B})";
paulson@2327
    27
by (fast_tac (!claset addEs [equalityE]) 1);
paulson@2327
    28
val subset_range_iff = result();
paulson@2327
    29
paulson@2327
    30
paulson@1839
    31
open Message;
paulson@1839
    32
paulson@2373
    33
AddIffs (msg.inject);
paulson@1839
    34
paulson@1839
    35
(** Inverse of keys **)
paulson@1839
    36
paulson@1839
    37
goal thy "!!K K'. (invKey K = invKey K') = (K=K')";
paulson@1839
    38
by (Step_tac 1);
paulson@2032
    39
by (rtac box_equals 1);
paulson@1839
    40
by (REPEAT (rtac invKey 2));
paulson@1839
    41
by (Asm_simp_tac 1);
paulson@1839
    42
qed "invKey_eq";
paulson@1839
    43
paulson@1839
    44
Addsimps [invKey, invKey_eq];
paulson@1839
    45
paulson@1839
    46
paulson@1839
    47
(**** keysFor operator ****)
paulson@1839
    48
paulson@1839
    49
goalw thy [keysFor_def] "keysFor {} = {}";
paulson@1839
    50
by (Fast_tac 1);
paulson@1839
    51
qed "keysFor_empty";
paulson@1839
    52
paulson@1839
    53
goalw thy [keysFor_def] "keysFor (H Un H') = keysFor H Un keysFor H'";
paulson@1839
    54
by (Fast_tac 1);
paulson@1839
    55
qed "keysFor_Un";
paulson@1839
    56
paulson@1839
    57
goalw thy [keysFor_def] "keysFor (UN i. H i) = (UN i. keysFor (H i))";
paulson@1839
    58
by (Fast_tac 1);
paulson@1839
    59
qed "keysFor_UN";
paulson@1839
    60
paulson@1839
    61
(*Monotonicity*)
paulson@1839
    62
goalw thy [keysFor_def] "!!G H. G<=H ==> keysFor(G) <= keysFor(H)";
paulson@1839
    63
by (Fast_tac 1);
paulson@1839
    64
qed "keysFor_mono";
paulson@1839
    65
paulson@1839
    66
goalw thy [keysFor_def] "keysFor (insert (Agent A) H) = keysFor H";
paulson@1839
    67
by (fast_tac (!claset addss (!simpset)) 1);
paulson@1839
    68
qed "keysFor_insert_Agent";
paulson@1839
    69
paulson@1839
    70
goalw thy [keysFor_def] "keysFor (insert (Nonce N) H) = keysFor H";
paulson@1839
    71
by (fast_tac (!claset addss (!simpset)) 1);
paulson@1839
    72
qed "keysFor_insert_Nonce";
paulson@1839
    73
paulson@1839
    74
goalw thy [keysFor_def] "keysFor (insert (Key K) H) = keysFor H";
paulson@1839
    75
by (fast_tac (!claset addss (!simpset)) 1);
paulson@1839
    76
qed "keysFor_insert_Key";
paulson@1839
    77
paulson@2373
    78
goalw thy [keysFor_def] "keysFor (insert (Hash X) H) = keysFor H";
paulson@2373
    79
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2373
    80
qed "keysFor_insert_Hash";
paulson@2373
    81
paulson@1839
    82
goalw thy [keysFor_def] "keysFor (insert {|X,Y|} H) = keysFor H";
paulson@1839
    83
by (fast_tac (!claset addss (!simpset)) 1);
paulson@1839
    84
qed "keysFor_insert_MPair";
paulson@1839
    85
paulson@1839
    86
goalw thy [keysFor_def]
paulson@2284
    87
    "keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)";
paulson@1839
    88
by (Auto_tac());
paulson@1839
    89
qed "keysFor_insert_Crypt";
paulson@1839
    90
paulson@1839
    91
Addsimps [keysFor_empty, keysFor_Un, keysFor_UN, 
paulson@2373
    92
          keysFor_insert_Agent, keysFor_insert_Nonce, keysFor_insert_Key, 
paulson@2373
    93
	  keysFor_insert_Hash, keysFor_insert_MPair, keysFor_insert_Crypt];
paulson@1839
    94
paulson@2284
    95
goalw thy [keysFor_def] "!!H. Crypt K X : H ==> invKey K : keysFor H";
paulson@2068
    96
by (Fast_tac 1);
paulson@2068
    97
qed "Crypt_imp_invKey_keysFor";
paulson@2068
    98
paulson@1839
    99
paulson@1839
   100
(**** Inductive relation "parts" ****)
paulson@1839
   101
paulson@1839
   102
val major::prems = 
paulson@1839
   103
goal thy "[| {|X,Y|} : parts H;       \
paulson@1839
   104
\            [| X : parts H; Y : parts H |] ==> P  \
paulson@1839
   105
\         |] ==> P";
paulson@1839
   106
by (cut_facts_tac [major] 1);
paulson@2032
   107
by (resolve_tac prems 1);
paulson@1839
   108
by (REPEAT (eresolve_tac [asm_rl, parts.Fst, parts.Snd] 1));
paulson@1839
   109
qed "MPair_parts";
paulson@1839
   110
paulson@1839
   111
AddIs  [parts.Inj];
paulson@1929
   112
paulson@1929
   113
val partsEs = [MPair_parts, make_elim parts.Body];
paulson@1929
   114
paulson@1929
   115
AddSEs partsEs;
paulson@1929
   116
(*NB These two rules are UNSAFE in the formal sense, as they discard the
paulson@1929
   117
     compound message.  They work well on THIS FILE, perhaps because its
paulson@1929
   118
     proofs concern only atomic messages.*)
paulson@1839
   119
paulson@1839
   120
goal thy "H <= parts(H)";
paulson@1839
   121
by (Fast_tac 1);
paulson@1839
   122
qed "parts_increasing";
paulson@1839
   123
paulson@1839
   124
(*Monotonicity*)
paulson@1839
   125
goalw thy parts.defs "!!G H. G<=H ==> parts(G) <= parts(H)";
paulson@1839
   126
by (rtac lfp_mono 1);
paulson@1839
   127
by (REPEAT (ares_tac basic_monos 1));
paulson@1839
   128
qed "parts_mono";
paulson@1839
   129
paulson@2373
   130
val parts_insertI = impOfSubs (subset_insertI RS parts_mono);
paulson@2373
   131
paulson@1839
   132
goal thy "parts{} = {}";
paulson@1839
   133
by (Step_tac 1);
paulson@2032
   134
by (etac parts.induct 1);
paulson@1839
   135
by (ALLGOALS Fast_tac);
paulson@1839
   136
qed "parts_empty";
paulson@1839
   137
Addsimps [parts_empty];
paulson@1839
   138
paulson@1839
   139
goal thy "!!X. X: parts{} ==> P";
paulson@1839
   140
by (Asm_full_simp_tac 1);
paulson@1839
   141
qed "parts_emptyE";
paulson@1839
   142
AddSEs [parts_emptyE];
paulson@1839
   143
paulson@1893
   144
(*WARNING: loops if H = {Y}, therefore must not be repeated!*)
paulson@1893
   145
goal thy "!!H. X: parts H ==> EX Y:H. X: parts {Y}";
paulson@2032
   146
by (etac parts.induct 1);
paulson@1893
   147
by (ALLGOALS Fast_tac);
paulson@1893
   148
qed "parts_singleton";
paulson@1893
   149
paulson@1839
   150
paulson@1839
   151
(** Unions **)
paulson@1839
   152
paulson@1839
   153
goal thy "parts(G) Un parts(H) <= parts(G Un H)";
paulson@1839
   154
by (REPEAT (ares_tac [Un_least, parts_mono, Un_upper1, Un_upper2] 1));
paulson@1839
   155
val parts_Un_subset1 = result();
paulson@1839
   156
paulson@1839
   157
goal thy "parts(G Un H) <= parts(G) Un parts(H)";
paulson@2032
   158
by (rtac subsetI 1);
paulson@2032
   159
by (etac parts.induct 1);
paulson@1839
   160
by (ALLGOALS Fast_tac);
paulson@1839
   161
val parts_Un_subset2 = result();
paulson@1839
   162
paulson@1839
   163
goal thy "parts(G Un H) = parts(G) Un parts(H)";
paulson@1839
   164
by (REPEAT (ares_tac [equalityI, parts_Un_subset1, parts_Un_subset2] 1));
paulson@1839
   165
qed "parts_Un";
paulson@1839
   166
paulson@2011
   167
goal thy "parts (insert X H) = parts {X} Un parts H";
paulson@1852
   168
by (stac (read_instantiate [("A","H")] insert_is_Un) 1);
paulson@2011
   169
by (simp_tac (HOL_ss addsimps [parts_Un]) 1);
paulson@2011
   170
qed "parts_insert";
paulson@2011
   171
paulson@2011
   172
(*TWO inserts to avoid looping.  This rewrite is better than nothing.
paulson@2011
   173
  Not suitable for Addsimps: its behaviour can be strange.*)
paulson@2011
   174
goal thy "parts (insert X (insert Y H)) = parts {X} Un parts {Y} Un parts H";
paulson@2011
   175
by (simp_tac (!simpset addsimps [Un_assoc]) 1);
paulson@2011
   176
by (simp_tac (!simpset addsimps [parts_insert RS sym]) 1);
paulson@1852
   177
qed "parts_insert2";
paulson@1852
   178
paulson@1839
   179
goal thy "(UN x:A. parts(H x)) <= parts(UN x:A. H x)";
paulson@1839
   180
by (REPEAT (ares_tac [UN_least, parts_mono, UN_upper] 1));
paulson@1839
   181
val parts_UN_subset1 = result();
paulson@1839
   182
paulson@1839
   183
goal thy "parts(UN x:A. H x) <= (UN x:A. parts(H x))";
paulson@2032
   184
by (rtac subsetI 1);
paulson@2032
   185
by (etac parts.induct 1);
paulson@1839
   186
by (ALLGOALS Fast_tac);
paulson@1839
   187
val parts_UN_subset2 = result();
paulson@1839
   188
paulson@1839
   189
goal thy "parts(UN x:A. H x) = (UN x:A. parts(H x))";
paulson@1839
   190
by (REPEAT (ares_tac [equalityI, parts_UN_subset1, parts_UN_subset2] 1));
paulson@1839
   191
qed "parts_UN";
paulson@1839
   192
paulson@1839
   193
goal thy "parts(UN x. H x) = (UN x. parts(H x))";
paulson@1839
   194
by (simp_tac (!simpset addsimps [UNION1_def, parts_UN]) 1);
paulson@1839
   195
qed "parts_UN1";
paulson@1839
   196
paulson@1913
   197
(*Added to simplify arguments to parts, analz and synth*)
paulson@1839
   198
Addsimps [parts_Un, parts_UN, parts_UN1];
paulson@1839
   199
paulson@1839
   200
goal thy "insert X (parts H) <= parts(insert X H)";
paulson@1852
   201
by (fast_tac (!claset addEs [impOfSubs parts_mono]) 1);
paulson@1839
   202
qed "parts_insert_subset";
paulson@1839
   203
paulson@1839
   204
(** Idempotence and transitivity **)
paulson@1839
   205
paulson@1839
   206
goal thy "!!H. X: parts (parts H) ==> X: parts H";
paulson@2032
   207
by (etac parts.induct 1);
paulson@1839
   208
by (ALLGOALS Fast_tac);
paulson@1839
   209
qed "parts_partsE";
paulson@1839
   210
AddSEs [parts_partsE];
paulson@1839
   211
paulson@1839
   212
goal thy "parts (parts H) = parts H";
paulson@1839
   213
by (Fast_tac 1);
paulson@1839
   214
qed "parts_idem";
paulson@1839
   215
Addsimps [parts_idem];
paulson@1839
   216
paulson@1839
   217
goal thy "!!H. [| X: parts G;  G <= parts H |] ==> X: parts H";
paulson@1839
   218
by (dtac parts_mono 1);
paulson@1839
   219
by (Fast_tac 1);
paulson@1839
   220
qed "parts_trans";
paulson@1839
   221
paulson@1839
   222
(*Cut*)
paulson@2373
   223
goal thy "!!H. [| Y: parts (insert X G);  X: parts H |] \
paulson@2373
   224
\              ==> Y: parts (G Un H)";
paulson@2032
   225
by (etac parts_trans 1);
paulson@2373
   226
by (Auto_tac());
paulson@1839
   227
qed "parts_cut";
paulson@1839
   228
paulson@1929
   229
goal thy "!!H. X: parts H ==> parts (insert X H) = parts H";
paulson@2373
   230
by (fast_tac (!claset addSDs [parts_cut]
paulson@2373
   231
                      addIs  [parts_insertI] 
paulson@2373
   232
                      addss (!simpset)) 1);
paulson@1929
   233
qed "parts_cut_eq";
paulson@1929
   234
paulson@2028
   235
Addsimps [parts_cut_eq];
paulson@2028
   236
paulson@1839
   237
paulson@1839
   238
(** Rewrite rules for pulling out atomic messages **)
paulson@1839
   239
paulson@2373
   240
fun parts_tac i =
paulson@2373
   241
  EVERY [rtac ([subsetI, parts_insert_subset] MRS equalityI) i,
paulson@2373
   242
	 etac parts.induct i,
paulson@2373
   243
	 REPEAT (fast_tac (!claset addss (!simpset)) i)];
paulson@2373
   244
paulson@1839
   245
goal thy "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)";
paulson@2373
   246
by (parts_tac 1);
paulson@1839
   247
qed "parts_insert_Agent";
paulson@1839
   248
paulson@1839
   249
goal thy "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)";
paulson@2373
   250
by (parts_tac 1);
paulson@1839
   251
qed "parts_insert_Nonce";
paulson@1839
   252
paulson@1839
   253
goal thy "parts (insert (Key K) H) = insert (Key K) (parts H)";
paulson@2373
   254
by (parts_tac 1);
paulson@1839
   255
qed "parts_insert_Key";
paulson@1839
   256
paulson@2373
   257
goal thy "parts (insert (Hash X) H) = insert (Hash X) (parts H)";
paulson@2373
   258
by (parts_tac 1);
paulson@2373
   259
qed "parts_insert_Hash";
paulson@2373
   260
paulson@2284
   261
goal thy "parts (insert (Crypt K X) H) = \
paulson@2284
   262
\         insert (Crypt K X) (parts (insert X H))";
paulson@2032
   263
by (rtac equalityI 1);
paulson@2032
   264
by (rtac subsetI 1);
paulson@2032
   265
by (etac parts.induct 1);
paulson@1839
   266
by (Auto_tac());
paulson@2032
   267
by (etac parts.induct 1);
paulson@1839
   268
by (ALLGOALS (best_tac (!claset addIs [parts.Body])));
paulson@1839
   269
qed "parts_insert_Crypt";
paulson@1839
   270
paulson@1839
   271
goal thy "parts (insert {|X,Y|} H) = \
paulson@1839
   272
\         insert {|X,Y|} (parts (insert X (insert Y H)))";
paulson@2032
   273
by (rtac equalityI 1);
paulson@2032
   274
by (rtac subsetI 1);
paulson@2032
   275
by (etac parts.induct 1);
paulson@1839
   276
by (Auto_tac());
paulson@2032
   277
by (etac parts.induct 1);
paulson@1839
   278
by (ALLGOALS (best_tac (!claset addIs [parts.Fst, parts.Snd])));
paulson@1839
   279
qed "parts_insert_MPair";
paulson@1839
   280
paulson@2373
   281
Addsimps [parts_insert_Agent, parts_insert_Nonce, parts_insert_Key, 
paulson@2373
   282
          parts_insert_Hash, parts_insert_Crypt, parts_insert_MPair];
paulson@1839
   283
paulson@1839
   284
paulson@2026
   285
goal thy "parts (Key``N) = Key``N";
paulson@2026
   286
by (Auto_tac());
paulson@2032
   287
by (etac parts.induct 1);
paulson@2026
   288
by (Auto_tac());
paulson@2026
   289
qed "parts_image_Key";
paulson@2026
   290
paulson@2026
   291
Addsimps [parts_image_Key];
paulson@2026
   292
paulson@2026
   293
paulson@1913
   294
(**** Inductive relation "analz" ****)
paulson@1839
   295
paulson@1839
   296
val major::prems = 
paulson@1913
   297
goal thy "[| {|X,Y|} : analz H;       \
paulson@1913
   298
\            [| X : analz H; Y : analz H |] ==> P  \
paulson@1839
   299
\         |] ==> P";
paulson@1839
   300
by (cut_facts_tac [major] 1);
paulson@2032
   301
by (resolve_tac prems 1);
paulson@1913
   302
by (REPEAT (eresolve_tac [asm_rl, analz.Fst, analz.Snd] 1));
paulson@1913
   303
qed "MPair_analz";
paulson@1839
   304
paulson@1913
   305
AddIs  [analz.Inj];
paulson@2011
   306
AddSEs [MPair_analz];      (*Perhaps it should NOT be deemed safe!*)
paulson@1913
   307
AddDs  [analz.Decrypt];
paulson@1839
   308
paulson@1913
   309
Addsimps [analz.Inj];
paulson@1885
   310
paulson@1913
   311
goal thy "H <= analz(H)";
paulson@1839
   312
by (Fast_tac 1);
paulson@1913
   313
qed "analz_increasing";
paulson@1839
   314
paulson@1913
   315
goal thy "analz H <= parts H";
paulson@1839
   316
by (rtac subsetI 1);
paulson@2032
   317
by (etac analz.induct 1);
paulson@1839
   318
by (ALLGOALS Fast_tac);
paulson@1913
   319
qed "analz_subset_parts";
paulson@1839
   320
paulson@1913
   321
bind_thm ("not_parts_not_analz", analz_subset_parts RS contra_subsetD);
paulson@1839
   322
paulson@1839
   323
paulson@1913
   324
goal thy "parts (analz H) = parts H";
paulson@2032
   325
by (rtac equalityI 1);
paulson@2032
   326
by (rtac (analz_subset_parts RS parts_mono RS subset_trans) 1);
paulson@1839
   327
by (Simp_tac 1);
paulson@1913
   328
by (fast_tac (!claset addDs [analz_increasing RS parts_mono RS subsetD]) 1);
paulson@1913
   329
qed "parts_analz";
paulson@1913
   330
Addsimps [parts_analz];
paulson@1839
   331
paulson@1913
   332
goal thy "analz (parts H) = parts H";
paulson@1885
   333
by (Auto_tac());
paulson@2032
   334
by (etac analz.induct 1);
paulson@1885
   335
by (Auto_tac());
paulson@1913
   336
qed "analz_parts";
paulson@1913
   337
Addsimps [analz_parts];
paulson@1885
   338
paulson@1839
   339
(*Monotonicity; Lemma 1 of Lowe*)
paulson@1913
   340
goalw thy analz.defs "!!G H. G<=H ==> analz(G) <= analz(H)";
paulson@1839
   341
by (rtac lfp_mono 1);
paulson@1839
   342
by (REPEAT (ares_tac basic_monos 1));
paulson@1913
   343
qed "analz_mono";
paulson@1839
   344
paulson@2373
   345
val analz_insertI = impOfSubs (subset_insertI RS analz_mono);
paulson@2373
   346
paulson@1839
   347
(** General equational properties **)
paulson@1839
   348
paulson@1913
   349
goal thy "analz{} = {}";
paulson@1839
   350
by (Step_tac 1);
paulson@2032
   351
by (etac analz.induct 1);
paulson@1839
   352
by (ALLGOALS Fast_tac);
paulson@1913
   353
qed "analz_empty";
paulson@1913
   354
Addsimps [analz_empty];
paulson@1839
   355
paulson@1913
   356
(*Converse fails: we can analz more from the union than from the 
paulson@1839
   357
  separate parts, as a key in one might decrypt a message in the other*)
paulson@1913
   358
goal thy "analz(G) Un analz(H) <= analz(G Un H)";
paulson@1913
   359
by (REPEAT (ares_tac [Un_least, analz_mono, Un_upper1, Un_upper2] 1));
paulson@1913
   360
qed "analz_Un";
paulson@1839
   361
paulson@1913
   362
goal thy "insert X (analz H) <= analz(insert X H)";
paulson@1913
   363
by (fast_tac (!claset addEs [impOfSubs analz_mono]) 1);
paulson@1913
   364
qed "analz_insert";
paulson@1839
   365
paulson@1839
   366
(** Rewrite rules for pulling out atomic messages **)
paulson@1839
   367
paulson@2373
   368
fun analz_tac i =
paulson@2373
   369
  EVERY [rtac ([subsetI, analz_insert] MRS equalityI) i,
paulson@2373
   370
	 etac analz.induct i,
paulson@2373
   371
	 REPEAT (fast_tac (!claset addss (!simpset)) i)];
paulson@2373
   372
paulson@1913
   373
goal thy "analz (insert (Agent agt) H) = insert (Agent agt) (analz H)";
paulson@2373
   374
by (analz_tac 1);
paulson@1913
   375
qed "analz_insert_Agent";
paulson@1839
   376
paulson@1913
   377
goal thy "analz (insert (Nonce N) H) = insert (Nonce N) (analz H)";
paulson@2373
   378
by (analz_tac 1);
paulson@1913
   379
qed "analz_insert_Nonce";
paulson@1839
   380
paulson@2373
   381
goal thy "analz (insert (Hash X) H) = insert (Hash X) (analz H)";
paulson@2373
   382
by (analz_tac 1);
paulson@2373
   383
qed "analz_insert_Hash";
paulson@2373
   384
paulson@1839
   385
(*Can only pull out Keys if they are not needed to decrypt the rest*)
paulson@1839
   386
goalw thy [keysFor_def]
paulson@1913
   387
    "!!K. K ~: keysFor (analz H) ==>  \
paulson@1913
   388
\         analz (insert (Key K) H) = insert (Key K) (analz H)";
paulson@2373
   389
by (analz_tac 1);
paulson@1913
   390
qed "analz_insert_Key";
paulson@1839
   391
paulson@1913
   392
goal thy "analz (insert {|X,Y|} H) = \
paulson@1913
   393
\         insert {|X,Y|} (analz (insert X (insert Y H)))";
paulson@2032
   394
by (rtac equalityI 1);
paulson@2032
   395
by (rtac subsetI 1);
paulson@2032
   396
by (etac analz.induct 1);
paulson@1885
   397
by (Auto_tac());
paulson@2032
   398
by (etac analz.induct 1);
paulson@2102
   399
by (ALLGOALS
paulson@2102
   400
    (deepen_tac (!claset addIs [analz.Fst, analz.Snd, analz.Decrypt]) 0));
paulson@1913
   401
qed "analz_insert_MPair";
paulson@1885
   402
paulson@1885
   403
(*Can pull out enCrypted message if the Key is not known*)
paulson@1913
   404
goal thy "!!H. Key (invKey K) ~: analz H ==>  \
paulson@2284
   405
\              analz (insert (Crypt K X) H) = \
paulson@2284
   406
\              insert (Crypt K X) (analz H)";
paulson@2373
   407
by (analz_tac 1);
paulson@1913
   408
qed "analz_insert_Crypt";
paulson@1839
   409
paulson@1913
   410
goal thy "!!H. Key (invKey K) : analz H ==>  \
paulson@2284
   411
\              analz (insert (Crypt K X) H) <= \
paulson@2284
   412
\              insert (Crypt K X) (analz (insert X H))";
paulson@2032
   413
by (rtac subsetI 1);
paulson@1913
   414
by (eres_inst_tac [("za","x")] analz.induct 1);
paulson@1839
   415
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@1839
   416
val lemma1 = result();
paulson@1839
   417
paulson@1913
   418
goal thy "!!H. Key (invKey K) : analz H ==>  \
paulson@2284
   419
\              insert (Crypt K X) (analz (insert X H)) <= \
paulson@2284
   420
\              analz (insert (Crypt K X) H)";
paulson@1839
   421
by (Auto_tac());
paulson@1913
   422
by (eres_inst_tac [("za","x")] analz.induct 1);
paulson@1839
   423
by (Auto_tac());
paulson@1913
   424
by (best_tac (!claset addIs [subset_insertI RS analz_mono RS subsetD,
paulson@2032
   425
                             analz.Decrypt]) 1);
paulson@1839
   426
val lemma2 = result();
paulson@1839
   427
paulson@1913
   428
goal thy "!!H. Key (invKey K) : analz H ==>  \
paulson@2284
   429
\              analz (insert (Crypt K X) H) = \
paulson@2284
   430
\              insert (Crypt K X) (analz (insert X H))";
paulson@1839
   431
by (REPEAT (ares_tac [equalityI, lemma1, lemma2] 1));
paulson@1913
   432
qed "analz_insert_Decrypt";
paulson@1839
   433
paulson@1885
   434
(*Case analysis: either the message is secure, or it is not!
paulson@1946
   435
  Effective, but can cause subgoals to blow up!
paulson@1885
   436
  Use with expand_if;  apparently split_tac does not cope with patterns
paulson@2284
   437
  such as "analz (insert (Crypt K X) H)" *)
paulson@2284
   438
goal thy "analz (insert (Crypt K X) H) =                \
paulson@2154
   439
\         (if (Key (invKey K) : analz H)                \
paulson@2284
   440
\          then insert (Crypt K X) (analz (insert X H)) \
paulson@2284
   441
\          else insert (Crypt K X) (analz H))";
paulson@2102
   442
by (case_tac "Key (invKey K)  : analz H " 1);
paulson@1913
   443
by (ALLGOALS (asm_simp_tac (!simpset addsimps [analz_insert_Crypt, 
paulson@2032
   444
                                               analz_insert_Decrypt])));
paulson@1913
   445
qed "analz_Crypt_if";
paulson@1885
   446
paulson@2373
   447
Addsimps [analz_insert_Agent, analz_insert_Nonce, analz_insert_Key, 
paulson@2373
   448
	  analz_insert_Hash, analz_insert_MPair, analz_Crypt_if];
paulson@1839
   449
paulson@1839
   450
(*This rule supposes "for the sake of argument" that we have the key.*)
paulson@2284
   451
goal thy  "analz (insert (Crypt K X) H) <=  \
paulson@2284
   452
\          insert (Crypt K X) (analz (insert X H))";
paulson@2032
   453
by (rtac subsetI 1);
paulson@2032
   454
by (etac analz.induct 1);
paulson@1839
   455
by (Auto_tac());
paulson@1913
   456
qed "analz_insert_Crypt_subset";
paulson@1839
   457
paulson@1839
   458
paulson@2026
   459
goal thy "analz (Key``N) = Key``N";
paulson@2026
   460
by (Auto_tac());
paulson@2032
   461
by (etac analz.induct 1);
paulson@2026
   462
by (Auto_tac());
paulson@2026
   463
qed "analz_image_Key";
paulson@2026
   464
paulson@2026
   465
Addsimps [analz_image_Key];
paulson@2026
   466
paulson@2026
   467
paulson@1839
   468
(** Idempotence and transitivity **)
paulson@1839
   469
paulson@1913
   470
goal thy "!!H. X: analz (analz H) ==> X: analz H";
paulson@2032
   471
by (etac analz.induct 1);
paulson@1839
   472
by (ALLGOALS Fast_tac);
paulson@1913
   473
qed "analz_analzE";
paulson@1913
   474
AddSEs [analz_analzE];
paulson@1839
   475
paulson@1913
   476
goal thy "analz (analz H) = analz H";
paulson@1839
   477
by (Fast_tac 1);
paulson@1913
   478
qed "analz_idem";
paulson@1913
   479
Addsimps [analz_idem];
paulson@1839
   480
paulson@1913
   481
goal thy "!!H. [| X: analz G;  G <= analz H |] ==> X: analz H";
paulson@1913
   482
by (dtac analz_mono 1);
paulson@1839
   483
by (Fast_tac 1);
paulson@1913
   484
qed "analz_trans";
paulson@1839
   485
paulson@1839
   486
(*Cut; Lemma 2 of Lowe*)
paulson@1998
   487
goal thy "!!H. [| Y: analz (insert X H);  X: analz H |] ==> Y: analz H";
paulson@2032
   488
by (etac analz_trans 1);
paulson@1839
   489
by (Fast_tac 1);
paulson@1913
   490
qed "analz_cut";
paulson@1839
   491
paulson@1839
   492
(*Cut can be proved easily by induction on
paulson@1913
   493
   "!!H. Y: analz (insert X H) ==> X: analz H --> Y: analz H"
paulson@1839
   494
*)
paulson@1839
   495
paulson@1885
   496
paulson@1913
   497
(** A congruence rule for "analz" **)
paulson@1885
   498
paulson@1913
   499
goal thy "!!H. [| analz G <= analz G'; analz H <= analz H' \
paulson@1913
   500
\              |] ==> analz (G Un H) <= analz (G' Un H')";
paulson@1885
   501
by (Step_tac 1);
paulson@2032
   502
by (etac analz.induct 1);
paulson@1913
   503
by (ALLGOALS (best_tac (!claset addIs [analz_mono RS subsetD])));
paulson@1913
   504
qed "analz_subset_cong";
paulson@1885
   505
paulson@1913
   506
goal thy "!!H. [| analz G = analz G'; analz H = analz H' \
paulson@1913
   507
\              |] ==> analz (G Un H) = analz (G' Un H')";
paulson@1913
   508
by (REPEAT_FIRST (ares_tac [equalityI, analz_subset_cong]
paulson@2032
   509
          ORELSE' etac equalityE));
paulson@1913
   510
qed "analz_cong";
paulson@1885
   511
paulson@1885
   512
paulson@1913
   513
goal thy "!!H. analz H = analz H' ==> analz(insert X H) = analz(insert X H')";
paulson@1885
   514
by (asm_simp_tac (!simpset addsimps [insert_def] 
paulson@2032
   515
                           setloop (rtac analz_cong)) 1);
paulson@1913
   516
qed "analz_insert_cong";
paulson@1885
   517
paulson@1913
   518
(*If there are no pairs or encryptions then analz does nothing*)
paulson@2284
   519
goal thy "!!H. [| ALL X Y. {|X,Y|} ~: H;  ALL X K. Crypt K X ~: H |] ==> \
paulson@1913
   520
\         analz H = H";
paulson@1839
   521
by (Step_tac 1);
paulson@2032
   522
by (etac analz.induct 1);
paulson@1839
   523
by (ALLGOALS Fast_tac);
paulson@1913
   524
qed "analz_trivial";
paulson@1839
   525
paulson@1839
   526
(*Helps to prove Fake cases*)
paulson@1913
   527
goal thy "!!X. X: analz (UN i. analz (H i)) ==> X: analz (UN i. H i)";
paulson@2032
   528
by (etac analz.induct 1);
paulson@1913
   529
by (ALLGOALS (fast_tac (!claset addEs [impOfSubs analz_mono])));
paulson@1839
   530
val lemma = result();
paulson@1839
   531
paulson@1913
   532
goal thy "analz (UN i. analz (H i)) = analz (UN i. H i)";
paulson@1839
   533
by (fast_tac (!claset addIs [lemma]
paulson@2032
   534
                      addEs [impOfSubs analz_mono]) 1);
paulson@1913
   535
qed "analz_UN_analz";
paulson@1913
   536
Addsimps [analz_UN_analz];
paulson@1839
   537
paulson@1839
   538
paulson@1913
   539
(**** Inductive relation "synth" ****)
paulson@1839
   540
paulson@1913
   541
AddIs  synth.intrs;
paulson@1839
   542
paulson@2011
   543
(*Can only produce a nonce or key if it is already known,
paulson@2011
   544
  but can synth a pair or encryption from its components...*)
paulson@2011
   545
val mk_cases = synth.mk_cases msg.simps;
paulson@2011
   546
paulson@2011
   547
(*NO Agent_synth, as any Agent name can be synthd*)
paulson@2011
   548
val Nonce_synth = mk_cases "Nonce n : synth H";
paulson@2011
   549
val Key_synth   = mk_cases "Key K : synth H";
paulson@2373
   550
val Hash_synth  = mk_cases "Hash X : synth H";
paulson@2011
   551
val MPair_synth = mk_cases "{|X,Y|} : synth H";
paulson@2284
   552
val Crypt_synth = mk_cases "Crypt K X : synth H";
paulson@2011
   553
paulson@2373
   554
AddSEs [Nonce_synth, Key_synth, Hash_synth, MPair_synth, Crypt_synth];
paulson@2011
   555
paulson@1913
   556
goal thy "H <= synth(H)";
paulson@1839
   557
by (Fast_tac 1);
paulson@1913
   558
qed "synth_increasing";
paulson@1839
   559
paulson@1839
   560
(*Monotonicity*)
paulson@1913
   561
goalw thy synth.defs "!!G H. G<=H ==> synth(G) <= synth(H)";
paulson@1839
   562
by (rtac lfp_mono 1);
paulson@1839
   563
by (REPEAT (ares_tac basic_monos 1));
paulson@1913
   564
qed "synth_mono";
paulson@1839
   565
paulson@1839
   566
(** Unions **)
paulson@1839
   567
paulson@1913
   568
(*Converse fails: we can synth more from the union than from the 
paulson@1839
   569
  separate parts, building a compound message using elements of each.*)
paulson@1913
   570
goal thy "synth(G) Un synth(H) <= synth(G Un H)";
paulson@1913
   571
by (REPEAT (ares_tac [Un_least, synth_mono, Un_upper1, Un_upper2] 1));
paulson@1913
   572
qed "synth_Un";
paulson@1839
   573
paulson@1913
   574
goal thy "insert X (synth H) <= synth(insert X H)";
paulson@1913
   575
by (fast_tac (!claset addEs [impOfSubs synth_mono]) 1);
paulson@1913
   576
qed "synth_insert";
paulson@1885
   577
paulson@1839
   578
(** Idempotence and transitivity **)
paulson@1839
   579
paulson@1913
   580
goal thy "!!H. X: synth (synth H) ==> X: synth H";
paulson@2032
   581
by (etac synth.induct 1);
paulson@1839
   582
by (ALLGOALS Fast_tac);
paulson@1913
   583
qed "synth_synthE";
paulson@1913
   584
AddSEs [synth_synthE];
paulson@1839
   585
paulson@1913
   586
goal thy "synth (synth H) = synth H";
paulson@1839
   587
by (Fast_tac 1);
paulson@1913
   588
qed "synth_idem";
paulson@1839
   589
paulson@1913
   590
goal thy "!!H. [| X: synth G;  G <= synth H |] ==> X: synth H";
paulson@1913
   591
by (dtac synth_mono 1);
paulson@1839
   592
by (Fast_tac 1);
paulson@1913
   593
qed "synth_trans";
paulson@1839
   594
paulson@1839
   595
(*Cut; Lemma 2 of Lowe*)
paulson@1998
   596
goal thy "!!H. [| Y: synth (insert X H);  X: synth H |] ==> Y: synth H";
paulson@2032
   597
by (etac synth_trans 1);
paulson@1839
   598
by (Fast_tac 1);
paulson@1913
   599
qed "synth_cut";
paulson@1839
   600
paulson@1946
   601
goal thy "Agent A : synth H";
paulson@1946
   602
by (Fast_tac 1);
paulson@1946
   603
qed "Agent_synth";
paulson@1946
   604
paulson@1913
   605
goal thy "(Nonce N : synth H) = (Nonce N : H)";
paulson@1839
   606
by (Fast_tac 1);
paulson@1913
   607
qed "Nonce_synth_eq";
paulson@1839
   608
paulson@1913
   609
goal thy "(Key K : synth H) = (Key K : H)";
paulson@1839
   610
by (Fast_tac 1);
paulson@1913
   611
qed "Key_synth_eq";
paulson@1839
   612
paulson@2373
   613
goal thy "!!K. Key K ~: H ==> (Crypt K X : synth H) = (Crypt K X : H)";
paulson@2011
   614
by (Fast_tac 1);
paulson@2011
   615
qed "Crypt_synth_eq";
paulson@2011
   616
paulson@2011
   617
Addsimps [Agent_synth, Nonce_synth_eq, Key_synth_eq, Crypt_synth_eq];
paulson@1839
   618
paulson@1839
   619
paulson@1839
   620
goalw thy [keysFor_def]
paulson@1913
   621
    "keysFor (synth H) = keysFor H Un invKey``{K. Key K : H}";
paulson@1839
   622
by (Fast_tac 1);
paulson@1913
   623
qed "keysFor_synth";
paulson@1913
   624
Addsimps [keysFor_synth];
paulson@1839
   625
paulson@1839
   626
paulson@1913
   627
(*** Combinations of parts, analz and synth ***)
paulson@1839
   628
paulson@1913
   629
goal thy "parts (synth H) = parts H Un synth H";
paulson@2032
   630
by (rtac equalityI 1);
paulson@2032
   631
by (rtac subsetI 1);
paulson@2032
   632
by (etac parts.induct 1);
paulson@1839
   633
by (ALLGOALS
paulson@1913
   634
    (best_tac (!claset addIs ((synth_increasing RS parts_mono RS subsetD)
paulson@2032
   635
                             ::parts.intrs))));
paulson@1913
   636
qed "parts_synth";
paulson@1913
   637
Addsimps [parts_synth];
paulson@1839
   638
paulson@2373
   639
goal thy "analz (analz G Un H) = analz (G Un H)";
paulson@2373
   640
by (REPEAT_FIRST (resolve_tac [equalityI, analz_subset_cong]));
paulson@2373
   641
by (ALLGOALS Simp_tac);
paulson@2373
   642
qed "analz_analz_Un";
paulson@2373
   643
paulson@2373
   644
goal thy "analz (synth G Un H) = analz (G Un H) Un synth G";
paulson@2032
   645
by (rtac equalityI 1);
paulson@2032
   646
by (rtac subsetI 1);
paulson@2032
   647
by (etac analz.induct 1);
paulson@2373
   648
by (deepen_tac (!claset addIs [impOfSubs analz_mono]) 0 5);
paulson@1839
   649
(*Strange that best_tac just can't hack this one...*)
paulson@1913
   650
by (ALLGOALS (deepen_tac (!claset addIs analz.intrs) 0));
paulson@2373
   651
qed "analz_synth_Un";
paulson@2373
   652
paulson@2373
   653
goal thy "analz (synth H) = analz H Un synth H";
paulson@2373
   654
by (cut_inst_tac [("H","{}")] analz_synth_Un 1);
paulson@2373
   655
by (Full_simp_tac 1);
paulson@1913
   656
qed "analz_synth";
paulson@2373
   657
Addsimps [analz_analz_Un, analz_synth_Un, analz_synth];
paulson@1839
   658
paulson@2032
   659
(*Hard to prove; still needed now that there's only one Spy?*)
paulson@1913
   660
goal thy "analz (UN i. synth (H i)) = \
paulson@1913
   661
\         analz (UN i. H i) Un (UN i. synth (H i))";
paulson@2032
   662
by (rtac equalityI 1);
paulson@2032
   663
by (rtac subsetI 1);
paulson@2032
   664
by (etac analz.induct 1);
paulson@1839
   665
by (best_tac
paulson@1913
   666
    (!claset addEs [impOfSubs synth_increasing,
paulson@2032
   667
                    impOfSubs analz_mono]) 5);
paulson@1839
   668
by (Best_tac 1);
paulson@1913
   669
by (deepen_tac (!claset addIs [analz.Fst]) 0 1);
paulson@1913
   670
by (deepen_tac (!claset addIs [analz.Snd]) 0 1);
paulson@1913
   671
by (deepen_tac (!claset addSEs [analz.Decrypt]
paulson@2032
   672
                        addIs  [analz.Decrypt]) 0 1);
paulson@1913
   673
qed "analz_UN1_synth";
paulson@1913
   674
Addsimps [analz_UN1_synth];
paulson@1929
   675
paulson@1946
   676
paulson@1946
   677
(** For reasoning about the Fake rule in traces **)
paulson@1946
   678
paulson@1929
   679
goal thy "!!Y. X: G ==> parts(insert X H) <= parts G Un parts H";
paulson@2032
   680
by (rtac ([parts_mono, parts_Un_subset2] MRS subset_trans) 1);
paulson@1929
   681
by (Fast_tac 1);
paulson@1929
   682
qed "parts_insert_subset_Un";
paulson@1929
   683
paulson@1946
   684
(*More specifically for Fake*)
paulson@1946
   685
goal thy "!!H. X: synth (analz G) ==> \
paulson@1946
   686
\              parts (insert X H) <= synth (analz G) Un parts G Un parts H";
paulson@2032
   687
by (dtac parts_insert_subset_Un 1);
paulson@1946
   688
by (Full_simp_tac 1);
paulson@1946
   689
by (Deepen_tac 0 1);
paulson@1946
   690
qed "Fake_parts_insert";
paulson@1946
   691
paulson@2061
   692
goal thy
paulson@2284
   693
     "!!H. [| Crypt K Y : parts (insert X H);  X: synth (analz G);  \
paulson@2061
   694
\             Key K ~: analz G |]                                   \
paulson@2284
   695
\          ==> Crypt K Y : parts G Un parts H";
paulson@2061
   696
by (dtac (impOfSubs Fake_parts_insert) 1);
paulson@2170
   697
by (assume_tac 1);
paulson@2061
   698
by (fast_tac (!claset addDs [impOfSubs analz_subset_parts]
paulson@2061
   699
                      addss (!simpset)) 1);
paulson@2061
   700
qed "Crypt_Fake_parts_insert";
paulson@2061
   701
paulson@2373
   702
goal thy "!!H. X: synth (analz G) ==> \
paulson@2373
   703
\              analz (insert X H) <= synth (analz G) Un analz (G Un H)";
paulson@2373
   704
by (rtac subsetI 1);
paulson@2373
   705
by (subgoal_tac "x : analz (synth (analz G) Un H)" 1);
paulson@2373
   706
by (best_tac (!claset addIs [impOfSubs (analz_mono RS synth_mono)]
paulson@2373
   707
                      addSEs [impOfSubs analz_mono]) 2);
paulson@2373
   708
by (Full_simp_tac 1);
paulson@2373
   709
by (Fast_tac 1);
paulson@2373
   710
qed "Fake_analz_insert";
paulson@2373
   711
paulson@2373
   712
(*Needed????????????????*)
paulson@1946
   713
goal thy "!!H. [| X: synth (analz G); G <= H |] ==> \
paulson@1946
   714
\              analz (insert X H) <= synth (analz H) Un analz H";
paulson@2032
   715
by (rtac subsetI 1);
paulson@1946
   716
by (subgoal_tac "x : analz (synth (analz H))" 1);
paulson@1946
   717
by (best_tac (!claset addIs [impOfSubs (analz_mono RS synth_mono)]
paulson@1946
   718
                      addSEs [impOfSubs analz_mono]) 2);
paulson@1946
   719
by (Full_simp_tac 1);
paulson@1946
   720
by (Fast_tac 1);
paulson@2373
   721
qed "Fake_analz_insert_old";
paulson@1929
   722
paulson@2011
   723
goal thy "(X: analz H & X: parts H) = (X: analz H)";
paulson@2011
   724
by (fast_tac (!claset addDs [impOfSubs analz_subset_parts]) 1);
paulson@2011
   725
val analz_conj_parts = result();
paulson@2011
   726
paulson@2011
   727
goal thy "(X: analz H | X: parts H) = (X: parts H)";
paulson@2011
   728
by (fast_tac (!claset addDs [impOfSubs analz_subset_parts]) 1);
paulson@2011
   729
val analz_disj_parts = result();
paulson@2011
   730
paulson@2011
   731
AddIffs [analz_conj_parts, analz_disj_parts];
paulson@2011
   732
paulson@1998
   733
(*Without this equation, other rules for synth and analz would yield
paulson@1998
   734
  redundant cases*)
paulson@1998
   735
goal thy "({|X,Y|} : synth (analz H)) = \
paulson@1998
   736
\         (X : synth (analz H) & Y : synth (analz H))";
paulson@1998
   737
by (Fast_tac 1);
paulson@1998
   738
qed "MPair_synth_analz";
paulson@1998
   739
paulson@1998
   740
AddIffs [MPair_synth_analz];
paulson@1929
   741
paulson@2154
   742
goal thy "!!K. [| Key K : analz H;  Key (invKey K) : analz H |] \
paulson@2284
   743
\              ==> (Crypt K X : synth (analz H)) = (X : synth (analz H))";
paulson@2154
   744
by (Fast_tac 1);
paulson@2154
   745
qed "Crypt_synth_analz";
paulson@2154
   746
paulson@1929
   747
paulson@2373
   748
goal thy "!!K. Key K ~: analz H \
paulson@2373
   749
\   ==> (Hash{|Key K,X|} : synth (analz H)) = (Hash{|Key K,X|} : analz H)";
paulson@2373
   750
by (Fast_tac 1);
paulson@2373
   751
qed "Hash_synth_analz";
paulson@2373
   752
Addsimps [Hash_synth_analz];
paulson@2373
   753
paulson@2373
   754
paulson@1929
   755
(*We do NOT want Crypt... messages broken up in protocols!!*)
paulson@1929
   756
Delrules partsEs;
paulson@1929
   757
paulson@2327
   758
paulson@2327
   759
(** Rewrites to push in Key and Crypt messages, so that other messages can
paulson@2327
   760
    be pulled out using the analz_insert rules **)
paulson@2327
   761
paulson@2327
   762
fun insComm thy x y = read_instantiate_sg (sign_of thy) [("x",x), ("y",y)] 
paulson@2327
   763
                          insert_commute;
paulson@2327
   764
paulson@2327
   765
val pushKeys = map (insComm thy "Key ?K") 
paulson@2373
   766
                   ["Agent ?C", "Nonce ?N", "Hash ?X", 
paulson@2373
   767
		    "MPair ?X ?Y", "Crypt ?X ?K'"];
paulson@2327
   768
paulson@2327
   769
val pushCrypts = map (insComm thy "Crypt ?X ?K") 
paulson@2373
   770
                     ["Agent ?C", "Nonce ?N", "Hash ?X'", "MPair ?X' ?Y"];
paulson@2327
   771
paulson@2327
   772
(*Cannot be added with Addsimps -- we don't always want to re-order messages*)
paulson@2327
   773
val pushes = pushKeys@pushCrypts;
paulson@2327
   774
paulson@2327
   775
paulson@2327
   776
(*No premature instantiation of variables.  For proving weak liveness.*)
paulson@2327
   777
fun safe_solver prems =
paulson@2327
   778
    match_tac (TrueI::refl::prems) ORELSE' eq_assume_tac
paulson@2327
   779
    ORELSE' etac FalseE;
paulson@2327
   780
paulson@2373
   781
val Fake_insert_tac = 
paulson@2373
   782
    dresolve_tac [impOfSubs Fake_analz_insert,
paulson@2373
   783
		  impOfSubs Fake_parts_insert] THEN'
paulson@2373
   784
    eresolve_tac [asm_rl, synth.Inj];
paulson@2373
   785
paulson@2373
   786
(*Analysis of Fake cases and of messages that forward unknown parts.
paulson@2327
   787
  Abstraction over i is ESSENTIAL: it delays the dereferencing of claset
paulson@2327
   788
  DEPENDS UPON "X" REFERRING TO THE FRADULENT MESSAGE *)
paulson@2327
   789
fun spy_analz_tac i =
paulson@2373
   790
  DETERM
paulson@2373
   791
   (SELECT_GOAL
paulson@2373
   792
     (EVERY 
paulson@2373
   793
      [  (*push in occurrences of X...*)
paulson@2373
   794
       (REPEAT o CHANGED)
paulson@2373
   795
           (res_inst_tac [("x1","X")] (insert_commute RS ssubst) 1),
paulson@2373
   796
       (*...allowing further simplifications*)
paulson@2373
   797
       simp_tac (!simpset setloop split_tac [expand_if]) 1,
paulson@2373
   798
       REPEAT (FIRSTGOAL (resolve_tac [allI,impI,notI,conjI])),
paulson@2373
   799
       DEPTH_SOLVE 
paulson@2373
   800
         (REPEAT (Fake_insert_tac 1) THEN Asm_full_simp_tac 1
paulson@2373
   801
	  THEN
paulson@2373
   802
	  IF_UNSOLVED (depth_tac (!claset addIs [impOfSubs analz_mono,
paulson@2373
   803
						 impOfSubs analz_subset_parts]) 2 1))
paulson@2373
   804
       ]) i);
paulson@2327
   805
paulson@2415
   806
(** Useful in many uniqueness proofs **)
paulson@2327
   807
fun ex_strip_tac i = REPEAT (swap_res_tac [exI, conjI] i) THEN 
paulson@2327
   808
                     assume_tac (i+1);
paulson@2327
   809
paulson@2415
   810
(*Apply the EX-ALL quantifification to prove uniqueness theorems in 
paulson@2415
   811
  their standard form*)
paulson@2415
   812
fun prove_unique_tac lemma = 
paulson@2415
   813
  EVERY' [dtac lemma,
paulson@2415
   814
	  REPEAT o (mp_tac ORELSE' eresolve_tac [asm_rl,exE]),
paulson@2415
   815
	  (*Duplicate the assumption*)
paulson@2415
   816
	  forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl,
paulson@2415
   817
	  fast_tac (!claset addSDs [spec])];
paulson@2415
   818
paulson@2373
   819
paulson@2373
   820
(*Needed occasionally with spy_analz_tac, e.g. in analz_insert_Key_newK*)
paulson@2373
   821
goal Set.thy "A Un (B Un A) = B Un A";
paulson@2373
   822
by (Fast_tac 1);
paulson@2373
   823
val Un_absorb3 = result();
paulson@2373
   824
Addsimps [Un_absorb3];