src/HOL/Auth/Message.ML
author paulson
Thu, 11 Sep 1997 12:24:28 +0200
changeset 3668 a39baf59ea47
parent 3650 282ffdc91884
child 3683 aafe719dff14
permissions -rw-r--r--
Split base cases from "msg" to "atomic" in order to reduce the number of freeness theorems
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/Message
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     2
    ID:         $Id$
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     5
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     6
Datatypes of agents and messages;
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
     7
Inductive relations "parts", "analz" and "synth"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     8
*)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     9
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    10
open Message;
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    11
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    12
AddIffs atomic.inject;
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    13
AddIffs msg.inject;
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    14
3514
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    15
(*Holds because Friend is injective: thus cannot prove for all f*)
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    16
goal thy "(Friend x : Friend``A) = (x:A)";
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    17
by (Auto_tac());
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    18
qed "Friend_image_eq";
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    19
Addsimps [Friend_image_eq];
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    20
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    21
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    22
(** Inverse of keys **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    23
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    24
goal thy "!!K K'. (invKey K = invKey K') = (K=K')";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    25
by (Step_tac 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
    26
by (rtac box_equals 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    27
by (REPEAT (rtac invKey 2));
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    28
by (Asm_simp_tac 1);
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    29
qed "invKey_eq";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    30
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    31
Addsimps [invKey, invKey_eq];
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    32
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    33
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    34
(**** keysFor operator ****)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    35
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    36
goalw thy [keysFor_def] "keysFor {} = {}";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    37
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    38
qed "keysFor_empty";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    39
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    40
goalw thy [keysFor_def] "keysFor (H Un H') = keysFor H Un keysFor H'";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    41
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    42
qed "keysFor_Un";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    43
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    44
goalw thy [keysFor_def] "keysFor (UN i. H i) = (UN i. keysFor (H i))";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    45
by (Blast_tac 1);
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
    46
qed "keysFor_UN1";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    47
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    48
(*Monotonicity*)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    49
goalw thy [keysFor_def] "!!G H. G<=H ==> keysFor(G) <= keysFor(H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    50
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    51
qed "keysFor_mono";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    52
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    53
goalw thy [keysFor_def] "keysFor (insert (Agent A) H) = keysFor H";
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
    54
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    55
qed "keysFor_insert_Agent";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    56
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    57
goalw thy [keysFor_def] "keysFor (insert (Nonce N) H) = keysFor H";
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
    58
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    59
qed "keysFor_insert_Nonce";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    60
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    61
goalw thy [keysFor_def] "keysFor (insert (Number N) H) = keysFor H";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    62
by (Blast_tac 1);
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    63
qed "keysFor_insert_Number";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    64
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    65
goalw thy [keysFor_def] "keysFor (insert (Key K) H) = keysFor H";
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
    66
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    67
qed "keysFor_insert_Key";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    68
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
    69
goalw thy [keysFor_def] "keysFor (insert (Hash X) H) = keysFor H";
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
    70
by (Blast_tac 1);
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
    71
qed "keysFor_insert_Hash";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
    72
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    73
goalw thy [keysFor_def] "keysFor (insert {|X,Y|} H) = keysFor H";
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
    74
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    75
qed "keysFor_insert_MPair";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    76
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    77
goalw thy [keysFor_def]
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
    78
    "keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    79
by (Auto_tac());
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    80
qed "keysFor_insert_Crypt";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    81
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
    82
Addsimps [keysFor_empty, keysFor_Un, keysFor_UN1, 
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    83
          keysFor_insert_Agent, keysFor_insert_Nonce, 
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
    84
	  keysFor_insert_Number, keysFor_insert_Key, 
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
    85
          keysFor_insert_Hash, keysFor_insert_MPair, keysFor_insert_Crypt];
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
    86
AddSEs [keysFor_Un RS equalityD1 RS subsetD RS UnE,
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
    87
	keysFor_UN1 RS equalityD1 RS subsetD RS UN1_E];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    88
3514
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    89
goalw thy [keysFor_def] "keysFor (Key``E) = {}";
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    90
by (Auto_tac ());
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    91
qed "keysFor_image_Key";
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    92
Addsimps [keysFor_image_Key];
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
    93
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
    94
goalw thy [keysFor_def] "!!H. Crypt K X : H ==> invKey K : keysFor H";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    95
by (Blast_tac 1);
2068
0d05468dc80c New theorem Crypt_imp_invKey_keysFor
paulson
parents: 2061
diff changeset
    96
qed "Crypt_imp_invKey_keysFor";
0d05468dc80c New theorem Crypt_imp_invKey_keysFor
paulson
parents: 2061
diff changeset
    97
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    98
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    99
(**** Inductive relation "parts" ****)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   100
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   101
val major::prems = 
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   102
goal thy "[| {|X,Y|} : parts H;       \
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   103
\            [| X : parts H; Y : parts H |] ==> P  \
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   104
\         |] ==> P";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   105
by (cut_facts_tac [major] 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   106
by (resolve_tac prems 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   107
by (REPEAT (eresolve_tac [asm_rl, parts.Fst, parts.Snd] 1));
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   108
qed "MPair_parts";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   109
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   110
AddIs  [parts.Inj];
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   111
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   112
val partsEs = [MPair_parts, make_elim parts.Body];
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   113
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   114
AddSEs partsEs;
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   115
(*NB These two rules are UNSAFE in the formal sense, as they discard the
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   116
     compound message.  They work well on THIS FILE, perhaps because its
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   117
     proofs concern only atomic messages.*)
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   118
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   119
goal thy "H <= parts(H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   120
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   121
qed "parts_increasing";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   122
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   123
(*Monotonicity*)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   124
goalw thy parts.defs "!!G H. G<=H ==> parts(G) <= parts(H)";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   125
by (rtac lfp_mono 1);
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   126
by (REPEAT (ares_tac basic_monos 1));
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   127
qed "parts_mono";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   128
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   129
val parts_insertI = impOfSubs (subset_insertI RS parts_mono);
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   130
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   131
goal thy "parts{} = {}";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   132
by (Step_tac 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   133
by (etac parts.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   134
by (ALLGOALS Blast_tac);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   135
qed "parts_empty";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   136
Addsimps [parts_empty];
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   137
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   138
goal thy "!!X. X: parts{} ==> P";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   139
by (Asm_full_simp_tac 1);
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   140
qed "parts_emptyE";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   141
AddSEs [parts_emptyE];
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   142
1893
fa58f4a06f21 Works up to main theorem, then XXX...X
paulson
parents: 1885
diff changeset
   143
(*WARNING: loops if H = {Y}, therefore must not be repeated!*)
fa58f4a06f21 Works up to main theorem, then XXX...X
paulson
parents: 1885
diff changeset
   144
goal thy "!!H. X: parts H ==> EX Y:H. X: parts {Y}";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   145
by (etac parts.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   146
by (ALLGOALS Blast_tac);
1893
fa58f4a06f21 Works up to main theorem, then XXX...X
paulson
parents: 1885
diff changeset
   147
qed "parts_singleton";
fa58f4a06f21 Works up to main theorem, then XXX...X
paulson
parents: 1885
diff changeset
   148
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   149
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   150
(** Unions **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   151
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   152
goal thy "parts(G) Un parts(H) <= parts(G Un H)";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   153
by (REPEAT (ares_tac [Un_least, parts_mono, Un_upper1, Un_upper2] 1));
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   154
val parts_Un_subset1 = result();
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   155
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   156
goal thy "parts(G Un H) <= parts(G) Un parts(H)";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   157
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   158
by (etac parts.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   159
by (ALLGOALS Blast_tac);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   160
val parts_Un_subset2 = result();
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   161
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   162
goal thy "parts(G Un H) = parts(G) Un parts(H)";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   163
by (REPEAT (ares_tac [equalityI, parts_Un_subset1, parts_Un_subset2] 1));
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   164
qed "parts_Un";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   165
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   166
goal thy "parts (insert X H) = parts {X} Un parts H";
1852
289ce6cb5c84 Added Msg 3; works up to Says_Server_imp_Key_newK
paulson
parents: 1839
diff changeset
   167
by (stac (read_instantiate [("A","H")] insert_is_Un) 1);
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   168
by (simp_tac (HOL_ss addsimps [parts_Un]) 1);
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   169
qed "parts_insert";
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   170
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   171
(*TWO inserts to avoid looping.  This rewrite is better than nothing.
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   172
  Not suitable for Addsimps: its behaviour can be strange.*)
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   173
goal thy "parts (insert X (insert Y H)) = parts {X} Un parts {Y} Un parts H";
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   174
by (simp_tac (!simpset addsimps [Un_assoc]) 1);
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   175
by (simp_tac (!simpset addsimps [parts_insert RS sym]) 1);
1852
289ce6cb5c84 Added Msg 3; works up to Says_Server_imp_Key_newK
paulson
parents: 1839
diff changeset
   176
qed "parts_insert2";
289ce6cb5c84 Added Msg 3; works up to Says_Server_imp_Key_newK
paulson
parents: 1839
diff changeset
   177
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   178
goal thy "(UN x:A. parts(H x)) <= parts(UN x:A. H x)";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   179
by (REPEAT (ares_tac [UN_least, parts_mono, UN_upper] 1));
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   180
val parts_UN_subset1 = result();
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   181
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   182
goal thy "parts(UN x:A. H x) <= (UN x:A. parts(H x))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   183
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   184
by (etac parts.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   185
by (ALLGOALS Blast_tac);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   186
val parts_UN_subset2 = result();
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   187
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   188
goal thy "parts(UN x:A. H x) = (UN x:A. parts(H x))";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   189
by (REPEAT (ares_tac [equalityI, parts_UN_subset1, parts_UN_subset2] 1));
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   190
qed "parts_UN";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   191
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   192
goal thy "parts(UN x. H x) = (UN x. parts(H x))";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   193
by (simp_tac (!simpset addsimps [UNION1_def, parts_UN]) 1);
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   194
qed "parts_UN1";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   195
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   196
(*Added to simplify arguments to parts, analz and synth.
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   197
  NOTE: the UN versions are no longer used!*)
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   198
Addsimps [parts_Un, parts_UN, parts_UN1];
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   199
AddSEs [parts_Un RS equalityD1 RS subsetD RS UnE,
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   200
	parts_UN RS equalityD1 RS subsetD RS UN_E,
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   201
	parts_UN1 RS equalityD1 RS subsetD RS UN1_E];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   202
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   203
goal thy "insert X (parts H) <= parts(insert X H)";
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   204
by (blast_tac (!claset addIs [impOfSubs parts_mono]) 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   205
qed "parts_insert_subset";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   206
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   207
(** Idempotence and transitivity **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   208
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   209
goal thy "!!H. X: parts (parts H) ==> X: parts H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   210
by (etac parts.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   211
by (ALLGOALS Blast_tac);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   212
qed "parts_partsD";
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   213
AddSDs [parts_partsD];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   214
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   215
goal thy "parts (parts H) = parts H";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   216
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   217
qed "parts_idem";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   218
Addsimps [parts_idem];
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   219
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   220
goal thy "!!H. [| X: parts G;  G <= parts H |] ==> X: parts H";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   221
by (dtac parts_mono 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   222
by (Blast_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   223
qed "parts_trans";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   224
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   225
(*Cut*)
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   226
goal thy "!!H. [| Y: parts (insert X G);  X: parts H |] \
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   227
\              ==> Y: parts (G Un H)";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   228
by (etac parts_trans 1);
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   229
by (Auto_tac());
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   230
qed "parts_cut";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   231
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   232
goal thy "!!H. X: parts H ==> parts (insert X H) = parts H";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   233
by (fast_tac (!claset addSDs [parts_cut]
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   234
                      addIs  [parts_insertI] 
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   235
                      addss (!simpset)) 1);
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   236
qed "parts_cut_eq";
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   237
2028
738bb98d65ec Last working version prior to addition of "lost" component
paulson
parents: 2026
diff changeset
   238
Addsimps [parts_cut_eq];
738bb98d65ec Last working version prior to addition of "lost" component
paulson
parents: 2026
diff changeset
   239
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   240
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   241
(** Rewrite rules for pulling out atomic messages **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   242
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   243
fun parts_tac i =
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   244
  EVERY [rtac ([subsetI, parts_insert_subset] MRS equalityI) i,
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   245
         etac parts.induct i,
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
   246
         REPEAT (Blast_tac i)];
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   247
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   248
goal thy "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   249
by (parts_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   250
qed "parts_insert_Agent";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   251
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   252
goal thy "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   253
by (parts_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   254
qed "parts_insert_Nonce";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   255
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   256
goal thy "parts (insert (Number N) H) = insert (Number N) (parts H)";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   257
by (parts_tac 1);
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   258
qed "parts_insert_Number";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   259
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   260
goal thy "parts (insert (Key K) H) = insert (Key K) (parts H)";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   261
by (parts_tac 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   262
qed "parts_insert_Key";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   263
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   264
goal thy "parts (insert (Hash X) H) = insert (Hash X) (parts H)";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   265
by (parts_tac 1);
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   266
qed "parts_insert_Hash";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   267
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   268
goal thy "parts (insert (Crypt K X) H) = \
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   269
\         insert (Crypt K X) (parts (insert X H))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   270
by (rtac equalityI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   271
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   272
by (etac parts.induct 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   273
by (Auto_tac());
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   274
by (etac parts.induct 1);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   275
by (ALLGOALS (blast_tac (!claset addIs [parts.Body])));
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   276
qed "parts_insert_Crypt";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   277
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   278
goal thy "parts (insert {|X,Y|} H) = \
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   279
\         insert {|X,Y|} (parts (insert X (insert Y H)))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   280
by (rtac equalityI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   281
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   282
by (etac parts.induct 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   283
by (Auto_tac());
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   284
by (etac parts.induct 1);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   285
by (ALLGOALS (blast_tac (!claset addIs [parts.Fst, parts.Snd])));
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   286
qed "parts_insert_MPair";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   287
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   288
Addsimps [parts_insert_Agent, parts_insert_Nonce, 
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   289
	  parts_insert_Number, parts_insert_Key, 
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   290
          parts_insert_Hash, parts_insert_Crypt, parts_insert_MPair];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   291
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   292
2026
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   293
goal thy "parts (Key``N) = Key``N";
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   294
by (Auto_tac());
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   295
by (etac parts.induct 1);
2026
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   296
by (Auto_tac());
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   297
qed "parts_image_Key";
3514
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   298
Addsimps [parts_image_Key];
2026
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   299
3514
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   300
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   301
(*In any message, there is an upper bound N on its greatest nonce.*)
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   302
goal thy "EX N. ALL n. N<=n --> Nonce n ~: parts {msg}";
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   303
by (induct_tac "msg" 1);
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   304
by (induct_tac "atomic" 1);
3514
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   305
by (ALLGOALS (asm_simp_tac (!simpset addsimps [exI, parts_insert2])));
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   306
(*MPair case: blast_tac works out the necessary sum itself!*)
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   307
by (blast_tac (!claset addSEs [add_leE]) 2);
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   308
(*Nonce case*)
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   309
by (res_inst_tac [("x","N + Suc nat")] exI 1);
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   310
by (fast_tac (!claset addSEs [add_leE] addaltern trans_tac) 1);
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   311
qed "msg_Nonce_supply";
2026
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   312
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   313
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   314
(**** Inductive relation "analz" ****)
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   315
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   316
val major::prems = 
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   317
goal thy "[| {|X,Y|} : analz H;       \
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   318
\            [| X : analz H; Y : analz H |] ==> P  \
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   319
\         |] ==> P";
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   320
by (cut_facts_tac [major] 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   321
by (resolve_tac prems 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   322
by (REPEAT (eresolve_tac [asm_rl, analz.Fst, analz.Snd] 1));
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   323
qed "MPair_analz";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   324
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   325
AddIs  [analz.Inj];
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   326
AddSEs [MPair_analz];      (*Perhaps it should NOT be deemed safe!*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   327
AddDs  [analz.Decrypt];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   328
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   329
Addsimps [analz.Inj];
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   330
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   331
goal thy "H <= analz(H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   332
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   333
qed "analz_increasing";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   334
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   335
goal thy "analz H <= parts H";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   336
by (rtac subsetI 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   337
by (etac analz.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   338
by (ALLGOALS Blast_tac);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   339
qed "analz_subset_parts";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   340
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   341
bind_thm ("not_parts_not_analz", analz_subset_parts RS contra_subsetD);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   342
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   343
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   344
goal thy "parts (analz H) = parts H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   345
by (rtac equalityI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   346
by (rtac (analz_subset_parts RS parts_mono RS subset_trans) 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   347
by (Simp_tac 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   348
by (blast_tac (!claset addIs [analz_increasing RS parts_mono RS subsetD]) 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   349
qed "parts_analz";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   350
Addsimps [parts_analz];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   351
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   352
goal thy "analz (parts H) = parts H";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   353
by (Auto_tac());
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   354
by (etac analz.induct 1);
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   355
by (Auto_tac());
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   356
qed "analz_parts";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   357
Addsimps [analz_parts];
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   358
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   359
(*Monotonicity; Lemma 1 of Lowe*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   360
goalw thy analz.defs "!!G H. G<=H ==> analz(G) <= analz(H)";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   361
by (rtac lfp_mono 1);
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   362
by (REPEAT (ares_tac basic_monos 1));
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   363
qed "analz_mono";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   364
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   365
val analz_insertI = impOfSubs (subset_insertI RS analz_mono);
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   366
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   367
(** General equational properties **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   368
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   369
goal thy "analz{} = {}";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   370
by (Step_tac 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   371
by (etac analz.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   372
by (ALLGOALS Blast_tac);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   373
qed "analz_empty";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   374
Addsimps [analz_empty];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   375
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   376
(*Converse fails: we can analz more from the union than from the 
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   377
  separate parts, as a key in one might decrypt a message in the other*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   378
goal thy "analz(G) Un analz(H) <= analz(G Un H)";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   379
by (REPEAT (ares_tac [Un_least, analz_mono, Un_upper1, Un_upper2] 1));
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   380
qed "analz_Un";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   381
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   382
goal thy "insert X (analz H) <= analz(insert X H)";
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   383
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   384
qed "analz_insert";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   385
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   386
(** Rewrite rules for pulling out atomic messages **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   387
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   388
fun analz_tac i =
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   389
  EVERY [rtac ([subsetI, analz_insert] MRS equalityI) i,
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   390
         etac analz.induct i,
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
   391
         REPEAT (Blast_tac i)];
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   392
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   393
goal thy "analz (insert (Agent agt) H) = insert (Agent agt) (analz H)";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   394
by (analz_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   395
qed "analz_insert_Agent";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   396
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   397
goal thy "analz (insert (Nonce N) H) = insert (Nonce N) (analz H)";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   398
by (analz_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   399
qed "analz_insert_Nonce";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   400
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   401
goal thy "analz (insert (Number N) H) = insert (Number N) (analz H)";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   402
by (analz_tac 1);
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   403
qed "analz_insert_Number";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   404
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   405
goal thy "analz (insert (Hash X) H) = insert (Hash X) (analz H)";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   406
by (analz_tac 1);
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   407
qed "analz_insert_Hash";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   408
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   409
(*Can only pull out Keys if they are not needed to decrypt the rest*)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   410
goalw thy [keysFor_def]
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   411
    "!!K. K ~: keysFor (analz H) ==>  \
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   412
\         analz (insert (Key K) H) = insert (Key K) (analz H)";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   413
by (analz_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   414
qed "analz_insert_Key";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   415
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   416
goal thy "analz (insert {|X,Y|} H) = \
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   417
\         insert {|X,Y|} (analz (insert X (insert Y H)))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   418
by (rtac equalityI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   419
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   420
by (etac analz.induct 1);
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   421
by (Auto_tac());
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   422
by (etac analz.induct 1);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   423
by (ALLGOALS (blast_tac (!claset addIs [analz.Fst, analz.Snd])));
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   424
qed "analz_insert_MPair";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   425
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   426
(*Can pull out enCrypted message if the Key is not known*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   427
goal thy "!!H. Key (invKey K) ~: analz H ==>  \
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   428
\              analz (insert (Crypt K X) H) = \
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   429
\              insert (Crypt K X) (analz H)";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   430
by (analz_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   431
qed "analz_insert_Crypt";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   432
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   433
goal thy "!!H. Key (invKey K) : analz H ==>  \
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   434
\              analz (insert (Crypt K X) H) <= \
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   435
\              insert (Crypt K X) (analz (insert X H))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   436
by (rtac subsetI 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   437
by (eres_inst_tac [("za","x")] analz.induct 1);
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
   438
by (ALLGOALS (Blast_tac));
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   439
val lemma1 = result();
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   440
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   441
goal thy "!!H. Key (invKey K) : analz H ==>  \
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   442
\              insert (Crypt K X) (analz (insert X H)) <= \
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   443
\              analz (insert (Crypt K X) H)";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   444
by (Auto_tac());
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   445
by (eres_inst_tac [("za","x")] analz.induct 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   446
by (Auto_tac());
3449
6b17f82bbf01 New comments; a tidied proof
paulson
parents: 3431
diff changeset
   447
by (blast_tac (!claset addIs [analz_insertI, analz.Decrypt]) 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   448
val lemma2 = result();
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   449
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   450
goal thy "!!H. Key (invKey K) : analz H ==>  \
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   451
\              analz (insert (Crypt K X) H) = \
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   452
\              insert (Crypt K X) (analz (insert X H))";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   453
by (REPEAT (ares_tac [equalityI, lemma1, lemma2] 1));
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   454
qed "analz_insert_Decrypt";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   455
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   456
(*Case analysis: either the message is secure, or it is not!
1946
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   457
  Effective, but can cause subgoals to blow up!
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   458
  Use with expand_if;  apparently split_tac does not cope with patterns
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   459
  such as "analz (insert (Crypt K X) H)" *)
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   460
goal thy "analz (insert (Crypt K X) H) =                \
2154
913b4fc7670a New, purely illustrative result Crypt_synth_analz
paulson
parents: 2102
diff changeset
   461
\         (if (Key (invKey K) : analz H)                \
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   462
\          then insert (Crypt K X) (analz (insert X H)) \
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   463
\          else insert (Crypt K X) (analz H))";
2102
41a667d2c3fa Replaced excluded_middle_tac by case_tac
paulson
parents: 2068
diff changeset
   464
by (case_tac "Key (invKey K)  : analz H " 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   465
by (ALLGOALS (asm_simp_tac (!simpset addsimps [analz_insert_Crypt, 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   466
                                               analz_insert_Decrypt])));
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   467
qed "analz_Crypt_if";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   468
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   469
Addsimps [analz_insert_Agent, analz_insert_Nonce, 
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   470
	  analz_insert_Number, analz_insert_Key, 
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   471
          analz_insert_Hash, analz_insert_MPair, analz_Crypt_if];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   472
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   473
(*This rule supposes "for the sake of argument" that we have the key.*)
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   474
goal thy  "analz (insert (Crypt K X) H) <=  \
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   475
\          insert (Crypt K X) (analz (insert X H))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   476
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   477
by (etac analz.induct 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   478
by (Auto_tac());
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   479
qed "analz_insert_Crypt_subset";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   480
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   481
2026
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   482
goal thy "analz (Key``N) = Key``N";
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   483
by (Auto_tac());
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   484
by (etac analz.induct 1);
2026
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   485
by (Auto_tac());
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   486
qed "analz_image_Key";
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   487
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   488
Addsimps [analz_image_Key];
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   489
0df5a96bf77e Last working version prior to introduction of "lost"
paulson
parents: 2011
diff changeset
   490
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   491
(** Idempotence and transitivity **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   492
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   493
goal thy "!!H. X: analz (analz H) ==> X: analz H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   494
by (etac analz.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   495
by (ALLGOALS Blast_tac);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   496
qed "analz_analzD";
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   497
AddSDs [analz_analzD];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   498
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   499
goal thy "analz (analz H) = analz H";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   500
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   501
qed "analz_idem";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   502
Addsimps [analz_idem];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   503
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   504
goal thy "!!H. [| X: analz G;  G <= analz H |] ==> X: analz H";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   505
by (dtac analz_mono 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   506
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   507
qed "analz_trans";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   508
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   509
(*Cut; Lemma 2 of Lowe*)
1998
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   510
goal thy "!!H. [| Y: analz (insert X H);  X: analz H |] ==> Y: analz H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   511
by (etac analz_trans 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   512
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   513
qed "analz_cut";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   514
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   515
(*Cut can be proved easily by induction on
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   516
   "!!H. Y: analz (insert X H) ==> X: analz H --> Y: analz H"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   517
*)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   518
3449
6b17f82bbf01 New comments; a tidied proof
paulson
parents: 3431
diff changeset
   519
(*This rewrite rule helps in the simplification of messages that involve
6b17f82bbf01 New comments; a tidied proof
paulson
parents: 3431
diff changeset
   520
  the forwarding of unknown components (X).  Without it, removing occurrences
6b17f82bbf01 New comments; a tidied proof
paulson
parents: 3431
diff changeset
   521
  of X can be very complicated. *)
3431
05b397185e1d Useful new lemma
paulson
parents: 3121
diff changeset
   522
goal thy "!!H. X: analz H ==> analz (insert X H) = analz H";
05b397185e1d Useful new lemma
paulson
parents: 3121
diff changeset
   523
by (blast_tac (!claset addIs [analz_cut, analz_insertI]) 1);
05b397185e1d Useful new lemma
paulson
parents: 3121
diff changeset
   524
qed "analz_insert_eq";
05b397185e1d Useful new lemma
paulson
parents: 3121
diff changeset
   525
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   526
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   527
(** A congruence rule for "analz" **)
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   528
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   529
goal thy "!!H. [| analz G <= analz G'; analz H <= analz H' \
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   530
\              |] ==> analz (G Un H) <= analz (G' Un H')";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   531
by (Step_tac 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   532
by (etac analz.induct 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   533
by (ALLGOALS (best_tac (!claset addIs [analz_mono RS subsetD])));
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   534
qed "analz_subset_cong";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   535
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   536
goal thy "!!H. [| analz G = analz G'; analz H = analz H' \
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   537
\              |] ==> analz (G Un H) = analz (G' Un H')";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   538
by (REPEAT_FIRST (ares_tac [equalityI, analz_subset_cong]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   539
          ORELSE' etac equalityE));
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   540
qed "analz_cong";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   541
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   542
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   543
goal thy "!!H. analz H = analz H' ==> analz(insert X H) = analz(insert X H')";
3583
5a47b869d16a Had to remove {x.x=a} = a from !simpset in one proof.
nipkow
parents: 3519
diff changeset
   544
by (asm_simp_tac (!simpset addsimps [insert_def] delsimps [singleton_conv]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   545
                           setloop (rtac analz_cong)) 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   546
qed "analz_insert_cong";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   547
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   548
(*If there are no pairs or encryptions then analz does nothing*)
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   549
goal thy "!!H. [| ALL X Y. {|X,Y|} ~: H;  ALL X K. Crypt K X ~: H |] ==> \
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   550
\         analz H = H";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   551
by (Step_tac 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   552
by (etac analz.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   553
by (ALLGOALS Blast_tac);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   554
qed "analz_trivial";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   555
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   556
(*Helps to prove Fake cases*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   557
goal thy "!!X. X: analz (UN i. analz (H i)) ==> X: analz (UN i. H i)";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   558
by (etac analz.induct 1);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   559
by (ALLGOALS (blast_tac (!claset addIs [impOfSubs analz_mono])));
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   560
val lemma = result();
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   561
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   562
goal thy "analz (UN i. analz (H i)) = analz (UN i. H i)";
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   563
by (blast_tac (!claset addIs [lemma, impOfSubs analz_mono]) 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   564
qed "analz_UN_analz";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   565
Addsimps [analz_UN_analz];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   566
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   567
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   568
(**** Inductive relation "synth" ****)
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   569
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   570
AddIs  synth.intrs;
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   571
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   572
(*Can only produce a nonce or key if it is already known,
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   573
  but can synth a pair or encryption from its components...*)
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   574
val mk_cases = synth.mk_cases (atomic.simps @ msg.simps);
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   575
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   576
(*NO Agent_synth, as any Agent name can be synthesized.  Ditto for Number*)
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   577
val Nonce_synth = mk_cases "Nonce n : synth H";
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   578
val Key_synth   = mk_cases "Key K : synth H";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   579
val Hash_synth  = mk_cases "Hash X : synth H";
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   580
val MPair_synth = mk_cases "{|X,Y|} : synth H";
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   581
val Crypt_synth = mk_cases "Crypt K X : synth H";
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   582
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   583
AddSEs [Nonce_synth, Key_synth, Hash_synth, MPair_synth, Crypt_synth];
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   584
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   585
goal thy "H <= synth(H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   586
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   587
qed "synth_increasing";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   588
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   589
(*Monotonicity*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   590
goalw thy synth.defs "!!G H. G<=H ==> synth(G) <= synth(H)";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   591
by (rtac lfp_mono 1);
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   592
by (REPEAT (ares_tac basic_monos 1));
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   593
qed "synth_mono";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   594
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   595
(** Unions **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   596
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   597
(*Converse fails: we can synth more from the union than from the 
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   598
  separate parts, building a compound message using elements of each.*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   599
goal thy "synth(G) Un synth(H) <= synth(G Un H)";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   600
by (REPEAT (ares_tac [Un_least, synth_mono, Un_upper1, Un_upper2] 1));
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   601
qed "synth_Un";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   602
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   603
goal thy "insert X (synth H) <= synth(insert X H)";
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   604
by (blast_tac (!claset addIs [impOfSubs synth_mono]) 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   605
qed "synth_insert";
1885
a18a6dc14f76 Auth proofs work up to the XXX...
paulson
parents: 1852
diff changeset
   606
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   607
(** Idempotence and transitivity **)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   608
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   609
goal thy "!!H. X: synth (synth H) ==> X: synth H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   610
by (etac synth.induct 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   611
by (ALLGOALS Blast_tac);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   612
qed "synth_synthD";
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   613
AddSDs [synth_synthD];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   614
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   615
goal thy "synth (synth H) = synth H";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   616
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   617
qed "synth_idem";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   618
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   619
goal thy "!!H. [| X: synth G;  G <= synth H |] ==> X: synth H";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   620
by (dtac synth_mono 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   621
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   622
qed "synth_trans";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   623
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   624
(*Cut; Lemma 2 of Lowe*)
1998
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   625
goal thy "!!H. [| Y: synth (insert X H);  X: synth H |] ==> Y: synth H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   626
by (etac synth_trans 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   627
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   628
qed "synth_cut";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   629
1946
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   630
goal thy "Agent A : synth H";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   631
by (Blast_tac 1);
1946
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   632
qed "Agent_synth";
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   633
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   634
goal thy "Number n : synth H";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   635
by (Blast_tac 1);
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   636
qed "Number_synth";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   637
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   638
goal thy "(Nonce N : synth H) = (Nonce N : H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   639
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   640
qed "Nonce_synth_eq";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   641
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   642
goal thy "(Key K : synth H) = (Key K : H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   643
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   644
qed "Key_synth_eq";
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   645
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   646
goal thy "!!K. Key K ~: H ==> (Crypt K X : synth H) = (Crypt K X : H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   647
by (Blast_tac 1);
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   648
qed "Crypt_synth_eq";
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   649
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   650
Addsimps [Agent_synth, Number_synth, 
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   651
	  Nonce_synth_eq, Key_synth_eq, Crypt_synth_eq];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   652
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   653
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   654
goalw thy [keysFor_def]
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   655
    "keysFor (synth H) = keysFor H Un invKey``{K. Key K : H}";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   656
by (Blast_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   657
qed "keysFor_synth";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   658
Addsimps [keysFor_synth];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   659
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   660
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   661
(*** Combinations of parts, analz and synth ***)
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   662
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   663
goal thy "parts (synth H) = parts H Un synth H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   664
by (rtac equalityI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   665
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   666
by (etac parts.induct 1);
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   667
by (ALLGOALS
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   668
    (blast_tac (!claset addIs ((synth_increasing RS parts_mono RS subsetD)
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   669
                             ::parts.intrs))));
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   670
qed "parts_synth";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   671
Addsimps [parts_synth];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   672
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   673
goal thy "analz (analz G Un H) = analz (G Un H)";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   674
by (REPEAT_FIRST (resolve_tac [equalityI, analz_subset_cong]));
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   675
by (ALLGOALS Simp_tac);
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   676
qed "analz_analz_Un";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   677
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   678
goal thy "analz (synth G Un H) = analz (G Un H) Un synth G";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   679
by (rtac equalityI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   680
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   681
by (etac analz.induct 1);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   682
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 5);
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   683
by (ALLGOALS (blast_tac (!claset addIs analz.intrs)));
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   684
qed "analz_synth_Un";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   685
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   686
goal thy "analz (synth H) = analz H Un synth H";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   687
by (cut_inst_tac [("H","{}")] analz_synth_Un 1);
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   688
by (Full_simp_tac 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   689
qed "analz_synth";
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   690
Addsimps [analz_analz_Un, analz_synth_Un, analz_synth];
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   691
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   692
(*Hard to prove; still needed now that there's only one Spy?*)
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   693
goal thy "analz (UN i. synth (H i)) = \
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   694
\         analz (UN i. H i) Un (UN i. synth (H i))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   695
by (rtac equalityI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   696
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   697
by (etac analz.induct 1);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   698
by (blast_tac
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   699
    (!claset addIs [impOfSubs synth_increasing,
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   700
                    impOfSubs analz_mono]) 5);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   701
by (Blast_tac 1);
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   702
by (blast_tac (!claset addIs [analz.Inj RS analz.Fst]) 1);
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   703
by (blast_tac (!claset addIs [analz.Inj RS analz.Snd]) 1);
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   704
by (blast_tac (!claset addIs [analz.Decrypt]) 1);
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   705
qed "analz_UN1_synth";
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1893
diff changeset
   706
Addsimps [analz_UN1_synth];
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   707
1946
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   708
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   709
(** For reasoning about the Fake rule in traces **)
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   710
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   711
goal thy "!!Y. X: G ==> parts(insert X H) <= parts G Un parts H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   712
by (rtac ([parts_mono, parts_Un_subset2] MRS subset_trans) 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   713
by (Blast_tac 1);
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   714
qed "parts_insert_subset_Un";
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   715
1946
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   716
(*More specifically for Fake*)
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   717
goal thy "!!H. X: synth (analz G) ==> \
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   718
\              parts (insert X H) <= synth (analz G) Un parts G Un parts H";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2028
diff changeset
   719
by (dtac parts_insert_subset_Un 1);
1946
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   720
by (Full_simp_tac 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   721
by (Blast_tac 1);
1946
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   722
qed "Fake_parts_insert";
b59a3d686436 New theorems for Fake case
paulson
parents: 1929
diff changeset
   723
2061
b14a08bf61bf New theorem Crypt_Fake_parts_insert
paulson
parents: 2032
diff changeset
   724
goal thy
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   725
     "!!H. [| Crypt K Y : parts (insert X H);  X: synth (analz G);  \
2061
b14a08bf61bf New theorem Crypt_Fake_parts_insert
paulson
parents: 2032
diff changeset
   726
\             Key K ~: analz G |]                                   \
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   727
\          ==> Crypt K Y : parts G Un parts H";
2061
b14a08bf61bf New theorem Crypt_Fake_parts_insert
paulson
parents: 2032
diff changeset
   728
by (dtac (impOfSubs Fake_parts_insert) 1);
2170
c5e460f1ebb4 Ran expandshort
paulson
parents: 2154
diff changeset
   729
by (assume_tac 1);
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
   730
by (blast_tac (!claset addDs [impOfSubs analz_subset_parts]) 1);
2061
b14a08bf61bf New theorem Crypt_Fake_parts_insert
paulson
parents: 2032
diff changeset
   731
qed "Crypt_Fake_parts_insert";
b14a08bf61bf New theorem Crypt_Fake_parts_insert
paulson
parents: 2032
diff changeset
   732
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   733
goal thy "!!H. X: synth (analz G) ==> \
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   734
\              analz (insert X H) <= synth (analz G) Un analz (G Un H)";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   735
by (rtac subsetI 1);
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   736
by (subgoal_tac "x : analz (synth (analz G) Un H)" 1);
2922
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   737
by (blast_tac (!claset addIs [impOfSubs analz_mono,
580647a879cf Using Blast_tac
paulson
parents: 2891
diff changeset
   738
			      impOfSubs (analz_mono RS synth_mono)]) 2);
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   739
by (Full_simp_tac 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   740
by (Blast_tac 1);
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   741
qed "Fake_analz_insert";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   742
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   743
goal thy "(X: analz H & X: parts H) = (X: analz H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   744
by (blast_tac (!claset addIs [impOfSubs analz_subset_parts]) 1);
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   745
val analz_conj_parts = result();
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   746
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   747
goal thy "(X: analz H | X: parts H) = (X: parts H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   748
by (blast_tac (!claset addIs [impOfSubs analz_subset_parts]) 1);
2011
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   749
val analz_disj_parts = result();
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   750
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   751
AddIffs [analz_conj_parts, analz_disj_parts];
d9af64c26be6 New laws for messages
paulson
parents: 1998
diff changeset
   752
1998
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   753
(*Without this equation, other rules for synth and analz would yield
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   754
  redundant cases*)
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   755
goal thy "({|X,Y|} : synth (analz H)) = \
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   756
\         (X : synth (analz H) & Y : synth (analz H))";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   757
by (Blast_tac 1);
1998
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   758
qed "MPair_synth_analz";
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   759
f8230821f1e8 Reordering of premises for cut theorems, and new law MPair_synth_analz
paulson
parents: 1994
diff changeset
   760
AddIffs [MPair_synth_analz];
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   761
2154
913b4fc7670a New, purely illustrative result Crypt_synth_analz
paulson
parents: 2102
diff changeset
   762
goal thy "!!K. [| Key K : analz H;  Key (invKey K) : analz H |] \
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2170
diff changeset
   763
\              ==> (Crypt K X : synth (analz H)) = (X : synth (analz H))";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   764
by (Blast_tac 1);
2154
913b4fc7670a New, purely illustrative result Crypt_synth_analz
paulson
parents: 2102
diff changeset
   765
qed "Crypt_synth_analz";
913b4fc7670a New, purely illustrative result Crypt_synth_analz
paulson
parents: 2102
diff changeset
   766
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   767
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   768
goal thy "!!K. X ~: synth (analz H) \
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   769
\   ==> (Hash{|X,Y|} : synth (analz H)) = (Hash{|X,Y|} : analz H)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   770
by (Blast_tac 1);
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   771
qed "Hash_synth_analz";
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   772
Addsimps [Hash_synth_analz];
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   773
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   774
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   775
(**** HPair: a combination of Hash and MPair ****)
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   776
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   777
(*** Freeness ***)
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   778
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   779
goalw thy [HPair_def] "Agent A ~= Hash[X] Y";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   780
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   781
qed "Agent_neq_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   782
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   783
goalw thy [HPair_def] "Nonce N ~= Hash[X] Y";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   784
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   785
qed "Nonce_neq_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   786
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   787
goalw thy [HPair_def] "Number N ~= Hash[X] Y";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   788
by (Simp_tac 1);
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   789
qed "Number_neq_HPair";
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   790
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   791
goalw thy [HPair_def] "Key K ~= Hash[X] Y";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   792
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   793
qed "Key_neq_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   794
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   795
goalw thy [HPair_def] "Hash Z ~= Hash[X] Y";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   796
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   797
qed "Hash_neq_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   798
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   799
goalw thy [HPair_def] "Crypt K X' ~= Hash[X] Y";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   800
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   801
qed "Crypt_neq_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   802
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   803
val HPair_neqs = [Agent_neq_HPair, Nonce_neq_HPair, Number_neq_HPair, 
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   804
                  Key_neq_HPair, Hash_neq_HPair, Crypt_neq_HPair];
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   805
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   806
AddIffs HPair_neqs;
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   807
AddIffs (HPair_neqs RL [not_sym]);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   808
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   809
goalw thy [HPair_def] "(Hash[X'] Y' = Hash[X] Y) = (X' = X & Y'=Y)";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   810
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   811
qed "HPair_eq";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   812
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   813
goalw thy [HPair_def] "({|X',Y'|} = Hash[X] Y) = (X' = Hash{|X,Y|} & Y'=Y)";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   814
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   815
qed "MPair_eq_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   816
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   817
goalw thy [HPair_def] "(Hash[X] Y = {|X',Y'|}) = (X' = Hash{|X,Y|} & Y'=Y)";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   818
by (Auto_tac());
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   819
qed "HPair_eq_MPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   820
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   821
AddIffs [HPair_eq, MPair_eq_HPair, HPair_eq_MPair];
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   822
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   823
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   824
(*** Specialized laws, proved in terms of those for Hash and MPair ***)
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   825
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   826
goalw thy [HPair_def] "keysFor (insert (Hash[X] Y) H) = keysFor H";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   827
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   828
qed "keysFor_insert_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   829
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   830
goalw thy [HPair_def]
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   831
    "parts (insert (Hash[X] Y) H) = \
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   832
\    insert (Hash[X] Y) (insert (Hash{|X,Y|}) (parts (insert Y H)))";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   833
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   834
qed "parts_insert_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   835
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   836
goalw thy [HPair_def]
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   837
    "analz (insert (Hash[X] Y) H) = \
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   838
\    insert (Hash[X] Y) (insert (Hash{|X,Y|}) (analz (insert Y H)))";
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   839
by (Simp_tac 1);
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   840
qed "analz_insert_HPair";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   841
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   842
goalw thy [HPair_def] "!!H. X ~: synth (analz H) \
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   843
\   ==> (Hash[X] Y : synth (analz H)) = \
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   844
\       (Hash {|X, Y|} : analz H & Y : synth (analz H))";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   845
by (Simp_tac 1);
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   846
by (Blast_tac 1);
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   847
qed "HPair_synth_analz";
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   848
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   849
Addsimps [keysFor_insert_HPair, parts_insert_HPair, analz_insert_HPair, 
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   850
          HPair_synth_analz, HPair_synth_analz];
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   851
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2415
diff changeset
   852
1929
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   853
(*We do NOT want Crypt... messages broken up in protocols!!*)
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   854
Delrules partsEs;
f0839bab4b00 Working version of NS, messages 1-3, WITH INTERLEAVING
paulson
parents: 1913
diff changeset
   855
2327
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   856
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   857
(** Rewrites to push in Key and Crypt messages, so that other messages can
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   858
    be pulled out using the analz_insert rules **)
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   859
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   860
fun insComm thy x y = read_instantiate_sg (sign_of thy) [("x",x), ("y",y)] 
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   861
                          insert_commute;
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   862
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   863
val pushKeys = map (insComm thy "Key ?K") 
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   864
                   ["Agent ?C", "Nonce ?N", "Number ?N", 
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   865
		    "Hash ?X", "MPair ?X ?Y", "Crypt ?X ?K'"];
2327
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   866
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   867
val pushCrypts = map (insComm thy "Crypt ?X ?K") 
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   868
                     ["Agent ?C", "Nonce ?N", "Number ?N", 
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   869
		      "Hash ?X'", "MPair ?X' ?Y"];
2327
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   870
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   871
(*Cannot be added with Addsimps -- we don't always want to re-order messages*)
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   872
val pushes = pushKeys@pushCrypts;
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   873
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   874
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   875
(*** Tactics useful for many protocol proofs ***)
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   876
3470
8160cc3f6d40 Added a comment
paulson
parents: 3449
diff changeset
   877
(*Prove base case (subgoal i) and simplify others.  A typical base case
8160cc3f6d40 Added a comment
paulson
parents: 3449
diff changeset
   878
  concerns  Crypt K X ~: Key``shrK``lost  and cannot be proved by rewriting
8160cc3f6d40 Added a comment
paulson
parents: 3449
diff changeset
   879
  alone.*)
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   880
fun prove_simple_subgoals_tac i = 
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   881
    fast_tac (!claset addss (!simpset)) i THEN
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   882
    ALLGOALS Asm_simp_tac;
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   883
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   884
fun Fake_parts_insert_tac i = 
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   885
    blast_tac (!claset addDs [impOfSubs analz_subset_parts,
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   886
			      impOfSubs Fake_parts_insert]) i;
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   887
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   888
(*Apply rules to break down assumptions of the form
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   889
  Y : parts(insert X H)  and  Y : analz(insert X H)
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 3102
diff changeset
   890
*)
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   891
val Fake_insert_tac = 
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   892
    dresolve_tac [impOfSubs Fake_analz_insert,
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   893
                  impOfSubs Fake_parts_insert] THEN'
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   894
    eresolve_tac [asm_rl, synth.Inj];
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   895
3449
6b17f82bbf01 New comments; a tidied proof
paulson
parents: 3431
diff changeset
   896
(*Analysis of Fake cases.  Also works for messages that forward unknown parts,
6b17f82bbf01 New comments; a tidied proof
paulson
parents: 3431
diff changeset
   897
  but this application is no longer necessary if analz_insert_eq is used.
2327
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   898
  Abstraction over i is ESSENTIAL: it delays the dereferencing of claset
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   899
  DEPENDS UPON "X" REFERRING TO THE FRADULENT MESSAGE *)
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   900
fun spy_analz_tac i =
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   901
  DETERM
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   902
   (SELECT_GOAL
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   903
     (EVERY 
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   904
      [  (*push in occurrences of X...*)
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   905
       (REPEAT o CHANGED)
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   906
           (res_inst_tac [("x1","X")] (insert_commute RS ssubst) 1),
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   907
       (*...allowing further simplifications*)
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   908
       simp_tac (!simpset setloop split_tac [expand_if]) 1,
3476
1be4fee7606b spy_analz_tac: Restored iffI to the list of rules used to break down
paulson
parents: 3470
diff changeset
   909
       REPEAT (FIRSTGOAL (resolve_tac [allI,impI,notI,conjI,iffI])),
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   910
       DEPTH_SOLVE 
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   911
         (REPEAT (Fake_insert_tac 1) THEN Asm_full_simp_tac 1
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   912
          THEN
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
   913
          IF_UNSOLVED (Blast.depth_tac
3650
282ffdc91884 Replacing impOfSubs analz_mono by analz_insertI should improve convergence
paulson
parents: 3583
diff changeset
   914
		       (!claset addIs [analz_insertI,
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 3650
diff changeset
   915
				       impOfSubs analz_subset_parts]) 4 1))
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   916
       ]) i);
2327
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   917
2415
46de4b035f00 New tactic: prove_unique_tac
paulson
parents: 2373
diff changeset
   918
(** Useful in many uniqueness proofs **)
2327
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   919
fun ex_strip_tac i = REPEAT (swap_res_tac [exI, conjI] i) THEN 
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   920
                     assume_tac (i+1);
00ac25b2791d Moved much common material to Message.ML
paulson
parents: 2284
diff changeset
   921
2415
46de4b035f00 New tactic: prove_unique_tac
paulson
parents: 2373
diff changeset
   922
(*Apply the EX-ALL quantifification to prove uniqueness theorems in 
46de4b035f00 New tactic: prove_unique_tac
paulson
parents: 2373
diff changeset
   923
  their standard form*)
46de4b035f00 New tactic: prove_unique_tac
paulson
parents: 2373
diff changeset
   924
fun prove_unique_tac lemma = 
46de4b035f00 New tactic: prove_unique_tac
paulson
parents: 2373
diff changeset
   925
  EVERY' [dtac lemma,
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   926
          REPEAT o (mp_tac ORELSE' eresolve_tac [asm_rl,exE]),
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   927
          (*Duplicate the assumption*)
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
   928
          forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl,
3102
4d01cdc119d2 Some blast_tac calls; more needed
paulson
parents: 2948
diff changeset
   929
          Blast.depth_tac (!claset addSDs [spec]) 0];
2415
46de4b035f00 New tactic: prove_unique_tac
paulson
parents: 2373
diff changeset
   930
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   931
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   932
(*Needed occasionally with spy_analz_tac, e.g. in analz_insert_Key_newK*)
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   933
goal Set.thy "A Un (B Un A) = B Un A";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   934
by (Blast_tac 1);
2373
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   935
val Un_absorb3 = result();
490ffa16952e Addition of the Hash constructor
paulson
parents: 2327
diff changeset
   936
Addsimps [Un_absorb3];
3514
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   937
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   938
(*By default only o_apply is built-in.  But in the presence of eta-expansion
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   939
  this means that some terms displayed as (f o g) will be rewritten, and others
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   940
  will not!*)
eb16b8e8d872 Moved some declarations to Message from Public and Shared
paulson
parents: 3476
diff changeset
   941
Addsimps [o_def];