src/HOL/Auth/NS_Shared.ML
author paulson
Thu, 26 Sep 1996 12:50:48 +0200
changeset 2032 1bbf1bdcaf56
parent 2027 0f11f625063b
child 2045 ae1030e66745
permissions -rw-r--r--
Introduction of "lost" argument Changed Enemy -> Spy Ran expandshort
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/NS_Shared
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     2
    ID:         $Id$
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     5
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     6
Inductive relation "ns_shared" for Needham-Schroeder Shared-Key protocol.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     7
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     8
From page 247 of
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    10
  Proc. Royal Soc. 426 (1989)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    11
*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    12
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    13
open NS_Shared;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    14
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    15
proof_timing:=true;
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    16
HOL_quantifiers := false;
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    17
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    18
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
    19
(*Weak liveness: there are traces that reach the end*)
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    20
goal thy 
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    21
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    22
\        ==> EX N K. EX evs: ns_shared lost.          \
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    23
\               Says A B (Crypt {|Nonce N, Nonce N|} K) : set_of_list evs";
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    24
by (REPEAT (resolve_tac [exI,bexI] 1));
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    25
by (rtac (ns_shared.Nil RS ns_shared.NS1 RS ns_shared.NS2 RS ns_shared.NS3 RS ns_shared.NS4 RS ns_shared.NS5) 2);
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    26
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    27
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    28
by (ALLGOALS (fast_tac (!claset addss (!simpset setsolver safe_solver))));
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
    29
