src/Doc/Tutorial/Protocol/Public.thy
changeset 67613 ce654b0e6d69
parent 67406 23307fd33906
child 69505 cc2d676d5395
equal deleted inserted replaced
67610:4939494ed791 67613:ce654b0e6d69
    30   initState_Server:  "initState Server     =    
    30   initState_Server:  "initState Server     =    
    31                          insert (Key (priK Server)) (Key ` range pubK)"
    31                          insert (Key (priK Server)) (Key ` range pubK)"
    32 | initState_Friend:  "initState (Friend i) =    
    32 | initState_Friend:  "initState (Friend i) =    
    33                          insert (Key (priK (Friend i))) (Key ` range pubK)"
    33                          insert (Key (priK (Friend i))) (Key ` range pubK)"
    34 | initState_Spy:     "initState Spy        =    
    34 | initState_Spy:     "initState Spy        =    
    35                          (Key`invKey`pubK`bad) Un (Key ` range pubK)"
    35                          (Key`invKey`pubK`bad) \<union> (Key ` range pubK)"
    36 
    36 
    37 end
    37 end
    38 (*>*)
    38 (*>*)
    39 
    39 
    40 text \<open>
    40 text \<open>
    75   by (auto simp add: symKeys_def)
    75   by (auto simp add: symKeys_def)
    76 
    76 
    77 
    77 
    78 (** "Image" equations that hold for injective functions **)
    78 (** "Image" equations that hold for injective functions **)
    79 
    79 
    80 lemma invKey_image_eq[simp]: "(invKey x : invKey`A) = (x:A)"
    80 lemma invKey_image_eq[simp]: "(invKey x \<in> invKey`A) = (x\<in>A)"
    81   by auto
    81   by auto
    82 
    82 
    83 (*holds because invKey is injective*)
    83 (*holds because invKey is injective*)
    84 lemma pubK_image_eq[simp]: "(pubK x : pubK`A) = (x:A)"
    84 lemma pubK_image_eq[simp]: "(pubK x \<in> pubK`A) = (x\<in>A)"
    85   by auto
    85   by auto
    86 
    86 
    87 lemma priK_pubK_image_eq[simp]: "(priK x ~: pubK`A)"
    87 lemma priK_pubK_image_eq[simp]: "(priK x \<notin> pubK`A)"
    88   by auto
    88   by auto
    89 
    89 
    90 
    90 
    91 (** Rewrites should not refer to  initState(Friend i) 
    91 (** Rewrites should not refer to  initState(Friend i) 
    92     -- not in normal form! **)
    92     -- not in normal form! **)
    99 
    99 
   100 
   100 
   101 (*** Function "spies" ***)
   101 (*** Function "spies" ***)
   102 
   102 
   103 (*Agents see their own private keys!*)
   103 (*Agents see their own private keys!*)
   104 lemma priK_in_initState[iff]: "Key (priK A) : initState A"
   104 lemma priK_in_initState[iff]: "Key (priK A) \<in> initState A"
   105   by (induct A) auto
   105   by (induct A) auto
   106 
   106 
   107 (*All public keys are visible*)
   107 (*All public keys are visible*)
   108 lemma spies_pubK[iff]: "Key (pubK A) : spies evs"
   108 lemma spies_pubK[iff]: "Key (pubK A) \<in> spies evs"
   109   by (induct evs) (simp_all add: imageI knows_Cons split: event.split)
   109   by (induct evs) (simp_all add: imageI knows_Cons split: event.split)
   110 
   110 
   111 (*Spy sees private keys of bad agents!*)
   111 (*Spy sees private keys of bad agents!*)
   112 lemma Spy_spies_bad[intro!]: "A: bad ==> Key (priK A) : spies evs"
   112 lemma Spy_spies_bad[intro!]: "A \<in> bad \<Longrightarrow> Key (priK A) \<in> spies evs"
   113   by (induct evs) (simp_all add: imageI knows_Cons split: event.split)
   113   by (induct evs) (simp_all add: imageI knows_Cons split: event.split)
   114 
   114 
   115 lemmas [iff] = spies_pubK [THEN analz.Inj]
   115 lemmas [iff] = spies_pubK [THEN analz.Inj]
   116 
   116 
   117 
   117 
   118 (*** Fresh nonces ***)
   118 (*** Fresh nonces ***)
   119 
   119 
   120 lemma Nonce_notin_initState[iff]: "Nonce N ~: parts (initState B)"
   120 lemma Nonce_notin_initState[iff]: "Nonce N \<notin> parts (initState B)"
   121   by (induct B) auto
   121   by (induct B) auto
   122 
   122 
   123 lemma Nonce_notin_used_empty[simp]: "Nonce N ~: used []"
   123 lemma Nonce_notin_used_empty[simp]: "Nonce N \<notin> used []"
   124   by (simp add: used_Nil)
   124   by (simp add: used_Nil)
   125 
   125 
   126 
   126 
   127 (*** Supply fresh nonces for possibility theorems. ***)
   127 (*** Supply fresh nonces for possibility theorems. ***)
   128 
   128 
   129 (*In any trace, there is an upper bound N on the greatest nonce in use.*)
   129 (*In any trace, there is an upper bound N on the greatest nonce in use.*)
   130 lemma Nonce_supply_lemma: "EX N. ALL n. N<=n --> Nonce n \<notin> used evs"
   130 lemma Nonce_supply_lemma: "\<exists>N. \<forall>n. N\<le>n \<longrightarrow> Nonce n \<notin> used evs"
   131 apply (induct_tac "evs")
   131 apply (induct_tac "evs")
   132 apply (rule_tac x = 0 in exI)
   132 apply (rule_tac x = 0 in exI)
   133 apply (simp_all (no_asm_simp) add: used_Cons split: event.split)
   133 apply (simp_all (no_asm_simp) add: used_Cons split: event.split)
   134 apply safe
   134 apply safe
   135 apply (rule msg_Nonce_supply [THEN exE], blast elim!: add_leE)+
   135 apply (rule msg_Nonce_supply [THEN exE], blast elim!: add_leE)+
   136 done
   136 done
   137 
   137 
   138 lemma Nonce_supply1: "EX N. Nonce N \<notin> used evs"
   138 lemma Nonce_supply1: "\<exists>N. Nonce N \<notin> used evs"
   139 by (rule Nonce_supply_lemma [THEN exE], blast)
   139 by (rule Nonce_supply_lemma [THEN exE], blast)
   140 
   140 
   141 lemma Nonce_supply: "Nonce (@ N. Nonce N \<notin> used evs) \<notin> used evs"
   141 lemma Nonce_supply: "Nonce (SOME N. Nonce N \<notin> used evs) \<notin> used evs"
   142 apply (rule Nonce_supply_lemma [THEN exE])
   142 apply (rule Nonce_supply_lemma [THEN exE])
   143 apply (rule someI, fast)
   143 apply (rule someI, fast)
   144 done
   144 done
   145 
   145 
   146 
   146 
   147 (*** Specialized rewriting for the analz_image_... theorems ***)
   147 (*** Specialized rewriting for the analz_image_... theorems ***)
   148 
   148 
   149 lemma insert_Key_singleton: "insert (Key K) H = Key ` {K} Un H"
   149 lemma insert_Key_singleton: "insert (Key K) H = Key ` {K} \<union> H"
   150   by blast
   150   by blast
   151 
   151 
   152 lemma insert_Key_image: "insert (Key K) (Key`KK Un C) = Key ` (insert K KK) Un C"
   152 lemma insert_Key_image: "insert (Key K) (Key`KK \<union> C) = Key ` (insert K KK) \<union> C"
   153   by blast
   153   by blast
   154 
   154 
   155 
   155 
   156 (*Specialized methods*)
   156 (*Specialized methods*)
   157 
   157