src/HOL/Auth/Smartcard/Smartcard.thy
author wenzelm
Wed Dec 29 17:34:41 2010 +0100 (2010-12-29)
changeset 41413 64cd30d6b0b8
parent 39246 9e58f0499f57
child 41774 13b97824aec6
permissions -rw-r--r--
explicit file specifications -- avoid secondary load path;
haftmann@32631
     1
(* Author:     Giampaolo Bella, Catania University
paulson@18886
     2
*)
paulson@18886
     3
paulson@18886
     4
header{*Theory of smartcards*}
paulson@18886
     5
haftmann@32631
     6
theory Smartcard
wenzelm@41413
     7
imports EventSC "../All_Symmetric"
haftmann@32631
     8
begin
paulson@18886
     9
paulson@18886
    10
text{*  
paulson@18886
    11
As smartcards handle long-term (symmetric) keys, this theoy extends and 
paulson@18886
    12
supersedes theory Private.thy
paulson@18886
    13
paulson@18886
    14
An agent is bad if she reveals her PIN to the spy, not the shared key that
paulson@18886
    15
is embedded in her card. An agent's being bad implies nothing about her 
paulson@18886
    16
smartcard, which independently may be stolen or cloned.
paulson@18886
    17
*}
paulson@18886
    18
paulson@18886
    19
consts
paulson@18886
    20
  shrK    :: "agent => key"  (*long-term keys saved in smart cards*)
paulson@18886
    21
  crdK    :: "card  => key"  (*smart cards' symmetric keys*)
paulson@18886
    22
  pin     :: "agent => key"  (*pin to activate the smart cards*)
paulson@18886
    23
paulson@18886
    24
  (*Mostly for Shoup-Rubin*)
paulson@18886
    25
  Pairkey :: "agent * agent => nat"
paulson@18886
    26
  pairK   :: "agent * agent => key"
paulson@18886
    27
paulson@18886
    28
axioms
paulson@18886
    29
  inj_shrK: "inj shrK"  --{*No two smartcards store the same key*}
paulson@18886
    30
  inj_crdK: "inj crdK"  --{*Nor do two cards*}
paulson@18886
    31
  inj_pin : "inj pin"   --{*Nor do two agents have the same pin*}
paulson@18886
    32
paulson@18886
    33
  (*pairK is injective on each component, if we assume encryption to be a PRF
paulson@18886
    34
    or at least collision free *)
paulson@18886
    35
  inj_pairK    [iff]: "(pairK(A,B) = pairK(A',B')) = (A = A' & B = B')"
paulson@18886
    36
  comm_Pairkey [iff]: "Pairkey(A,B) = Pairkey(B,A)"
paulson@18886
    37
paulson@18886
    38
  (*long-term keys differ from each other*)
paulson@18886
    39
  pairK_disj_crdK [iff]: "pairK(A,B) \<noteq> crdK C"
paulson@18886
    40
  pairK_disj_shrK [iff]: "pairK(A,B) \<noteq> shrK P"
paulson@18886
    41
  pairK_disj_pin [iff]:  "pairK(A,B) \<noteq> pin P"
paulson@18886
    42
  shrK_disj_crdK [iff]:  "shrK P \<noteq> crdK C"
paulson@18886
    43
  shrK_disj_pin [iff]:  "shrK P \<noteq> pin Q"
paulson@18886
    44
  crdK_disj_pin [iff]:   "crdK C \<noteq> pin P"
paulson@18886
    45
haftmann@35416
    46
definition legalUse :: "card => bool" ("legalUse (_)") where
paulson@18886
    47
  "legalUse C == C \<notin> stolen"
paulson@18886
    48
haftmann@35416
    49
primrec illegalUse :: "card  => bool" where
haftmann@35416
    50
  illegalUse_def: "illegalUse (Card A) = ( (Card A \<in> stolen \<and> A \<in> bad)  \<or>  Card A \<in> cloned )"
paulson@18886
    51
paulson@18886
    52
paulson@18886
    53
text{*initState must be defined with care*}
haftmann@39246
    54
haftmann@39246
    55
overloading
haftmann@39246
    56
  initState \<equiv> initState
haftmann@39246
    57
begin
haftmann@39246
    58
haftmann@39246
    59
primrec initState where
paulson@18886
    60
(*Server knows all long-term keys; adding cards' keys may be redundant but
paulson@18886
    61
  helps prove crdK_in_initState and crdK_in_used to distinguish cards' keys
paulson@18886
    62
  from fresh (session) keys*)
paulson@18886
    63
  initState_Server:  "initState Server = 
paulson@18886
    64
        (Key`(range shrK \<union> range crdK \<union> range pin \<union> range pairK)) \<union> 
haftmann@39246
    65
        (Nonce`(range Pairkey))" |
paulson@18886
    66
paulson@18886
    67
(*Other agents know only their own*)
haftmann@39246
    68
  initState_Friend:  "initState (Friend i) = {Key (pin (Friend i))}" |
paulson@18886
    69
paulson@18886
    70
(*Spy knows bad agents' pins, cloned cards' keys, pairKs, and Pairkeys *)
paulson@18886
    71
  initState_Spy: "initState Spy  = 
paulson@18886
    72
                 (Key`((pin`bad) \<union> (pin `{A. Card A \<in> cloned}) \<union> 
paulson@18886
    73
                                      (shrK`{A. Card A \<in> cloned}) \<union> 
paulson@18886
    74
                        (crdK`cloned) \<union> 
paulson@18886
    75
                        (pairK`{(X,A). Card A \<in> cloned})))
