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