src/HOL/Auth/Public.thy
author paulson
Tue, 29 Apr 2003 12:36:49 +0200
changeset 13935 4822d9597d1e
parent 13926 6e62e5357a10
child 13956 8fe7e12290e1
permissions -rw-r--r--
tweaks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/Public
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     2
    ID:         $Id$
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     5
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents: 3478
diff changeset
     6
Theory of Public Keys (common to all public-key protocols)
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     7
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents: 3478
diff changeset
     8
Private and public keys; initial states of agents
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     9
*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    10
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    11
theory Public = Event:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    12
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    13
subsection{*Asymmetric Keys*}
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    14
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    15
consts
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    16
  (*the bool is TRUE if a signing key*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    17
  publicKey :: "[bool,agent] => key"
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    18
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    19
syntax
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    20
  pubEK :: "agent => key"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    21
  pubSK :: "agent => key"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    22
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    23
  privateKey :: "[bool,agent] => key"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    24
  priEK :: "agent => key"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    25
  priSK :: "agent => key"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    26
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    27
translations
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    28
  "pubEK"  == "publicKey False"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    29
  "pubSK"  == "publicKey True"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    30
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    31
  (*BEWARE!! priEK, priSK DON'T WORK with inj, range, image, etc.*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    32
  "privateKey b A" == "invKey (publicKey b A)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    33
  "priEK A"  == "privateKey False A"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    34
  "priSK A"  == "privateKey True A"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    35
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    36
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    37
text{*These translations give backward compatibility.  They represent the
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    38
simple situation where the signature and encryption keys are the same.*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    39
syntax
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    40
  pubK :: "agent => key"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    41
  priK :: "agent => key"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    42
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    43
translations
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    44
  "pubK A" == "pubEK A"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    45
  "priK A" == "invKey (pubEK A)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    46
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    47
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    48
axioms
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    49
  (*By freeness of agents, no two agents have the same key.  Since true\<noteq>false,
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    50
    no agent has identical signing and encryption keys*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    51
  injective_publicKey:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    52
    "publicKey b A = publicKey c A' ==> b=c & A=A'"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    53
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    54
  (*No private key equals any public key (essential to ensure that private
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    55
    keys are private!) *)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    56
  privateKey_neq_publicKey [iff]: "privateKey b A \<noteq> publicKey c A'"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    57
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    58
declare privateKey_neq_publicKey [THEN not_sym, iff]
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    59
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    60
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    61
subsection{*Basic properties of @{term pubK} and @{term priK}*}
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    62
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    63
lemma [iff]: "(publicKey b A = publicKey c A') = (b=c & A=A')"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    64
by (blast dest!: injective_publicKey) 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    65
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    66
lemma not_symKeys_pubK [iff]: "publicKey b A \<notin> symKeys"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    67
by (simp add: symKeys_def)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    68
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    69
lemma not_symKeys_priK [iff]: "privateKey b A \<notin> symKeys"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    70
by (simp add: symKeys_def)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    71
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    72
lemma symKey_neq_priEK: "K \<in> symKeys ==> K \<noteq> priEK A"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    73
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    74
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    75
lemma symKeys_neq_imp_neq: "(K \<in> symKeys) \<noteq> (K' \<in> symKeys) ==> K \<noteq> K'"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    76
by blast
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    77
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    78
lemma symKeys_invKey_iff [iff]: "(invKey K \<in> symKeys) = (K \<in> symKeys)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    79
by (unfold symKeys_def, auto)
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    80
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    81
lemma analz_symKeys_Decrypt:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    82
     "[| Crypt K X \<in> analz H;  K \<in> symKeys;  Key K \<in> analz H |]  
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    83
      ==> X \<in> analz H"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    84
by (auto simp add: symKeys_def)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    85
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    86
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    87
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    88
subsection{*"Image" equations that hold for injective functions*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    89
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    90
lemma invKey_image_eq [simp]: "(invKey x \<in> invKey`A) = (x \<in> A)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    91
by auto
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    92
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    93
(*holds because invKey is injective*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    94
lemma publicKey_image_eq [simp]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    95
     "(publicKey b x \<in> publicKey c ` AA) = (b=c & x \<in> AA)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    96
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    97
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
    98
lemma privateKey_notin_image_publicKey [simp]: "privateKey b x \<notin> publicKey c ` AA"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    99
by auto
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   100
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   101
lemma privateKey_image_eq [simp]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   102
     "(privateKey b A \<in> invKey ` publicKey c ` AS) = (b=c & A\<in>AS)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   103
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   104
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   105
lemma publicKey_notin_image_privateKey [simp]: "publicKey b A \<notin> invKey ` publicKey c ` AS"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   106
by auto
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   107
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   108
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   109
subsection{*Symmetric Keys*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   110
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   111
text{*For some protocols, it is convenient to equip agents with symmetric as
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   112
well as asymmetric keys.  The theory @{text Shared} assumes that all keys
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   113
are symmetric.*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   114
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   115
consts
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   116
  shrK    :: "agent => key"    --{*long-term shared keys*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   117
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   118
axioms
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   119
  inj_shrK: "inj shrK"	             --{*No two agents have the same key*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   120
  sym_shrK [iff]: "shrK X \<in> symKeys" --{*All shared keys are symmetric*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   121
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   122
(*Injectiveness: Agents' long-term keys are distinct.*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   123
declare inj_shrK [THEN inj_eq, iff]
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   124
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   125
lemma priK_neq_shrK [iff]: "shrK A \<noteq> privateKey b C"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   126
by (simp add: symKeys_neq_imp_neq)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   127
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   128
declare priK_neq_shrK [THEN not_sym, simp]
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   129
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   130
lemma pubK_neq_shrK [iff]: "shrK A \<noteq> publicKey b C"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   131
by (simp add: symKeys_neq_imp_neq)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   132
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   133
declare pubK_neq_shrK [THEN not_sym, simp]
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   134
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   135
lemma priEK_noteq_shrK [simp]: "priEK A \<noteq> shrK B" 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   136
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   137
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   138
lemma publicKey_notin_image_shrK [simp]: "publicKey b x \<notin> shrK ` AA"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   139
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   140
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   141
lemma privateKey_notin_image_shrK [simp]: "privateKey b x \<notin> shrK ` AA"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   142
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   143
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   144
lemma shrK_notin_image_publicKey [simp]: "shrK x \<notin> publicKey b ` AA"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   145
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   146
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   147
lemma shrK_notin_image_privateKey [simp]: "shrK x \<notin> invKey ` publicKey b ` AA" 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   148
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   149
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   150
lemma shrK_image_eq [simp]: "(shrK x \<in> shrK ` AA) = (x \<in> AA)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   151
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   152
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   153
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   154
subsection{*Initial States of Agents*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   155
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   156
text{*Note: for all practical purposes, all that matters is the initial
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   157
knowledge of the Spy.  All other agents are automata, merely following the
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   158
protocol.*}
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   159
5183
89f162de39cf Adapted to new datatype package.
berghofe
parents: 3683
diff changeset
   160
primrec
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   161
        (*Agents know their private key and all public keys*)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   162
  initState_Server:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   163
    "initState Server     =    
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   164
       {Key (priEK Server), Key (priSK Server)} \<union> 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   165
       (Key ` range pubEK) \<union> (Key ` range pubSK) \<union> (Key ` range shrK)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   166
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   167
  initState_Friend:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   168
    "initState (Friend i) =    
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   169
       {Key (priEK(Friend i)), Key (priSK(Friend i)), Key (shrK(Friend i))} \<union> 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   170
       (Key ` range pubEK) \<union> (Key ` range pubSK)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   171
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   172
  initState_Spy:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   173
    "initState Spy        =    
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   174
       (Key ` invKey ` pubEK ` bad) \<union> (Key ` invKey ` pubSK ` bad) \<union> 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   175
       (Key ` shrK ` bad) \<union> 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   176
       (Key ` range pubEK) \<union> (Key ` range pubSK)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   177
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   178
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   179
text{*These lemmas allow reasoning about @{term "used evs"} rather than
13935
paulson
parents: 13926
diff changeset
   180
   @{term "knows Spy evs"}, which is useful when there are private Notes. 
paulson
parents: 13926
diff changeset
   181
   Because they depend upon the definition of @{term initState}, they cannot
paulson
parents: 13926
diff changeset
   182
   be moved up.*}
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   183
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   184
lemma used_parts_subset_parts [rule_format]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   185
     "\<forall>X \<in> used evs. parts {X} \<subseteq> used evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   186
apply (induct evs) 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   187
 prefer 2
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   188
 apply (simp add: used_Cons)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   189
 apply (rule ballI)  
13935
paulson
parents: 13926
diff changeset
   190
 apply (case_tac a, auto)  
paulson
parents: 13926
diff changeset
   191
apply (auto dest!: parts_cut) 
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   192
txt{*Base case*}
13935
paulson
parents: 13926
diff changeset
   193
apply (simp add: used_Nil) 
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   194
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   195
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   196
lemma MPair_used_D: "{|X,Y|} \<in> used H ==> X \<in> used H & Y \<in> used H"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   197
by (drule used_parts_subset_parts, simp, blast)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   198
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   199
lemma MPair_used [elim!]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   200
     "[| {|X,Y|} \<in> used H;
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   201
         [| X \<in> used H; Y \<in> used H |] ==> P |] 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   202
      ==> P"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   203
by (blast dest: MPair_used_D) 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   204
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   205
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   206
text{*Rewrites should not refer to  @{term "initState(Friend i)"} because
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   207
  that expression is not in normal form.*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   208
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   209
lemma keysFor_parts_initState [simp]: "keysFor (parts (initState C)) = {}"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   210
apply (unfold keysFor_def)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   211
apply (induct_tac "C")
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   212
apply (auto intro: range_eqI)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   213
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   214
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   215
lemma Crypt_notin_initState: "Crypt K X \<notin> parts (initState B)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   216
by (induct B, auto)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   217
13935
paulson
parents: 13926
diff changeset
   218
lemma Crypt_notin_used_empty [simp]: "Crypt K X \<notin> used []"
paulson
parents: 13926
diff changeset
   219
by (simp add: Crypt_notin_initState used_Nil)
paulson
parents: 13926
diff changeset
   220
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   221
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   222
(*** Basic properties of shrK ***)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   223
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   224
(*Agents see their own shared keys!*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   225
lemma shrK_in_initState [iff]: "Key (shrK A) \<in> initState A"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   226
by (induct_tac "A", auto)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   227
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   228
lemma shrK_in_knows [iff]: "Key (shrK A) \<in> knows A evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   229
by (simp add: initState_subset_knows [THEN subsetD])
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   230
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   231
lemma shrK_in_used [iff]: "Key (shrK A) \<in> used evs"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   232
by (rule initState_into_used, blast)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   233
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   234
(** Fresh keys never clash with long-term shared keys **)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   235
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   236
(*Used in parts_induct_tac and analz_Fake_tac to distinguish session keys
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   237
  from long-term shared keys*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   238
lemma Key_not_used: "Key K \<notin> used evs ==> K \<notin> range shrK"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   239
by blast
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   240
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   241
lemma shrK_neq: "Key K \<notin> used evs ==> shrK B \<noteq> K"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   242
by blast
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   243
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   244
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   245
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   246
subsection{*Function @{term spies} *}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   247
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   248
text{*Agents see their own private keys!*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   249
lemma priK_in_initState [iff]: "Key (privateKey b A) \<in> initState A"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   250
by (induct_tac "A", auto)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   251
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   252
text{*Agents see all public keys!*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   253
lemma publicKey_in_initState [iff]: "Key (publicKey b A) \<in> initState B"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   254
by (case_tac "B", auto)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   255
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   256
text{*All public keys are visible*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   257
lemma spies_pubK [iff]: "Key (publicKey b A) \<in> spies evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   258
apply (induct_tac "evs")
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   259
apply (simp_all add: imageI knows_Cons split add: event.split)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   260
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   261
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   262
declare spies_pubK [THEN analz.Inj, iff]
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   263
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   264
text{*Spy sees private keys of bad agents!*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   265
lemma Spy_spies_bad_privateKey [intro!]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   266
     "A \<in> bad ==> Key (privateKey b A) \<in> spies evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   267
apply (induct_tac "evs")
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   268
apply (simp_all add: imageI knows_Cons split add: event.split)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   269
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   270
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   271
text{*Spy sees long-term shared keys of bad agents!*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   272
lemma Spy_spies_bad_shrK [intro!]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   273
     "A \<in> bad ==> Key (shrK A) \<in> spies evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   274
apply (induct_tac "evs")
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   275
apply (simp_all add: imageI knows_Cons split add: event.split)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   276
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   277
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   278
lemma publicKey_into_used [iff] :"Key (publicKey b A) \<in> used evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   279
apply (rule initState_into_used)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   280
apply (rule publicKey_in_initState [THEN parts.Inj])
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   281
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   282
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   283
lemma privateKey_into_used [iff]: "Key (privateKey b A) \<in> used evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   284
apply(rule initState_into_used)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   285
apply(rule priK_in_initState [THEN parts.Inj])
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   286
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   287
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   288
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   289
subsection{*Fresh Nonces*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   290
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   291
lemma Nonce_notin_initState [iff]: "Nonce N \<notin> parts (initState B)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   292
by (induct_tac "B", auto)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   293
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   294
lemma Nonce_notin_used_empty [simp]: "Nonce N \<notin> used []"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   295
by (simp add: used_Nil)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   296
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 10833
diff changeset
   297
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   298
subsection{*Supply fresh nonces for possibility theorems*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   299
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   300
text{*In any trace, there is an upper bound N on the greatest nonce in use*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   301
lemma Nonce_supply_lemma: "EX N. ALL n. N<=n --> Nonce n \<notin> used evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   302
apply (induct_tac "evs")
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   303
apply (rule_tac x = 0 in exI)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   304
apply (simp_all (no_asm_simp) add: used_Cons split add: event.split)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   305
apply safe
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   306
apply (rule msg_Nonce_supply [THEN exE], blast elim!: add_leE)+
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   307
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   308
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   309
lemma Nonce_supply1: "EX N. Nonce N \<notin> used evs"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   310
by (rule Nonce_supply_lemma [THEN exE], blast)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   311
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   312
lemma Nonce_supply: "Nonce (@ N. Nonce N \<notin> used evs) \<notin> used evs"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   313
apply (rule Nonce_supply_lemma [THEN exE])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   314
apply (rule someI, fast)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   315
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   316
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   317
subsection{*Specialized rewriting for the analz_image_... theorems*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   318
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   319
lemma insert_Key_singleton: "insert (Key K) H = Key ` {K} Un H"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   320
by blast
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 10833
diff changeset
   321
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   322
lemma insert_Key_image: "insert (Key K) (Key`KK \<union> C) = Key ` (insert K KK) \<union> C"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   323
by blast
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   324
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   325
ML
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   326
{*
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   327
val Key_not_used = thm "Key_not_used";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   328
val insert_Key_singleton = thm "insert_Key_singleton";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   329
val insert_Key_image = thm "insert_Key_image";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   330
*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   331
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   332
(*
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   333
val not_symKeys_pubK = thm "not_symKeys_pubK";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   334
val not_symKeys_priK = thm "not_symKeys_priK";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   335
val symKeys_neq_imp_neq = thm "symKeys_neq_imp_neq";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   336
val analz_symKeys_Decrypt = thm "analz_symKeys_Decrypt";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   337
val invKey_image_eq = thm "invKey_image_eq";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   338
val pubK_image_eq = thm "pubK_image_eq";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   339
val priK_pubK_image_eq = thm "priK_pubK_image_eq";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   340
val keysFor_parts_initState = thm "keysFor_parts_initState";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   341
val priK_in_initState = thm "priK_in_initState";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   342
val spies_pubK = thm "spies_pubK";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   343
val Spy_spies_bad = thm "Spy_spies_bad";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   344
val Nonce_notin_initState = thm "Nonce_notin_initState";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   345
val Nonce_notin_used_empty = thm "Nonce_notin_used_empty";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   346
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   347
*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   348
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   349
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   350
lemma invKey_K [simp]: "K \<in> symKeys ==> invKey K = K"
11287
0103ee3082bf conversion of Auth/TLS to Isar script
paulson
parents: 11270
diff changeset
   351
by (simp add: symKeys_def)
0103ee3082bf conversion of Auth/TLS to Isar script
paulson
parents: 11270
diff changeset
   352
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   353
lemma Crypt_imp_keysFor :"[|K \<in> symKeys; Crypt K X \<in> H|] ==> K \<in> keysFor H"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   354
by (drule Crypt_imp_invKey_keysFor, simp)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   355
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   356
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   357
subsection{*Specialized Methods for Possibility Theorems*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   358
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   359
ML
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   360
{*
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   361
val Nonce_supply1 = thm "Nonce_supply1";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   362
val Nonce_supply = thm "Nonce_supply";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   363
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   364
(*Tactic for possibility theorems (Isar interface)*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   365
fun gen_possibility_tac ss state = state |>
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   366
    REPEAT (*omit used_Says so that Nonces start from different traces!*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   367
    (ALLGOALS (simp_tac (ss delsimps [used_Says]))
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   368
     THEN
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   369
     REPEAT_FIRST (eq_assume_tac ORELSE' 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   370
                   resolve_tac [refl, conjI, Nonce_supply]))
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   371
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   372
(*Tactic for possibility theorems (ML script version)*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   373
fun possibility_tac state = gen_possibility_tac (simpset()) state
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   374
*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 10833
diff changeset
   375
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 10833
diff changeset
   376
method_setup possibility = {*
11270
a315a3862bb4 better treatment of methods: uses Method.ctxt_args to refer to current
paulson
parents: 11104
diff changeset
   377
    Method.ctxt_args (fn ctxt =>
a315a3862bb4 better treatment of methods: uses Method.ctxt_args to refer to current
paulson
parents: 11104
diff changeset
   378
        Method.METHOD (fn facts =>
a315a3862bb4 better treatment of methods: uses Method.ctxt_args to refer to current
paulson
parents: 11104
diff changeset
   379
            gen_possibility_tac (Simplifier.get_local_simpset ctxt))) *}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 10833
diff changeset
   380
    "for proving possibility theorems"
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   381
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   382
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   383
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   384
lemmas analz_image_freshK_simps =
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   385
       simp_thms mem_simps --{*these two allow its use with @{text "only:"}*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   386
       disj_comms 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   387
       image_insert [THEN sym] image_Un [THEN sym] empty_subsetI insert_subset
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   388
       analz_insert_eq Un_upper2 [THEN analz_mono, THEN [2] rev_subsetD]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   389
       insert_Key_singleton 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   390
       Key_not_used insert_Key_image Un_assoc [THEN sym]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   391
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   392
ML
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   393
{*
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   394
val analz_image_freshK_ss =
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   395
     simpset() delsimps [image_insert, image_Un]
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   396
	       delsimps [imp_disjL]    (*reduces blow-up*)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   397
	       addsimps thms"analz_image_freshK_simps"
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   398
*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11287
diff changeset
   399
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   400
axioms
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   401
  Key_supply_ax:  "finite KK ==> \<exists>K\<in>symKeys. K \<notin> KK & Key K \<notin> used evs"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   402
  --{*Unlike the corresponding property of nonces, this cannot be proved.
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   403
    We have infinitely many agents and there is nothing to stop their
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   404
    long-term keys from exhausting all the natural numbers.  The axiom
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   405
    assumes that their keys are dispersed so as to leave room for infinitely
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   406
    many fresh session keys.  We could, alternatively, restrict agents to
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   407
    an unspecified finite number.  We could however replace @{term"used evs"} 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   408
    by @{term "used []"}.*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   409
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   410
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   411
lemma Key_supply1: "\<exists>K\<in>symKeys. Key K \<notin> used evs"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   412
by (rule Finites.emptyI [THEN Key_supply_ax, THEN bexE], blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   413
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   414
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   415
end