src/HOL/Auth/Shared.ML
changeset 2045 ae1030e66745
parent 2032 1bbf1bdcaf56
child 2049 d3b93e1765bc
equal deleted inserted replaced
2044:e8d52d05530a 2045:ae1030e66745
     5 
     5 
     6 Theory of Shared Keys (common to all symmetric-key protocols)
     6 Theory of Shared Keys (common to all symmetric-key protocols)
     7 
     7 
     8 Server keys; initial states of agents; new nonces and keys; function "sees" 
     8 Server keys; initial states of agents; new nonces and keys; function "sees" 
     9 *)
     9 *)
    10 
       
    11 
       
    12 
       
    13 (****************DELETE****************)
       
    14 
       
    15 local
       
    16     fun string_of (a,0) = a
       
    17       | string_of (a,i) = a ^ "_" ^ string_of_int i;
       
    18 in
       
    19   fun freeze_thaw th =
       
    20     let val fth = freezeT th
       
    21         val {prop,sign,...} = rep_thm fth
       
    22         fun mk_inst (Var(v,T)) = 
       
    23             (cterm_of sign (Var(v,T)),
       
    24              cterm_of sign (Free(string_of v, T)))
       
    25         val insts = map mk_inst (term_vars prop)
       
    26         fun thaw th' = 
       
    27             th' |> forall_intr_list (map #2 insts)
       
    28                 |> forall_elim_list (map #1 insts)
       
    29     in  (instantiate ([],insts) fth, thaw)  end;
       
    30 end;
       
    31 fun defer_tac i state = 
       
    32     let val (state',thaw) = freeze_thaw state
       
    33         val hyps = Drule.strip_imp_prems (adjust_maxidx (cprop_of state'))
       
    34         val hyp::hyps' = drop(i-1,hyps)
       
    35     in  implies_intr hyp (implies_elim_list state' (map assume hyps)) 
       
    36         |> implies_intr_list (take(i-1,hyps) @ hyps')
       
    37         |> thaw
       
    38         |> Sequence.single
       
    39     end
       
    40     handle Bind => Sequence.null;
       
    41 
       
    42 
    10 
    43 
    11 
    44 
    12 
    45 (*GOALS.ML??*)
    13 (*GOALS.ML??*)
    46 fun prlim n = (goals_limit:=n; pr());
    14 fun prlim n = (goals_limit:=n; pr());
   130 by (agent.induct_tac "A" 1);
    98 by (agent.induct_tac "A" 1);
   131 by (Auto_tac ());
    99 by (Auto_tac ());
   132 qed_spec_mp "sees_own_shrK";
   100 qed_spec_mp "sees_own_shrK";
   133 
   101 
   134 (*Spy sees shared keys of lost agents!*)
   102 (*Spy sees shared keys of lost agents!*)
   135 goal thy "!!i. A: lost ==> Key (shrK A) : sees lost Spy evs";
   103 goal thy "!!A. A: lost ==> Key (shrK A) : sees lost Spy evs";
   136 by (list.induct_tac "evs" 1);
   104 by (list.induct_tac "evs" 1);
   137 by (Auto_tac());
   105 by (Auto_tac());
   138 qed "Spy_sees_bad";
   106 qed "Spy_sees_lost";
   139 
   107 
   140 AddSIs [sees_own_shrK, Spy_sees_bad];
   108 AddSIs [sees_own_shrK, Spy_sees_lost];
   141 
   109 
   142 
   110 
   143 (** Specialized rewrite rules for (sees lost A (Says...#evs)) **)
   111 (** Specialized rewrite rules for (sees lost A (Says...#evs)) **)
   144 
   112 
   145 goal thy "sees lost A (Says A B X # evs) = insert X (sees lost A evs)";
   113 goal thy "sees lost A (Says A B X # evs) = insert X (sees lost A evs)";
   257            IF_UNSOLVED (deepen_tac (!claset addIs [impOfSubs analz_mono]) 0 1)
   225            IF_UNSOLVED (deepen_tac (!claset addIs [impOfSubs analz_mono]) 0 1)
   258            ]) i;
   226            ]) i;
   259 
   227 
   260 
   228 
   261 (** Simplifying   parts (insert X (sees lost A evs))
   229 (** Simplifying   parts (insert X (sees lost A evs))
   262                 = parts {X} Un parts (sees lost A evs) -- since general case loops*)
   230       = parts {X} Un parts (sees lost A evs) -- since general case loops*)
   263 
   231 
   264 val parts_insert_sees = 
   232 val parts_insert_sees = 
   265     parts_insert |> read_instantiate_sg (sign_of thy) [("H", "sees lost A evs")]
   233     parts_insert |> read_instantiate_sg (sign_of thy)
       
   234                                         [("H", "sees lost A evs")]
   266                  |> standard;
   235                  |> standard;
       
   236 
       
   237 
       
   238 (** Specialized rewriting for  **)
       
   239 
       
   240 Delsimps [image_insert];
       
   241 Addsimps [image_insert RS sym];
       
   242 
       
   243 Delsimps [image_Un];
       
   244 Addsimps [image_Un RS sym];
       
   245 
       
   246 goal thy "insert (Key (newK x)) H = Key `` (newK``{x}) Un H";
       
   247 by (Fast_tac 1);
       
   248 qed "insert_Key_singleton";
       
   249 
       
   250 goal thy "insert (Key (f x)) (Key``(f``E) Un C) = \
       
   251 \         Key `` (f `` (insert x E)) Un C";
       
   252 by (Fast_tac 1);
       
   253 qed "insert_Key_image";
       
   254 
       
   255 
       
   256 (*Lemma for the trivial direction of the if-and-only-if*)
       
   257 goal thy  
       
   258  "!!evs. (Key K : analz (Key``nE Un H)) --> (K : nE | Key K : analz H)  ==> \
       
   259 \        (Key K : analz (Key``nE Un H)) = (K : nE | Key K : analz H)";
       
   260 by (fast_tac (!claset addSEs [impOfSubs analz_mono]) 1);
       
   261 qed "analz_image_newK_lemma";
       
   262 
       
   263