result();
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
    30
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    31
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    32
(**** Inductive proofs about ns_shared ****)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    33
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    34
goal thy "!!evs. lost' <= lost ==> ns_shared lost' <= ns_shared lost";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    35
by (rtac subsetI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    36
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    37
by (REPEAT_FIRST
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    38
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    39
                              :: ns_shared.intrs))));
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    40
qed "ns_shared_mono";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    41
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    42
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    43
(*The Spy can see more than anybody else, except for their initial state*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    44
goal thy 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    45
 "!!evs. evs : ns_shared lost ==> \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    46
\     sees lost A evs <= initState lost A Un sees lost Spy evs";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    47
by (etac ns_shared.induct 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    48
by (ALLGOALS (fast_tac (!claset addDs [sees_Says_subset_insert RS subsetD] 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    49
                                addss (!simpset))));
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    50
qed "sees_agent_subset_sees_Spy";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    51
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    52
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    53
(*The Spy can see more than anybody else who's lost their key!*)
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    54
goal thy 
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    55
 "!!evs. evs : ns_shared lost ==> \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    56
\        A: lost --> A ~= Server --> sees lost A evs <= sees lost Spy evs";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    57
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    58
by (agent.induct_tac "A" 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    59
by (auto_tac (!claset addDs [sees_Says_subset_insert RS subsetD], (!simpset)));
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    60
qed_spec_mp "sees_lost_agent_subset_sees_Spy";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    61
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    62
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    63
(*Nobody sends themselves messages*)
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    64
goal thy "!!evs. evs : ns_shared lost ==> ALL A X. Says A A X ~: set_of_list evs";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    65
by (etac ns_shared.induct 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    66
by (Auto_tac());
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    67
qed_spec_mp "not_Says_to_self";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    68
Addsimps [not_Says_to_self];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    69
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    70
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    71
(*For reasoning about the encrypted portion of message NS3*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    72
goal thy "!!evs. (Says S A (Crypt {|N, B, K, X|} KA)) : set_of_list evs ==> \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    73
\                X : parts (sees lost Spy evs)";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    74
by (fast_tac (!claset addSEs partsEs
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    75
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    76
qed "NS3_msg_in_parts_sees_Spy";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    77
                              
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    78
val parts_Fake_tac = 
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    79
    dres_inst_tac [("lost","lost")] NS3_msg_in_parts_sees_Spy 5;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    80
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    81
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
    82
    sends messages containing X! **)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    83
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    84
(*Spy never sees lost another agent's shared key!*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    85
goal thy 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    86
 "!!evs. [| evs : ns_shared lost; A ~: lost |]    \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    87
\        ==> Key (shrK A) ~: parts (sees lost Spy evs)";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    88
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    89
by parts_Fake_tac;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    90
by (Auto_tac());
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    91
(*Deals with Fake message*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    92
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    93
                             impOfSubs Fake_parts_insert]) 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    94
qed "Spy_not_see_shrK";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    95
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    96
bind_thm ("Spy_not_analz_shrK",
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    97
          [analz_subset_parts, Spy_not_see_shrK] MRS contra_subsetD);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    98
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
    99
Addsimps [Spy_not_see_shrK, Spy_not_analz_shrK];
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   100
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   101
(*We go to some trouble to preserve R in the 3rd and 4th subgoals
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   102
  As usual fast_tac cannot be used because it uses the equalities too soon*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   103
val major::prems = 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   104
goal thy  "[| Key (shrK A) : parts (sees lost Spy evs);       \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   105
\             evs : ns_shared lost;                             \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   106
\             A:lost ==> R                                  \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   107
\           |] ==> R";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   108
by (rtac ccontr 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   109
by (rtac ([major, Spy_not_see_shrK] MRS rev_notE) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   110
by (swap_res_tac prems 2);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   111
by (ALLGOALS (fast_tac (!claset addIs prems)));
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   112
qed "Spy_see_shrK_E";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   113
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   114
bind_thm ("Spy_analz_shrK_E", 
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   115
          analz_subset_parts RS subsetD RS Spy_see_shrK_E);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   116
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   117
AddSEs [Spy_see_shrK_E, Spy_analz_shrK_E];
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   118
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   119
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   120
goal thy  
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   121
 "!!evs. evs : ns_shared lost ==>                              \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   122
\        (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
2027
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   123
by (best_tac (!claset addIs [impOfSubs (subset_insertI RS analz_mono)]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   124
                      addss (!simpset)) 1);
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   125
qed "shrK_mem_analz";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   126
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   127
Addsimps [shrK_mem_analz];
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   128
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   129
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   130
(*** Future keys can't be seen or used! ***)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   131
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   132
(*Nobody can have SEEN keys that will be generated in the future.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   133
  This has to be proved anew for each protocol description,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   134
  but should go by similar reasoning every time.  Hardest case is the
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   135
  standard Fake rule.  
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   136
      The length comparison, and Union over C, are essential for the 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   137
  induction! *)
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   138
goal thy "!!evs. evs : ns_shared lost ==> \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   139
\                length evs <= length evs' --> \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   140
\                          Key (newK evs') ~: (UN C. parts (sees lost C evs))";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   141
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   142
by parts_Fake_tac;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   143
(*auto_tac does not work here, as it performs safe_tac first*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   144
by (ALLGOALS Asm_simp_tac);
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   145
by (ALLGOALS (fast_tac (!claset addDs [impOfSubs analz_subset_parts,
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   146
                                       impOfSubs parts_insert_subset_Un,
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   147
                                       Suc_leD]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   148
                                addss (!simpset))));
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   149
val lemma = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   150
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   151
(*Variant needed for the main theorem below*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   152
goal thy 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   153
 "!!evs. [| evs : ns_shared lost;  length evs <= length evs' |]    \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   154
\        ==> Key (newK evs') ~: parts (sees lost C evs)";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   155
by (fast_tac (!claset addDs [lemma]) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   156
qed "new_keys_not_seen";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   157
Addsimps [new_keys_not_seen];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   158
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   159
(*Another variant: old messages must contain old keys!*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   160
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   161
 "!!evs. [| Says A B X : set_of_list evs;  \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   162
\           Key (newK evt) : parts {X};    \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   163
\           evs : ns_shared lost                 \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   164
\        |] ==> length evt < length evs";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   165
by (rtac ccontr 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   166
by (dtac leI 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   167
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   168
                      addIs  [impOfSubs parts_mono]) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   169
qed "Says_imp_old_keys";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   170
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   171
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   172
(*Nobody can have USED keys that will be generated in the future.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   173
  ...very like new_keys_not_seen*)
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   174
goal thy "!!evs. evs : ns_shared lost ==> \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   175
\                length evs <= length evs' --> \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   176
\                newK evs' ~: keysFor (UN C. parts (sees lost C evs))";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   177
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   178
by parts_Fake_tac;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   179
by (ALLGOALS Asm_simp_tac);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   180
(*NS1 and NS2*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   181
map (by o fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [3,2];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   182
(*Fake and NS3*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   183
map (by o best_tac
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
   184
     (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
2027
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   185
                     impOfSubs (parts_insert_subset_Un RS keysFor_mono),
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   186
                     Suc_leD]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   187
              addEs [new_keys_not_seen RS not_parts_not_analz RSN (2,rev_notE)]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   188
              addss (!simpset)))
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   189
    [2,1];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   190
(*NS4 and NS5: nonce exchange*)
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
   191
by (ALLGOALS (deepen_tac (!claset addSDs [Says_imp_old_keys]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   192
                                  addIs  [less_SucI, impOfSubs keysFor_mono]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   193
                                  addss (!simpset addsimps [le_def])) 0));
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   194
val lemma = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   195
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   196
goal thy 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   197
 "!!evs. [| evs : ns_shared lost;  length evs <= length evs' |]    \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   198
\        ==> newK evs' ~: keysFor (parts (sees lost C evs))";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   199
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   200
qed "new_keys_not_used";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   201
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   202
bind_thm ("new_keys_not_analzd",
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   203
          [analz_subset_parts RS keysFor_mono,
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   204
           new_keys_not_used] MRS contra_subsetD);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   205
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   206
Addsimps [new_keys_not_used, new_keys_not_analzd];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   207
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   208
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   209
(** Lemmas concerning the form of items passed in messages **)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   210
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   211
(*Describes the form of K, X and K' when the Server sends this message.*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   212
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   213
 "!!evs. [| Says Server A (Crypt {|N, Agent B, K, X|} K') : set_of_list evs; \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   214
\           evs : ns_shared lost |]    \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   215
\        ==> (EX evt: ns_shared lost. \
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   216
\                  K = Key(newK evt) & \
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   217
\                  X = (Crypt {|K, Agent A|} (shrK B)) & \
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   218
\                  K' = shrK A)";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   219
by (etac rev_mp 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   220
by (etac ns_shared.induct 1);
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   221
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   222
qed "Says_Server_message_form";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   223
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   224
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   225
(*Describes the form of X when the following message is sent.  The use of
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   226
  "parts" strengthens the induction hyp for proving the Fake case.  The
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   227
  assumptions on A are needed to prevent its being a Faked message.*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   228
goal thy
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   229
 "!!evs. evs : ns_shared lost ==>                                         \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   230
\            Crypt {|Nonce NA, Agent B, Key K, X|} (shrK A)               \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   231
\               : parts (sees lost Spy evs) &                           \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   232
\            A ~: lost -->                                                \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   233
\          (EX evt: ns_shared lost. K = newK evt & \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   234
\                             X = (Crypt {|Key K, Agent A|} (shrK B)))";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   235
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   236
by parts_Fake_tac;
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   237
(*Fake case*)
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   238
by (best_tac (!claset addSDs [impOfSubs Fake_parts_insert]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   239
                      addDs  [impOfSubs analz_subset_parts]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   240
                      addss  (!simpset)) 2);
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   241
by (Auto_tac());
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   242
val lemma = result() RS mp;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   243
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   244
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   245
(*The following theorem is proved by cases.  If the message was sent with a
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   246
  bad key then the Spy reads it -- even if he didn't send it in the first
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   247
  place.*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   248
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   249
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   250
(*EITHER describes the form of X when the following message is sent, 
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   251
  OR     reduces it to the Fake case.
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   252
  Use Says_Server_message_form if applicable.*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   253
goal thy 
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   254
 "!!evs. [| Says S A (Crypt {|Nonce NA, Agent B, Key K, X|} (shrK A))    \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   255
\            : set_of_list evs;  evs : ns_shared lost |]                      \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   256
\        ==> (EX evt: ns_shared lost. K = newK evt & length evt < length evs & \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   257
\                               X = (Crypt {|Key K, Agent A|} (shrK B))) | \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   258
\            X : analz (sees lost Spy evs)";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   259
by (excluded_middle_tac "A : lost" 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   260
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   261
                      addss (!simpset)) 2);
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   262
by (forward_tac [lemma] 1);
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   263
by (fast_tac (!claset addEs  partsEs
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   264
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   265
by (fast_tac (!claset addIs [Says_imp_old_keys] addss (!simpset)) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   266
qed "Says_S_message_form";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   267
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   268
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   269
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   270
(****
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   271
 The following is to prove theorems of the form
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   272
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   273
          Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) ==>
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   274
          Key K : analz (sees lost Spy evs)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   275
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   276
 A more general formula must be proved inductively.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   277
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   278
****)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   279
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   280
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   281
(*NOT useful in this form, but it says that session keys are not used
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   282
  to encrypt messages containing other keys, in the actual protocol.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   283
  We require that agents should behave like this subsequently also.*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   284
goal thy 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   285
 "!!evs. evs : ns_shared lost ==> \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   286
\        (Crypt X (newK evt)) : parts (sees lost Spy evs) & \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   287
\        Key K : parts {X} --> Key K : parts (sees lost Spy evs)";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   288
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   289
by parts_Fake_tac;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   290
by (ALLGOALS (asm_simp_tac (!simpset addsimps pushes)));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   291
(*Deals with Faked messages*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   292
by (best_tac (!claset addSEs partsEs
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   293
                      addDs [impOfSubs parts_insert_subset_Un]
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   294
                      addss (!simpset)) 2);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   295
(*Base, NS4 and NS5*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   296
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   297
result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   298
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   299
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   300
(** Specialized rewriting for this proof **)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   301
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   302
Delsimps [image_insert];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   303
Addsimps [image_insert RS sym];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   304
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   305
Delsimps [image_Un];
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   306
Addsimps [image_Un RS sym];
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   307
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   308
goal thy "insert (Key (newK x)) (sees lost A evs) = \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   309
\         Key `` (newK``{x}) Un (sees lost A evs)";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   310
by (Fast_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   311
val insert_Key_singleton = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   312
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   313
goal thy "insert (Key (f x)) (Key``(f``E) Un C) = \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   314
\         Key `` (f `` (insert x E)) Un C";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   315
by (Fast_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   316
val insert_Key_image = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   317
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   318
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   319
(** Session keys are not used to encrypt other session keys **)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   320
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   321
(*Lemma for the trivial direction of the if-and-only-if*)
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   322
goal thy  
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   323
 "!!evs. (Key K : analz (Key``nE Un sEe)) --> \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   324
\         (K : nE | Key K : analz sEe)  ==>     \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   325
\        (Key K : analz (Key``nE Un sEe)) = (K : nE | Key K : analz sEe)";
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   326
by (fast_tac (!claset addSEs [impOfSubs analz_mono]) 1);
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   327
val lemma = result();
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   328
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   329
(*The equality makes the induction hypothesis easier to apply*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   330
goal thy  
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   331
 "!!evs. evs : ns_shared lost ==> \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   332
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees lost Spy evs))) = \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   333
\           (K : newK``E | Key K : analz (sees lost Spy evs))";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   334
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   335
by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);     
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   336
by (REPEAT ((eresolve_tac [bexE, conjE, disjE] ORELSE' hyp_subst_tac) 5));
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   337
by (REPEAT_FIRST (resolve_tac [allI, lemma]));
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   338
by (ALLGOALS 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   339
    (asm_simp_tac 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   340
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   341
                         @ pushes)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   342
               setloop split_tac [expand_if])));
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   343
(** LEVEL 5 **)
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   344
(*NS3, Fake subcase*)
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   345
by (spy_analz_tac 5);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   346
(*Cases NS2 and NS3!!  Simple, thanks to auto case splits*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   347
by (REPEAT (Fast_tac 3));
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   348
(*Fake case*) (** LEVEL 7 **)
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   349
by (spy_analz_tac 2);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   350
(*Base case*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   351
by (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   352
qed_spec_mp "analz_image_newK";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   353
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   354
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   355
goal thy
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   356
 "!!evs. evs : ns_shared lost ==>                               \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   357
\        Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) = \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   358
\        (K = newK evt | Key K : analz (sees lost Spy evs))";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   359
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   360
                                   insert_Key_singleton]) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   361
by (Fast_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   362
qed "analz_insert_Key_newK";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   363
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   364
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   365
(** The session key K uniquely identifies the message, if encrypted
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   366
    with a secure key **)
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   367
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   368
fun ex_strip_tac i = REPEAT (ares_tac [exI, conjI] i) THEN assume_tac (i+1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   369
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   370
goal thy 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   371
 "!!evs. evs : ns_shared lost ==>                             \
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   372
\      EX X'. ALL A X N B.                               \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   373
\       A ~: lost -->                                     \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   374
\       Crypt {|N, Agent B, Key K, X|} (shrK A) : parts (sees lost Spy evs) --> \
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   375
\       X=X'";
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   376
by (Simp_tac 1);        (*Miniscoping*)
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   377
by (etac ns_shared.induct 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   378
by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);     
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   379
by (ALLGOALS 
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   380
    (asm_simp_tac (!simpset addsimps [all_conj_distrib, ex_disj_distrib,
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   381
                                      imp_conj_distrib, parts_insert_sees])));
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   382
by (REPEAT_FIRST (eresolve_tac [exE,disjE]));
2027
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   383
(*NS2: Cextraction of K = newK evsa to global context...*) 
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   384
(** LEVEL 5 **)
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   385
by (excluded_middle_tac "K = newK evsa" 3);
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   386
by (Asm_simp_tac 3);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   387
by (etac exI 3);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   388
(*...we assume X is a very new message, and handle this case by contradiction*)
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   389
by (fast_tac (!claset addSEs partsEs
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   390
                      addEs [Says_imp_old_keys RS less_irrefl]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   391
                      addss (!simpset)) 3);
2027
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   392
(*Base, Fake, NS3*) (** LEVEL 9 **)
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   393
by (REPEAT_FIRST ex_strip_tac);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   394
by (dtac synth.Inj 4);
2027
0f11f625063b Last working version before "lost"
paulson
parents: 2015
diff changeset
   395
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs Fake_parts_insert]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   396
                                    addss (!simpset))));
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   397
val lemma = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   398
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   399
(*In messages of this form, the session key uniquely identifies the rest*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   400
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   401
 "!!evs. [| Says S A          \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   402
\             (Crypt {|N, Agent B, Key K, X|} (shrK C))     \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   403
\                  : set_of_list evs; \ 
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   404
\           Says S' A'                                         \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   405
\             (Crypt {|N', Agent B', Key K, X'|} (shrK C')) \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   406
\                  : set_of_list evs;                         \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   407
\           evs : ns_shared lost;  C ~: lost;  C' ~: lost |] ==> X = X'";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   408
by (dtac lemma 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   409
by (etac exE 1);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   410
(*Duplicate the assumption*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   411
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   412
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   413
qed "unique_session_keys";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   414
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   415
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   416
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   417
(** Crucial secrecy property: Spy does not see the keys sent in msg NS2 **)
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   418
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   419
goal thy 
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   420
 "!!evs. [| A ~: lost;  B ~: lost;  \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   421
\           evs : ns_shared lost;  evt: ns_shared lost |]  \
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   422
\        ==> Says Server A                                             \
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   423
\              (Crypt {|N, Agent B, Key(newK evt),                     \
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   424
\                       Crypt {|Key(newK evt), Agent A|} (shrK B)|} (shrK A)) \
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   425
\             : set_of_list evs --> \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   426
\        Key(newK evt) ~: analz (sees lost Spy evs)";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   427
by (etac ns_shared.induct 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   428
by (ALLGOALS 
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   429
    (asm_simp_tac 
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   430
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   431
                          analz_insert_Key_newK] @ pushes)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   432
               setloop split_tac [expand_if])));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   433
(*NS2*)
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   434
by (fast_tac (!claset addIs [parts_insertI]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   435
                      addEs [Says_imp_old_keys RS less_irrefl]
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   436
                      addss (!simpset)) 2);
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   437
(*Fake case*)
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   438
by (spy_analz_tac 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   439
(*NS3: that message from the Server was sent earlier*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   440
by (forward_tac [Says_S_message_form] 1 THEN assume_tac 1);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   441
by (Step_tac 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   442
by (REPEAT_FIRST assume_tac);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   443
by (spy_analz_tac 2);           (*Prove the Fake subcase*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   444
by (asm_full_simp_tac
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   445
    (!simpset addsimps (mem_if::analz_insert_Key_newK::pushes)) 1);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   446
by (Step_tac 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   447
(**LEVEL 10 **)
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   448
by (excluded_middle_tac "Aa : lost" 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   449
(*But this contradicts Key(newK evt) ~: analz (sees lost Spy evsa) *)
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   450
by (dtac (Says_imp_sees_Spy RS analz.Inj) 2);
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   451
by (fast_tac (!claset addSDs [analz.Decrypt]
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   452
                      addss (!simpset)) 2);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   453
(*So now we have  Aa ~: lost *)
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   454
by (dtac unique_session_keys 1);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   455
by (Auto_tac ());
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   456
val lemma = result() RS mp RSN(2,rev_notE);
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   457
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   458
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   459
(*Final version: Server's message in the most abstract form*)
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   460
goal thy 
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   461
 "!!evs. [| Says Server A                                                \
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   462
\            (Crypt {|N, Agent B, K, X|} K') : set_of_list evs;          \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   463
\           A ~: lost;  B ~: lost;  evs : ns_shared lost                        \
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   464
\        |] ==>                                                          \
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   465
\     K ~: analz (sees lost Spy evs)";
2015
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   466
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
d4a8fd8a8065 Simplification of proof of unique_session_keys
paulson
parents: 1999
diff changeset
   467
by (fast_tac (!claset addSEs [lemma]) 1);
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   468
qed "Spy_not_see_encrypted_key";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   469
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   470
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   471
goal thy 
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   472
 "!!evs. [| C ~: {A,B,Server}; \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   473
\           Says Server A                                                \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   474
\            (Crypt {|N, Agent B, K, X|} K') : set_of_list evs;          \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   475
\           A ~: lost;  B ~: lost;  evs : ns_shared lost |]                  \
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   476
\        ==> K ~: analz (sees lost C evs)";
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   477
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   478
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   479
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   480
by (REPEAT_FIRST (fast_tac (!claset addIs [ns_shared_mono RS subsetD])));
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2027
diff changeset
   481
qed "Agent_not_see_encrypted_key";