paulson@18886
    76
           \<union> (Nonce`(Pairkey`{(A,B). Card A \<in> cloned & Card B \<in> cloned}))"
paulson@18886
    77
haftmann@39246
    78
end
paulson@18886
    79
paulson@18886
    80
text{*Still relying on axioms*}
paulson@18886
    81
axioms
paulson@18886
    82
  Key_supply_ax:  "finite KK \<Longrightarrow> \<exists> K. K \<notin> KK & Key K \<notin> used evs"
paulson@18886
    83
paulson@18886
    84
  (*Needed because of Spy's knowledge of Pairkeys*)
paulson@18886
    85
  Nonce_supply_ax: "finite NN \<Longrightarrow> \<exists> N. N \<notin> NN & Nonce N \<notin> used evs"
paulson@18886
    86
paulson@18886
    87
paulson@18886
    88
paulson@18886
    89
paulson@18886
    90
paulson@18886
    91
paulson@18886
    92
paulson@18886
    93
subsection{*Basic properties of shrK*}
paulson@18886
    94
paulson@18886
    95
(*Injectiveness: Agents' long-term keys are distinct.*)
paulson@18886
    96
declare inj_shrK [THEN inj_eq, iff]
paulson@18886
    97
declare inj_crdK [THEN inj_eq, iff]
paulson@18886
    98
declare inj_pin  [THEN inj_eq, iff]
paulson@18886
    99
paulson@18886
   100
lemma invKey_K [simp]: "invKey K = K"
paulson@18886
   101
apply (insert isSym_keys)
paulson@18886
   102
apply (simp add: symKeys_def) 
paulson@18886
   103
done
paulson@18886
   104
paulson@18886
   105
paulson@18886
   106
lemma analz_Decrypt' [dest]:
paulson@18886
   107
     "\<lbrakk> Crypt K X \<in> analz H;  Key K  \<in> analz H \<rbrakk> \<Longrightarrow> X \<in> analz H"
paulson@18886
   108
by auto
paulson@18886
   109
paulson@18886
   110
text{*Now cancel the @{text dest} attribute given to
paulson@18886
   111
 @{text analz.Decrypt} in its declaration.*}
paulson@18886
   112
declare analz.Decrypt [rule del]
paulson@18886
   113
paulson@18886
   114
text{*Rewrites should not refer to  @{term "initState(Friend i)"} because
paulson@18886
   115
  that expression is not in normal form.*}
paulson@18886
   116
paulson@18886
   117
text{*Added to extend initstate with set of nonces*}
paulson@18886
   118
lemma parts_image_Nonce [simp]: "parts (Nonce`N) = Nonce`N"
paulson@18886
   119
apply auto
paulson@18886
   120
apply (erule parts.induct)
paulson@18886
   121
apply auto
paulson@18886
   122
done
paulson@18886
   123
paulson@18886
   124
lemma keysFor_parts_initState [simp]: "keysFor (parts (initState C)) = {}"
paulson@18886
   125
apply (unfold keysFor_def)
paulson@18886
   126
apply (induct_tac "C", auto)
paulson@18886
   127
done
paulson@18886
   128
paulson@18886
   129
(*Specialized to shared-key model: no @{term invKey}*)
paulson@18886
   130
lemma keysFor_parts_insert:
paulson@18886
   131
     "\<lbrakk> K \<in> keysFor (parts (insert X G));  X \<in> synth (analz H) \<rbrakk> 
paulson@18886
   132
     \<Longrightarrow> K \<in> keysFor (parts (G \<union> H)) | Key K \<in> parts H";
paulson@18886
   133
by (force dest: EventSC.keysFor_parts_insert)  
paulson@18886
   134
paulson@18886
   135
lemma Crypt_imp_keysFor: "Crypt K X \<in> H \<Longrightarrow> K \<in> keysFor H"
paulson@18886
   136
by (drule Crypt_imp_invKey_keysFor, simp)
paulson@18886
   137
paulson@18886
   138
paulson@18886
   139
subsection{*Function "knows"*}
paulson@18886
   140
paulson@18886
   141
(*Spy knows the pins of bad agents!*)
paulson@18886
   142
lemma Spy_knows_bad [intro!]: "A \<in> bad \<Longrightarrow> Key (pin A) \<in> knows Spy evs"
paulson@18886
   143
apply (induct_tac "evs")
paulson@18886
   144
apply (simp_all (no_asm_simp) add: imageI knows_Cons split add: event.split)
paulson@18886
   145
done
paulson@18886
   146
paulson@18886
   147
(*Spy knows the long-term keys of cloned cards!*)
paulson@18886
   148
lemma Spy_knows_cloned [intro!]: 
paulson@18886
   149
     "Card A \<in> cloned \<Longrightarrow>  Key (crdK (Card A)) \<in> knows Spy evs &   
paulson@18886
   150
                           Key (shrK A) \<in> knows Spy evs &  
paulson@18886
   151
                           Key (pin A)  \<in> knows Spy evs &  
paulson@18886
   152
                          (\<forall> B. Key (pairK(B,A)) \<in> knows Spy evs)"
paulson@18886
   153
apply (induct_tac "evs")
paulson@18886
   154
apply (simp_all (no_asm_simp) add: imageI knows_Cons split add: event.split)
paulson@18886
   155
done
paulson@18886
   156
paulson@18886
   157
lemma Spy_knows_cloned1 [intro!]: "C \<in> cloned \<Longrightarrow> Key (crdK C) \<in> knows Spy evs"
paulson@18886
   158
apply (induct_tac "evs")
paulson@18886
   159
apply (simp_all (no_asm_simp) add: imageI knows_Cons split add: event.split)
paulson@18886
   160
done
paulson@18886
   161
paulson@18886
   162
lemma Spy_knows_cloned2 [intro!]: "\<lbrakk> Card A \<in> cloned; Card B \<in> cloned \<rbrakk>  
paulson@18886
   163
   \<Longrightarrow> Nonce (Pairkey(A,B))\<in> knows Spy evs"
paulson@18886
   164
apply (induct_tac "evs")
paulson@18886
   165
apply (simp_all (no_asm_simp) add: imageI knows_Cons split add: event.split)
paulson@18886
   166
done
paulson@18886
   167
paulson@18886
   168
(*Spy only knows pins of bad agents!*)
paulson@18886
   169
lemma Spy_knows_Spy_bad [intro!]: "A\<in> bad \<Longrightarrow> Key (pin A) \<in> knows Spy evs"
paulson@18886
   170
apply (induct_tac "evs")
paulson@18886
   171
apply (simp_all (no_asm_simp) add: imageI knows_Cons split add: event.split)
paulson@18886
   172
done
paulson@18886
   173
paulson@18886
   174
paulson@18886
   175
(*For case analysis on whether or not an agent is compromised*)
paulson@18886
   176
lemma Crypt_Spy_analz_bad: 
paulson@18886
   177
  "\<lbrakk> Crypt (pin A) X \<in> analz (knows Spy evs);  A\<in>bad \<rbrakk>   
paulson@18886
   178
      \<Longrightarrow> X \<in> analz (knows Spy evs)"
paulson@18886
   179
apply (force dest!: analz.Decrypt)
paulson@18886
   180
done
paulson@18886
   181
paulson@18886
   182
(** Fresh keys never clash with other keys **)
paulson@18886
   183
paulson@18886
   184
lemma shrK_in_initState [iff]: "Key (shrK A) \<in> initState Server"
paulson@18886
   185
apply (induct_tac "A")
paulson@18886
   186
apply auto
paulson@18886
   187
done
paulson@18886
   188
paulson@18886
   189
lemma shrK_in_used [iff]: "Key (shrK A) \<in> used evs"
paulson@18886
   190
apply (rule initState_into_used)
paulson@18886
   191
apply blast
paulson@18886
   192
done
paulson@18886
   193
paulson@18886
   194
lemma crdK_in_initState [iff]: "Key (crdK A) \<in> initState Server"
paulson@18886
   195
apply (induct_tac "A")
paulson@18886
   196
apply auto
paulson@18886
   197
done
paulson@18886
   198
paulson@18886
   199
lemma crdK_in_used [iff]: "Key (crdK A) \<in> used evs"
paulson@18886
   200
apply (rule initState_into_used)
paulson@18886
   201
apply blast
paulson@18886
   202
done
paulson@18886
   203
paulson@18886
   204
lemma pin_in_initState [iff]: "Key (pin A) \<in> initState A"
paulson@18886
   205
apply (induct_tac "A")
paulson@18886
   206
apply auto
paulson@18886
   207
done
paulson@18886
   208
paulson@18886
   209
lemma pin_in_used [iff]: "Key (pin A) \<in> used evs"
paulson@18886
   210
apply (rule initState_into_used)
paulson@18886
   211
apply blast
paulson@18886
   212
done
paulson@18886
   213
paulson@18886
   214
lemma pairK_in_initState [iff]: "Key (pairK X) \<in> initState Server"
paulson@18886
   215
apply (induct_tac "X")
paulson@18886
   216
apply auto
paulson@18886
   217
done
paulson@18886
   218
paulson@18886
   219
lemma pairK_in_used [iff]: "Key (pairK X) \<in> used evs"
paulson@18886
   220
apply (rule initState_into_used)
paulson@18886
   221
apply blast
paulson@18886
   222
done
paulson@18886
   223
paulson@18886
   224
paulson@18886
   225
paulson@18886
   226
(*Used in parts_induct_tac and analz_Fake_tac to distinguish session keys
paulson@18886
   227
  from long-term shared keys*)
paulson@18886
   228
lemma Key_not_used [simp]: "Key K \<notin> used evs \<Longrightarrow> K \<notin> range shrK"
paulson@18886
   229
by blast
paulson@18886
   230
paulson@18886
   231
lemma shrK_neq [simp]: "Key K \<notin> used evs \<Longrightarrow> shrK B \<noteq> K"
paulson@18886
   232
by blast
paulson@18886
   233
paulson@18886
   234
lemma crdK_not_used [simp]: "Key K \<notin> used evs \<Longrightarrow> K \<notin> range crdK"
paulson@18886
   235
apply clarify
paulson@18886
   236
done
paulson@18886
   237
paulson@18886
   238
lemma crdK_neq [simp]: "Key K \<notin> used evs \<Longrightarrow> crdK C \<noteq> K"
paulson@18886
   239
apply clarify
paulson@18886
   240
done
paulson@18886
   241
paulson@18886
   242
lemma pin_not_used [simp]: "Key K \<notin> used evs \<Longrightarrow> K \<notin> range pin"
paulson@18886
   243
apply clarify
paulson@18886
   244
done
paulson@18886
   245
paulson@18886
   246
lemma pin_neq [simp]: "Key K \<notin> used evs \<Longrightarrow> pin A \<noteq> K"
paulson@18886
   247
apply clarify
paulson@18886
   248
done
paulson@18886
   249
paulson@18886
   250
lemma pairK_not_used [simp]: "Key K \<notin> used evs \<Longrightarrow> K \<notin> range pairK"
paulson@18886
   251
apply clarify
paulson@18886
   252
done
paulson@18886
   253
paulson@18886
   254
lemma pairK_neq [simp]: "Key K \<notin> used evs \<Longrightarrow> pairK(A,B) \<noteq> K"
paulson@18886
   255
apply clarify
paulson@18886
   256
done
paulson@18886
   257
paulson@18886
   258
declare shrK_neq [THEN not_sym, simp]
paulson@18886
   259
declare crdK_neq [THEN not_sym, simp]
paulson@18886
   260
declare pin_neq [THEN not_sym, simp]
paulson@18886
   261
declare pairK_neq [THEN not_sym, simp]
paulson@18886
   262
paulson@18886
   263
paulson@18886
   264
subsection{*Fresh nonces*}
paulson@18886
   265
paulson@18886
   266
lemma Nonce_notin_initState [iff]: "Nonce N \<notin> parts (initState (Friend i))"
paulson@18886
   267
by auto
paulson@18886
   268
paulson@18886
   269
paulson@18886
   270
(*This lemma no longer holds of smartcard protocols, where the cards can store
paulson@18886
   271
  nonces.
paulson@18886
   272
paulson@18886
   273
lemma Nonce_notin_used_empty [simp]: "Nonce N \<notin> used []"
paulson@18886
   274
apply (simp (no_asm) add: used_Nil)
paulson@18886
   275
done
paulson@18886
   276
paulson@18886
   277
So, we must use old-style supply fresh nonce theorems relying on the appropriate axiom*)
paulson@18886
   278
paulson@18886
   279
paulson@18886
   280
subsection{*Supply fresh nonces for possibility theorems.*}
paulson@18886
   281
paulson@18886
   282
paulson@18886
   283
lemma Nonce_supply1: "\<exists>N. Nonce N \<notin> used evs"
berghofe@22265
   284
apply (rule finite.emptyI [THEN Nonce_supply_ax, THEN exE], blast)
paulson@18886
   285
done
paulson@18886
   286
paulson@18886
   287
lemma Nonce_supply2: 
paulson@18886
   288
  "\<exists>N N'. Nonce N \<notin> used evs & Nonce N' \<notin> used evs' & N \<noteq> N'"
berghofe@22265
   289
apply (cut_tac evs = evs in finite.emptyI [THEN Nonce_supply_ax])
paulson@18886
   290
apply (erule exE)
berghofe@22265
   291
apply (cut_tac evs = evs' in finite.emptyI [THEN finite.insertI, THEN Nonce_supply_ax]) 
paulson@18886
   292
apply auto
paulson@18886
   293
done
paulson@18886
   294
paulson@18886
   295
paulson@18886
   296
lemma Nonce_supply3: "\<exists>N N' N''. Nonce N \<notin> used evs & Nonce N' \<notin> used evs' &  
paulson@18886
   297
                    Nonce N'' \<notin> used evs'' & N \<noteq> N' & N' \<noteq> N'' & N \<noteq> N''"
berghofe@22265
   298
apply (cut_tac evs = evs in finite.emptyI [THEN Nonce_supply_ax])
paulson@18886
   299
apply (erule exE)
berghofe@22265
   300
apply (cut_tac evs = evs' and a1 = N in finite.emptyI [THEN finite.insertI, THEN Nonce_supply_ax]) 
paulson@18886
   301
apply (erule exE)
berghofe@22265
   302
apply (cut_tac evs = evs'' and a1 = Na and a2 = N in finite.emptyI [THEN finite.insertI, THEN finite.insertI, THEN Nonce_supply_ax]) 
paulson@18886
   303
apply blast
paulson@18886
   304
done
paulson@18886
   305
paulson@18886
   306
lemma Nonce_supply: "Nonce (@ N. Nonce N \<notin> used evs) \<notin> used evs"
berghofe@22265
   307
apply (rule finite.emptyI [THEN Nonce_supply_ax, THEN exE])
paulson@18886
   308
apply (rule someI, blast)
paulson@18886
   309
done
paulson@18886
   310
paulson@18886
   311
paulson@18886
   312
paulson@18886
   313
text{*Unlike the corresponding property of nonces, we cannot prove
paulson@18886
   314
    @{term "finite KK \<Longrightarrow> \<exists>K. K \<notin> KK & Key K \<notin> used evs"}.
paulson@18886
   315
    We have infinitely many agents and there is nothing to stop their
paulson@18886
   316
    long-term keys from exhausting all the natural numbers.  Instead,
paulson@18886
   317
    possibility theorems must assume the existence of a few keys.*}
paulson@18886
   318
paulson@18886
   319
paulson@18886
   320
subsection{*Specialized Rewriting for Theorems About @{term analz} and Image*}
paulson@18886
   321
paulson@18886
   322
lemma subset_Compl_range_shrK: "A \<subseteq> - (range shrK) \<Longrightarrow> shrK x \<notin> A"
paulson@18886
   323
by blast
paulson@18886
   324
paulson@18886
   325
lemma subset_Compl_range_crdK: "A \<subseteq> - (range crdK) \<Longrightarrow> crdK x \<notin> A"
paulson@18886
   326
apply blast
paulson@18886
   327
done
paulson@18886
   328
paulson@18886
   329
lemma subset_Compl_range_pin: "A \<subseteq> - (range pin) \<Longrightarrow> pin x \<notin> A"
paulson@18886
   330
apply blast
paulson@18886
   331
done
paulson@18886
   332
paulson@18886
   333
lemma subset_Compl_range_pairK: "A \<subseteq> - (range pairK) \<Longrightarrow> pairK x \<notin> A"
paulson@18886
   334
apply blast
paulson@18886
   335
done
paulson@18886
   336
lemma insert_Key_singleton: "insert (Key K) H = Key ` {K} \<union> H"
paulson@18886
   337
by blast
paulson@18886
   338
paulson@18886
   339
lemma insert_Key_image: "insert (Key K) (Key`KK \<union> C) = Key`(insert K KK) \<union> C"
paulson@18886
   340
by blast
paulson@18886
   341
paulson@18886
   342
(** Reverse the normal simplification of "image" to build up (not break down)
paulson@18886
   343
    the set of keys.  Use analz_insert_eq with (Un_upper2 RS analz_mono) to
paulson@18886
   344
    erase occurrences of forwarded message components (X). **)
paulson@18886
   345
paulson@18886
   346
lemmas analz_image_freshK_simps =
paulson@18886
   347
       simp_thms mem_simps --{*these two allow its use with @{text "only:"}*}
paulson@18886
   348
       disj_comms 
paulson@18886
   349
       image_insert [THEN sym] image_Un [THEN sym] empty_subsetI insert_subset
paulson@18886
   350
       analz_insert_eq Un_upper2 [THEN analz_mono, THEN [2] rev_subsetD]
paulson@18886
   351
       insert_Key_singleton subset_Compl_range_shrK subset_Compl_range_crdK
paulson@18886
   352
       subset_Compl_range_pin subset_Compl_range_pairK
paulson@18886
   353
       Key_not_used insert_Key_image Un_assoc [THEN sym]
paulson@18886
   354
paulson@18886
   355
(*Lemma for the trivial direction of the if-and-only-if*)
paulson@18886
   356
lemma analz_image_freshK_lemma:
paulson@18886
   357
     "(Key K \<in> analz (Key`nE \<union> H)) \<longrightarrow> (K \<in> nE | Key K \<in> analz H)  \<Longrightarrow>  
paulson@18886
   358
         (Key K \<in> analz (Key`nE \<union> H)) = (K \<in> nE | Key K \<in> analz H)"
paulson@18886
   359
by (blast intro: analz_mono [THEN [2] rev_subsetD])
paulson@18886
   360
wenzelm@24122
   361
wenzelm@24122
   362
subsection{*Tactics for possibility theorems*}
wenzelm@24122
   363
paulson@18886
   364
ML
paulson@18886
   365
{*
wenzelm@24122
   366
structure Smartcard =
wenzelm@24122
   367
struct
wenzelm@24122
   368
wenzelm@24122
   369
(*Omitting used_Says makes the tactic much faster: it leaves expressions
wenzelm@24122
   370
    such as  Nonce ?N \<notin> used evs that match Nonce_supply*)
wenzelm@24122
   371
fun possibility_tac ctxt =
wenzelm@24122
   372
   (REPEAT 
wenzelm@32149
   373
    (ALLGOALS (simp_tac (simpset_of ctxt
wenzelm@24122
   374
      delsimps [@{thm used_Says}, @{thm used_Notes}, @{thm used_Gets},
wenzelm@24122
   375
        @{thm used_Inputs}, @{thm used_C_Gets}, @{thm used_Outpts}, @{thm used_A_Gets}] 
wenzelm@24122
   376
      setSolver safe_solver))
wenzelm@24122
   377
     THEN
wenzelm@24122
   378
     REPEAT_FIRST (eq_assume_tac ORELSE' 
wenzelm@24122
   379
                   resolve_tac [refl, conjI, @{thm Nonce_supply}])))
wenzelm@24122
   380
wenzelm@24122
   381
(*For harder protocols (such as Recur) where we have to set up some
wenzelm@24122
   382
  nonces and keys initially*)
wenzelm@24122
   383
fun basic_possibility_tac ctxt =
wenzelm@24122
   384
    REPEAT 
wenzelm@32149
   385
    (ALLGOALS (asm_simp_tac (simpset_of ctxt setSolver safe_solver))
wenzelm@24122
   386
     THEN
wenzelm@24122
   387
     REPEAT_FIRST (resolve_tac [refl, conjI]))
paulson@18886
   388
paulson@18886
   389
val analz_image_freshK_ss = 
wenzelm@23894
   390
     @{simpset} delsimps [image_insert, image_Un]
wenzelm@32960
   391
               delsimps [@{thm imp_disjL}]    (*reduces blow-up*)
wenzelm@32960
   392
               addsimps @{thms analz_image_freshK_simps}
wenzelm@24122
   393
end
paulson@18886
   394
*}
paulson@18886
   395
paulson@18886
   396
paulson@18886
   397
(*Lets blast_tac perform this step without needing the simplifier*)
paulson@18886
   398
lemma invKey_shrK_iff [iff]:
paulson@18886
   399
     "(Key (invKey K) \<in> X) = (Key K \<in> X)"
paulson@18886
   400
by auto
paulson@18886
   401
paulson@18886
   402
(*Specialized methods*)
paulson@18886
   403
paulson@18886
   404
method_setup analz_freshK = {*
wenzelm@30549
   405
    Scan.succeed (fn ctxt =>
wenzelm@30510
   406
     (SIMPLE_METHOD
wenzelm@21588
   407
      (EVERY [REPEAT_FIRST (resolve_tac [allI, ballI, impI]),
wenzelm@24122
   408
          REPEAT_FIRST (rtac @{thm analz_image_freshK_lemma}),
wenzelm@24122
   409
          ALLGOALS (asm_simp_tac (Simplifier.context ctxt Smartcard.analz_image_freshK_ss))]))) *}
paulson@18886
   410
    "for proving the Session Key Compromise theorem"
paulson@18886
   411
paulson@18886
   412
method_setup possibility = {*
wenzelm@30549
   413
    Scan.succeed (fn ctxt =>
wenzelm@30510
   414
        SIMPLE_METHOD (Smartcard.possibility_tac ctxt)) *}
wenzelm@23894
   415
    "for proving possibility theorems"
wenzelm@23894
   416
wenzelm@23894
   417
method_setup basic_possibility = {*
wenzelm@30549
   418
    Scan.succeed (fn ctxt =>
wenzelm@30510
   419
        SIMPLE_METHOD (Smartcard.basic_possibility_tac ctxt)) *}
paulson@18886
   420
    "for proving possibility theorems"
paulson@18886
   421
paulson@18886
   422
lemma knows_subset_knows_Cons: "knows A evs \<subseteq> knows A (e # evs)"
wenzelm@23894
   423
by (induct e) (auto simp: knows_Cons)
paulson@18886
   424
paulson@18886
   425
(*Needed for actual protocols that will follow*)
paulson@18886
   426
declare shrK_disj_crdK[THEN not_sym, iff]
paulson@18886
   427
declare shrK_disj_pin[THEN not_sym, iff]
paulson@18886
   428
declare pairK_disj_shrK[THEN not_sym, iff]
paulson@18886
   429
declare pairK_disj_crdK[THEN not_sym, iff]
paulson@18886
   430
declare pairK_disj_pin[THEN not_sym, iff]
paulson@18886
   431
declare crdK_disj_pin[THEN not_sym, iff]
paulson@18886
   432
paulson@18886
   433
declare legalUse_def [iff] illegalUse_def [iff]
paulson@18886
   434
paulson@18886
   435
end