src/HOL/Auth/Public.ML
author sandnerr
Fri, 13 Dec 1996 12:01:26 +0100
changeset 2380 90280b3a538b
parent 2318 6d3f7c7f70b0
child 2451 ce85a2aafc7a
permissions -rw-r--r--
Dummy change to document the change in revision 1.5: Parent theory changed to HOLCF.thy (former Tr2.thy) . Was necessary because the use of HOLCF_ss in Hoare.ML, which has been extended by the introduction of the Lift theories.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/Public
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     2
    ID:         $Id$
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     5
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     6
Theory of Public Keys (common to all symmetric-key protocols)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     7
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     8
Server keys; initial states of agents; new nonces and keys; function "sees" 
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     9
*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    10
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    11
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    12
open Public;
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    13
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    14
(*Holds because Friend is injective: thus cannot prove for all f*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    15
goal thy "(Friend x : Friend``A) = (x:A)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    16
by (Auto_tac());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    17
qed "Friend_image_eq";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    18
Addsimps [Friend_image_eq];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    19
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    20
Addsimps [Un_insert_left, Un_insert_right];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    21
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    22
(*By default only o_apply is built-in.  But in the presence of eta-expansion
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    23
  this means that some terms displayed as (f o g) will be rewritten, and others
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    24
  will not!*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    25
Addsimps [o_def];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    26
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    27
(*** Basic properties of pubK ***)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    28
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    29
(*Injectiveness and freshness of new keys and nonces*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    30
AddIffs [inj_pubK RS inj_eq];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    31
AddSDs  [newN_length];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    32
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    33
(** Rewrites should not refer to  initState(Friend i) 
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    34
    -- not in normal form! **)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    35
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    36
Addsimps [priK_neq_pubK, priK_neq_pubK RS not_sym];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    37
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    38
goal thy "Nonce (newN evs) ~: parts (initState lost B)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    39
by (agent.induct_tac "B" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    40
by (Auto_tac ());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    41
qed "newN_notin_initState";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    42
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    43
AddIffs [newN_notin_initState];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    44
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    45
goalw thy [keysFor_def] "keysFor (parts (initState lost C)) = {}";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    46
by (agent.induct_tac "C" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    47
by (auto_tac (!claset addIs [range_eqI], !simpset));
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    48
qed "keysFor_parts_initState";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    49
Addsimps [keysFor_parts_initState];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    50
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    51
goalw thy [keysFor_def] "keysFor (Key``E) = {}";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    52
by (Auto_tac ());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    53
qed "keysFor_image_Key";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    54
Addsimps [keysFor_image_Key];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    55
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    56
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    57
(*** Function "sees" ***)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    58
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    59
goal thy
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    60
    "!!evs. lost' <= lost ==> sees lost' A evs <= sees lost A evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    61
by (list.induct_tac "evs" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    62
by (agent.induct_tac "A" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    63
by (event.induct_tac "a" 2);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    64
by (Auto_tac ());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    65
qed "sees_mono";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    66
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    67
(*Agents see their own private keys!*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    68
goal thy "A ~= Spy --> Key (priK A) : sees lost A evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    69
by (list.induct_tac "evs" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    70
by (agent.induct_tac "A" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    71
by (Auto_tac ());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    72
qed_spec_mp "sees_own_priK";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    73
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    74
(*All public keys are visible*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    75
goal thy "Key (pubK A) : sees lost A evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    76
by (list.induct_tac "evs" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    77
by (agent.induct_tac "A" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    78
by (Auto_tac ());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    79
qed_spec_mp "sees_pubK";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    80
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    81
(*Spy sees private keys of lost agents!*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    82
goal thy "!!A. A: lost ==> Key (priK A) : sees lost Spy evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    83
by (list.induct_tac "evs" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    84
by (Auto_tac());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    85
qed "Spy_sees_lost";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    86
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    87
AddIffs [sees_pubK];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    88
AddSIs  [sees_own_priK, Spy_sees_lost];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    89
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    90
(*Added for Yahalom/lost_tac*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    91
goal thy "!!A. [| Crypt (pubK A) X : analz (sees lost Spy evs);  A: lost |] \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    92
\              ==> X : analz (sees lost Spy evs)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    93
by (fast_tac (!claset addSDs [analz.Decrypt] addss (!simpset)) 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    94
qed "Crypt_Spy_analz_lost";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    95
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    96
(** Specialized rewrite rules for (sees lost A (Says...#evs)) **)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    97
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    98
goal thy "sees lost B (Says A B X # evs) = insert X (sees lost B evs)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    99
by (Simp_tac 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   100
qed "sees_own";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   101
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   102
goal thy "!!A. Server ~= B ==> \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   103
\          sees lost Server (Says A B X # evs) = sees lost Server evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   104
by (Asm_simp_tac 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   105
qed "sees_Server";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   106
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   107
goal thy "!!A. Friend i ~= B ==> \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   108
\          sees lost (Friend i) (Says A B X # evs) = sees lost (Friend i) evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   109
by (Asm_simp_tac 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   110
qed "sees_Friend";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   111
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   112
goal thy "sees lost Spy (Says A B X # evs) = insert X (sees lost Spy evs)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   113
by (Simp_tac 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   114
qed "sees_Spy";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   115
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   116
goal thy "sees lost A (Says A' B X # evs) <= insert X (sees lost A evs)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   117
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   118
by (Fast_tac 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   119
qed "sees_Says_subset_insert";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   120
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   121
goal thy "sees lost A evs <= sees lost A (Says A' B X # evs)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   122
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   123
by (Fast_tac 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   124
qed "sees_subset_sees_Says";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   125
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   126
(*Pushing Unions into parts.  One of the agents A is B, and thus sees Y.
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   127
  Once used to prove new_keys_not_seen; now obsolete.*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   128
goal thy "(UN A. parts (sees lost A (Says B C Y # evs))) = \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   129
\         parts {Y} Un (UN A. parts (sees lost A evs))";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   130
by (Step_tac 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   131
by (etac rev_mp 1);     (*split_tac does not work on assumptions*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   132
by (ALLGOALS
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   133
    (fast_tac (!claset addss (!simpset addsimps [parts_Un, sees_Cons] 
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   134
                       setloop split_tac [expand_if]))));
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   135
qed "UN_parts_sees_Says";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   136
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   137
goal thy "Says A B X : set_of_list evs --> X : sees lost Spy evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   138
by (list.induct_tac "evs" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   139
by (Auto_tac ());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   140
qed_spec_mp "Says_imp_sees_Spy";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   141
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   142
goal thy  
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   143
 "!!evs. [| Says A B (Crypt (pubK C) X) : set_of_list evs;  C : lost |] \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   144
\        ==> X : analz (sees lost Spy evs)";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   145
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   146
                      addss (!simpset)) 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   147
qed "Says_Crypt_lost";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   148
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   149
goal thy  
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   150
 "!!evs. [| Says A B (Crypt (pubK C) X) : set_of_list evs;        \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   151
\           X ~: analz (sees lost Spy evs) |]                     \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   152
\        ==> C ~: lost";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   153
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   154
                      addss (!simpset)) 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   155
qed "Says_Crypt_not_lost";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   156
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   157
Addsimps [sees_own, sees_Server, sees_Friend, sees_Spy];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   158
Delsimps [sees_Cons];   (**** NOTE REMOVAL -- laws above are cleaner ****)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   159
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   160
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   161
(** Power of the Spy **)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   162
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   163
(*The Spy can see more than anybody else, except for their initial state*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   164
goal thy "sees lost A evs <= initState lost A Un sees lost Spy evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   165
by (list.induct_tac "evs" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   166
by (event.induct_tac "a" 2);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   167
by (ALLGOALS (fast_tac (!claset addDs [sees_Says_subset_insert RS subsetD] 
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   168
                                addss (!simpset))));
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   169
qed "sees_agent_subset_sees_Spy";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   170
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   171
(*The Spy can see more than anybody else who's lost their key!*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   172
goal thy "A: lost --> A ~= Server --> sees lost A evs <= sees lost Spy evs";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   173
by (list.induct_tac "evs" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   174
by (event.induct_tac "a" 2);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   175
by (agent.induct_tac "A" 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   176
by (auto_tac (!claset addDs [sees_Says_subset_insert RS subsetD], (!simpset)));
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   177
qed_spec_mp "sees_lost_agent_subset_sees_Spy";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   178
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   179
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   180
(** Simplifying   parts (insert X (sees lost A evs))
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   181
      = parts {X} Un parts (sees lost A evs) -- since general case loops*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   182
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   183
val parts_insert_sees = 
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   184
    parts_insert |> read_instantiate_sg (sign_of thy)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   185
                                        [("H", "sees lost A evs")]
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   186
                 |> standard;