src/HOL/Auth/Smartcard/Smartcard.thy
author nipkow
Wed, 10 Aug 2016 09:33:54 +0200
changeset 63648 f9f3006a5579
parent 62343 24106dc44def
child 67443 3abf6a722518
permissions -rw-r--r--
"split add" -> "split"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32631
2489e3c3562b common base for protocols with symmetric keys
haftmann
parents: 32149
diff changeset
     1
(* Author:     Giampaolo Bella, Catania University
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
     2
*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
     3
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
     4
section\<open>Theory of smartcards\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
     5
32631
2489e3c3562b common base for protocols with symmetric keys
haftmann
parents: 32149
diff changeset
     6
theory Smartcard
41413
64cd30d6b0b8 explicit file specifications -- avoid secondary load path;
wenzelm
parents: 39246
diff changeset
     7
imports EventSC "../All_Symmetric"
32631
2489e3c3562b common base for protocols with symmetric keys
haftmann
parents: 32149
diff changeset
     8
begin
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
     9
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    10
text\<open>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    11
As smartcards handle long-term (symmetric) keys, this theoy extends and 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    12
supersedes theory Private.thy
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    13
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    14
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
    15
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
    16
smartcard, which independently may be stolen or cloned.
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    17
\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    18
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    19
axiomatization
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    20
  shrK    :: "agent => key" and  (*long-term keys saved in smart cards*)
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    21
  crdK    :: "card  => key" and  (*smart cards' symmetric keys*)
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    22
  pin     :: "agent => key" and  (*pin to activate the smart cards*)
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    23
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    24
  (*Mostly for Shoup-Rubin*)
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    25
  Pairkey :: "agent * agent => nat" and
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    26
  pairK   :: "agent * agent => key"
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    27
where
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    28
  inj_shrK: "inj shrK" and  \<comment>\<open>No two smartcards store the same key\<close>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    29
  inj_crdK: "inj crdK" and  \<comment>\<open>Nor do two cards\<close>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    30
  inj_pin : "inj pin" and   \<comment>\<open>Nor do two agents have the same pin\<close>
18886
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 *)
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    34
  inj_pairK    [iff]: "(pairK(A,B) = pairK(A',B')) = (A = A' & B = B')" and
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    35
  comm_Pairkey [iff]: "Pairkey(A,B) = Pairkey(B,A)" and
18886
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*)
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    38
  pairK_disj_crdK [iff]: "pairK(A,B) \<noteq> crdK C" and
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    39
  pairK_disj_shrK [iff]: "pairK(A,B) \<noteq> shrK P" and
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    40
  pairK_disj_pin [iff]:  "pairK(A,B) \<noteq> pin P" and
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    41
  shrK_disj_crdK [iff]:  "shrK P \<noteq> crdK C" and
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    42
  shrK_disj_pin [iff]:  "shrK P \<noteq> pin Q" and
18886
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
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    45
definition legalUse :: "card => bool" ("legalUse (_)") where
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    46
  "legalUse C == C \<notin> stolen"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    47
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    48
primrec illegalUse :: "card  => bool" where
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    49
  illegalUse_def: "illegalUse (Card A) = ( (Card A \<in> stolen \<and> A \<in> bad)  \<or>  Card A \<in> cloned )"
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    50
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    51
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    52
text\<open>initState must be defined with care\<close>
39246
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    53
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    54
overloading
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    55
  initState \<equiv> initState
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    56
begin
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    57
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    58
primrec initState where
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    59
(*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
    60
  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
    61
  from fresh (session) keys*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    62
  initState_Server:  "initState Server = 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    63
        (Key`(range shrK \<union> range crdK \<union> range pin \<union> range pairK)) \<union> 
39246
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    64
        (Nonce`(range Pairkey))" |
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    65
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    66
(*Other agents know only their own*)
39246
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    67
  initState_Friend:  "initState (Friend i) = {Key (pin (Friend i))}" |
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    68
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    69
(*Spy knows bad agents' pins, cloned cards' keys, pairKs, and Pairkeys *)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    70
  initState_Spy: "initState Spy  = 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    71
                 (Key`((pin`bad) \<union> (pin `{A. Card A \<in> cloned}) \<union> 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    72
                                      (shrK`{A. Card A \<in> cloned}) \<union> 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    73
                        (crdK`cloned) \<union> 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    74
                        (pairK`{(X,A). Card A \<in> cloned})))
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    75
           \<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
    76
39246
9e58f0499f57 modernized primrec
haftmann
parents: 35416
diff changeset
    77
end
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    78
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    79
text\<open>Still relying on axioms\<close>
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    80
axiomatization where
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
    81
  Key_supply_ax:  "finite KK \<Longrightarrow> \<exists> K. K \<notin> KK & Key K \<notin> used evs" and
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    82
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    83
  (*Needed because of Spy's knowledge of Pairkeys*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    84
  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
    85
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    86
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    87
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
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    90
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    91
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
    92
subsection\<open>Basic properties of shrK\<close>
18886
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
(*Injectiveness: Agents' long-term keys are distinct.*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    95
declare inj_shrK [THEN inj_eq, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    96
declare inj_crdK [THEN inj_eq, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    97
declare inj_pin  [THEN inj_eq, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    98
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
    99
lemma invKey_K [simp]: "invKey K = K"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   100
apply (insert isSym_keys)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   101
apply (simp add: symKeys_def) 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   102
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   103
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 analz_Decrypt' [dest]:
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   106
     "\<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
   107
by auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   108
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   109
text\<open>Now cancel the \<open>dest\<close> attribute given to
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   110
 \<open>analz.Decrypt\<close> in its declaration.\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   111
declare analz.Decrypt [rule del]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   112
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   113
text\<open>Rewrites should not refer to  @{term "initState(Friend i)"} because
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   114
  that expression is not in normal form.\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   115
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   116
text\<open>Added to extend initstate with set of nonces\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   117
lemma parts_image_Nonce [simp]: "parts (Nonce`N) = Nonce`N"
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 61830
diff changeset
   118
  by auto
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   119
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   120
lemma keysFor_parts_initState [simp]: "keysFor (parts (initState C)) = {}"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   121
apply (unfold keysFor_def)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   122
apply (induct_tac "C", auto)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   123
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   124
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   125
(*Specialized to shared-key model: no @{term invKey}*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   126
lemma keysFor_parts_insert:
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   127
     "\<lbrakk> K \<in> keysFor (parts (insert X G));  X \<in> synth (analz H) \<rbrakk> 
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41413
diff changeset
   128
     \<Longrightarrow> K \<in> keysFor (parts (G \<union> H)) | Key K \<in> parts H"
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   129
by (force dest: EventSC.keysFor_parts_insert)  
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   130
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   131
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
   132
by (drule Crypt_imp_invKey_keysFor, simp)
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
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   135
subsection\<open>Function "knows"\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   136
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   137
(*Spy knows the pins of bad agents!*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   138
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
   139
apply (induct_tac "evs")
63648
f9f3006a5579 "split add" -> "split"
nipkow
parents: 62343
diff changeset
   140
apply (simp_all (no_asm_simp) add: imageI knows_Cons split: event.split)
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   141
done
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
(*Spy knows the long-term keys of cloned cards!*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   144
lemma Spy_knows_cloned [intro!]: 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   145
     "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
   146
                           Key (shrK A) \<in> knows Spy evs &  
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   147
                           Key (pin A)  \<in> knows Spy evs &  
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   148
                          (\<forall> B. Key (pairK(B,A)) \<in> knows Spy evs)"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   149
apply (induct_tac "evs")
63648
f9f3006a5579 "split add" -> "split"
nipkow
parents: 62343
diff changeset
   150
apply (simp_all (no_asm_simp) add: imageI knows_Cons split: event.split)
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   151
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   152
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   153
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
   154
apply (induct_tac "evs")
63648
f9f3006a5579 "split add" -> "split"
nipkow
parents: 62343
diff changeset
   155
apply (simp_all (no_asm_simp) add: imageI knows_Cons split: event.split)
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   156
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   157
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   158
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
   159
   \<Longrightarrow> Nonce (Pairkey(A,B))\<in> knows Spy evs"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   160
apply (induct_tac "evs")
63648
f9f3006a5579 "split add" -> "split"
nipkow
parents: 62343
diff changeset
   161
apply (simp_all (no_asm_simp) add: imageI knows_Cons split: event.split)
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   162
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   163
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   164
(*Spy only knows pins of bad agents!*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   165
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
   166
apply (induct_tac "evs")
63648
f9f3006a5579 "split add" -> "split"
nipkow
parents: 62343
diff changeset
   167
apply (simp_all (no_asm_simp) add: imageI knows_Cons split: event.split)
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   168
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   169
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   170
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   171
(*For case analysis on whether or not an agent is compromised*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   172
lemma Crypt_Spy_analz_bad: 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   173
  "\<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
   174
      \<Longrightarrow> X \<in> analz (knows Spy evs)"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   175
apply (force dest!: analz.Decrypt)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   176
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   177
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   178
(** Fresh keys never clash with other keys **)
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
lemma shrK_in_initState [iff]: "Key (shrK A) \<in> initState Server"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   181
apply (induct_tac "A")
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   182
apply auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   183
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   184
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   185
lemma shrK_in_used [iff]: "Key (shrK A) \<in> used evs"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   186
apply (rule initState_into_used)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   187
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   188
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   189
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   190
lemma crdK_in_initState [iff]: "Key (crdK A) \<in> initState Server"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   191
apply (induct_tac "A")
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   192
apply auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   193
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   194
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   195
lemma crdK_in_used [iff]: "Key (crdK A) \<in> used evs"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   196
apply (rule initState_into_used)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   197
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   198
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   199
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   200
lemma pin_in_initState [iff]: "Key (pin A) \<in> initState A"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   201
apply (induct_tac "A")
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   202
apply auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   203
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   204
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   205
lemma pin_in_used [iff]: "Key (pin A) \<in> used evs"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   206
apply (rule initState_into_used)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   207
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   208
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   209
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   210
lemma pairK_in_initState [iff]: "Key (pairK X) \<in> initState Server"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   211
apply (induct_tac "X")
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   212
apply auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   213
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   214
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   215
lemma pairK_in_used [iff]: "Key (pairK X) \<in> used evs"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   216
apply (rule initState_into_used)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   217
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   218
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   219
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   220
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   221
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   222
(*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
   223
  from long-term shared keys*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   224
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
   225
by blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   226
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   227
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
   228
by blast
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
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
   231
apply clarify
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   232
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   233
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   234
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
   235
apply clarify
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   236
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   237
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   238
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
   239
apply clarify
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   240
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   241
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   242
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
   243
apply clarify
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   244
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   245
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   246
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
   247
apply clarify
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   248
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   249
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   250
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
   251
apply clarify
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   252
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   253
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   254
declare shrK_neq [THEN not_sym, simp]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   255
declare crdK_neq [THEN not_sym, simp]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   256
declare pin_neq [THEN not_sym, simp]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   257
declare pairK_neq [THEN not_sym, simp]
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
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   260
subsection\<open>Fresh nonces\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   261
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   262
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
   263
by auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   264
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   265
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   266
(*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
   267
  nonces.
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
lemma Nonce_notin_used_empty [simp]: "Nonce N \<notin> used []"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   270
apply (simp (no_asm) add: used_Nil)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   271
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   272
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   273
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
   274
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   275
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   276
subsection\<open>Supply fresh nonces for possibility theorems.\<close>
18886
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
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   279
lemma Nonce_supply1: "\<exists>N. Nonce N \<notin> used evs"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 21588
diff changeset
   280
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
   281
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   282
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   283
lemma Nonce_supply2: 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   284
  "\<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
   285
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
   286
apply (erule exE)
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 21588
diff changeset
   287
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
   288
apply auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   289
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   290
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_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
   293
                    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
   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' 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
   297
apply (erule exE)
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 21588
diff changeset
   298
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
   299
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   300
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   301
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   302
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
   303
apply (rule finite.emptyI [THEN Nonce_supply_ax, THEN exE])
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   304
apply (rule someI, blast)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   305
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   306
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   307
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   308
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   309
text\<open>Unlike the corresponding property of nonces, we cannot prove
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   310
    @{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
   311
    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
   312
    long-term keys from exhausting all the natural numbers.  Instead,
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   313
    possibility theorems must assume the existence of a few keys.\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   314
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   315
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   316
subsection\<open>Specialized Rewriting for Theorems About @{term analz} and Image\<close>
18886
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
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
   319
by blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   320
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   321
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
   322
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   323
done
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
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
   326
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   327
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   328
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   329
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
   330
apply blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   331
done
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   332
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
   333
by blast
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   334
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   335
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
   336
by blast
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
(** 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
   339
    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
   340
    erase occurrences of forwarded message components (X). **)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   341
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   342
lemmas analz_image_freshK_simps =
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   343
       simp_thms mem_simps \<comment>\<open>these two allow its use with \<open>only:\<close>\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   344
       disj_comms 
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   345
       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
   346
       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
   347
       insert_Key_singleton subset_Compl_range_shrK subset_Compl_range_crdK
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   348
       subset_Compl_range_pin subset_Compl_range_pairK
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   349
       Key_not_used insert_Key_image Un_assoc [THEN sym]
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
(*Lemma for the trivial direction of the if-and-only-if*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   352
lemma analz_image_freshK_lemma:
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   353
     "(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
   354
         (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
   355
by (blast intro: analz_mono [THEN [2] rev_subsetD])
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   356
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   357
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   358
subsection\<open>Tactics for possibility theorems\<close>
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   359
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   360
ML
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   361
\<open>
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   362
structure Smartcard =
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   363
struct
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   364
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   365
(*Omitting used_Says makes the tactic much faster: it leaves expressions
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   366
    such as  Nonce ?N \<notin> used evs that match Nonce_supply*)
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   367
fun possibility_tac ctxt =
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   368
   (REPEAT 
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 41774
diff changeset
   369
    (ALLGOALS (simp_tac (ctxt
53428
3083c611ec40 use case_of_simps
noschinl
parents: 51717
diff changeset
   370
      delsimps @{thms used_Cons_simps}
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   371
      setSolver safe_solver))
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   372
     THEN
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   373
     REPEAT_FIRST (eq_assume_tac ORELSE' 
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   374
                   resolve_tac ctxt [refl, conjI, @{thm Nonce_supply}])))
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   375
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   376
(*For harder protocols (such as Recur) where we have to set up some
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   377
  nonces and keys initially*)
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   378
fun basic_possibility_tac ctxt =
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   379
    REPEAT 
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 41774
diff changeset
   380
    (ALLGOALS (asm_simp_tac (ctxt setSolver safe_solver))
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   381
     THEN
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   382
     REPEAT_FIRST (resolve_tac ctxt [refl, conjI]))
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   383
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   384
val analz_image_freshK_ss = 
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 41774
diff changeset
   385
  simpset_of
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 41774
diff changeset
   386
   (@{context} delsimps [image_insert, image_Un]
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32631
diff changeset
   387
               delsimps [@{thm imp_disjL}]    (*reduces blow-up*)
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 41774
diff changeset
   388
               addsimps @{thms analz_image_freshK_simps})
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23894
diff changeset
   389
end
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   390
\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   391
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   392
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   393
(*Lets blast_tac perform this step without needing the simplifier*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   394
lemma invKey_shrK_iff [iff]:
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   395
     "(Key (invKey K) \<in> X) = (Key K \<in> X)"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   396
by auto
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   397
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   398
(*Specialized methods*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   399
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   400
method_setup analz_freshK = \<open>
30549
d2d7874648bd simplified method setup;
wenzelm
parents: 30510
diff changeset
   401
    Scan.succeed (fn ctxt =>
30510
4120fc59dd85 unified type Proof.method and pervasive METHOD combinators;
wenzelm
parents: 24122
diff changeset
   402
     (SIMPLE_METHOD
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   403
      (EVERY [REPEAT_FIRST (resolve_tac ctxt [allI, ballI, impI]),
60754
02924903a6fd prefer tactics with explicit context;
wenzelm
parents: 59498
diff changeset
   404
          REPEAT_FIRST (resolve_tac ctxt @{thms analz_image_freshK_lemma}),
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   405
          ALLGOALS (asm_simp_tac (put_simpset Smartcard.analz_image_freshK_ss ctxt))])))\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   406
    "for proving the Session Key Compromise theorem"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   407
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   408
method_setup possibility = \<open>
30549
d2d7874648bd simplified method setup;
wenzelm
parents: 30510
diff changeset
   409
    Scan.succeed (fn ctxt =>
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   410
        SIMPLE_METHOD (Smartcard.possibility_tac ctxt))\<close>
23894
1a4167d761ac tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents: 22265
diff changeset
   411
    "for proving possibility theorems"
1a4167d761ac tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents: 22265
diff changeset
   412
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   413
method_setup basic_possibility = \<open>
30549
d2d7874648bd simplified method setup;
wenzelm
parents: 30510
diff changeset
   414
    Scan.succeed (fn ctxt =>
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 60754
diff changeset
   415
        SIMPLE_METHOD (Smartcard.basic_possibility_tac ctxt))\<close>
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   416
    "for proving possibility theorems"
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   417
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   418
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
   419
by (induct e) (auto simp: knows_Cons)
18886
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   420
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   421
(*Needed for actual protocols that will follow*)
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   422
declare shrK_disj_crdK[THEN not_sym, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   423
declare shrK_disj_pin[THEN not_sym, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   424
declare pairK_disj_shrK[THEN not_sym, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   425
declare pairK_disj_crdK[THEN not_sym, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   426
declare pairK_disj_pin[THEN not_sym, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   427
declare crdK_disj_pin[THEN not_sym, iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   428
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   429
declare legalUse_def [iff] illegalUse_def [iff]
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   430
9f27383426db new and updated protocol proofs by Giamp Bella
paulson
parents:
diff changeset
   431
end