diff -r 143f58bb34f9 -r 0909deb8059b src/HOL/SET_Protocol/Public_SET.thy --- a/src/HOL/SET_Protocol/Public_SET.thy Thu May 26 16:57:14 2016 +0200 +++ b/src/HOL/SET_Protocol/Public_SET.thy Thu May 26 17:51:22 2016 +0200 @@ -4,24 +4,24 @@ Author: Lawrence C Paulson *) -section{*The Public-Key Theory, Modified for SET*} +section\The Public-Key Theory, Modified for SET\ theory Public_SET imports Event_SET begin -subsection{*Symmetric and Asymmetric Keys*} +subsection\Symmetric and Asymmetric Keys\ -text{*definitions influenced by the wish to assign asymmetric keys +text\definitions influenced by the wish to assign asymmetric keys - since the beginning - only to RCA and CAs, namely we need a partial - function on type Agent*} + function on type Agent\ -text{*The SET specs mention two signature keys for CAs - we only have one*} +text\The SET specs mention two signature keys for CAs - we only have one\ consts publicKey :: "[bool, agent] => key" - --{*the boolean is TRUE if a signing key*} + \\the boolean is TRUE if a signing key\ abbreviation "pubEK == publicKey False" abbreviation "pubSK == publicKey True" @@ -30,8 +30,8 @@ abbreviation "priEK A == invKey (pubEK A)" abbreviation "priSK A == invKey (pubSK A)" -text{*By freeness of agents, no two agents have the same key. Since - @{term "True\False"}, no agent has the same signing and encryption keys.*} +text\By freeness of agents, no two agents have the same key. Since + @{term "True\False"}, no agent has the same signing and encryption keys.\ specification (publicKey) injective_publicKey: @@ -55,15 +55,15 @@ declare privateKey_neq_publicKey [THEN not_sym, iff] -subsection{*Initial Knowledge*} +subsection\Initial Knowledge\ -text{*This information is not necessary. Each protocol distributes any needed +text\This information is not necessary. Each protocol distributes any needed certificates, and anyway our proofs require a formalization of the Spy's knowledge only. However, the initial knowledge is as follows: All agents know RCA's public keys; RCA and CAs know their own respective keys; RCA (has already certified and therefore) knows all CAs public keys; - Spy knows all keys of all bad agents.*} + Spy knows all keys of all bad agents.\ overloading initState \ "initState" begin @@ -104,13 +104,13 @@ end -text{*Injective mapping from agents to PANs: an agent can have only one card*} +text\Injective mapping from agents to PANs: an agent can have only one card\ consts pan :: "agent => nat" specification (pan) inj_pan: "inj pan" - --{*No two agents have the same PAN*} + \\No two agents have the same PAN\ (*<*) apply (rule exI [of _ "nat_of_agent"]) apply (simp add: inj_on_def inj_nat_of_agent [THEN inj_eq]) @@ -120,10 +120,10 @@ declare inj_pan [THEN inj_eq, iff] consts - XOR :: "nat*nat => nat" --{*no properties are assumed of exclusive-or*} + XOR :: "nat*nat => nat" \\no properties are assumed of exclusive-or\ -subsection{*Signature Primitives*} +subsection\Signature Primitives\ definition (* Signature = Message + signed Digest *) @@ -167,22 +167,22 @@ abbreviation "onlySig == Number (Suc 0)" abbreviation "authCode == Number (Suc (Suc 0))" -subsection{*Encryption Primitives*} +subsection\Encryption Primitives\ definition EXcrypt :: "[key,key,msg,msg] => msg" where - --{*Extra Encryption*} + \\Extra Encryption\ (*K: the symmetric key EK: the public encryption key*) "EXcrypt K EK M m = \Crypt K \M, Hash m\, Crypt EK \Key K, m\\" definition EXHcrypt :: "[key,key,msg,msg] => msg" where - --{*Extra Encryption with Hashing*} + \\Extra Encryption with Hashing\ (*K: the symmetric key EK: the public encryption key*) "EXHcrypt K EK M m = \Crypt K \M, Hash m\, Crypt EK \Key K, m, Hash M\\" definition Enc :: "[key,key,key,msg] => msg" where - --{*Simple Encapsulation with SIGNATURE*} + \\Simple Encapsulation with SIGNATURE\ (*SK: the sender's signing key K: the symmetric key EK: the public encryption key*) @@ -190,12 +190,12 @@ \Crypt K (sign SK M), Crypt EK (Key K)\" definition EncB :: "[key,key,key,msg,msg] => msg" where - --{*Encapsulation with Baggage. Keys as above, and baggage b.*} + \\Encapsulation with Baggage. Keys as above, and baggage b.\ "EncB SK K EK M b = \Enc SK K EK \M, Hash b\, b\" -subsection{*Basic Properties of pubEK, pubSK, priEK and priSK *} +subsection\Basic Properties of pubEK, pubSK, priEK and priSK\ lemma publicKey_eq_iff [iff]: "(publicKey b A = publicKey b' A') = (b=b' & A=A')" @@ -217,12 +217,12 @@ lemma symKeys_invKey_iff [simp]: "(invKey K \ symKeys) = (K \ symKeys)" by (unfold symKeys_def, auto) -text{*Can be slow (or even loop) as a simprule*} +text\Can be slow (or even loop) as a simprule\ lemma symKeys_neq_imp_neq: "(K \ symKeys) \ (K' \ symKeys) ==> K \ K'" by blast -text{*These alternatives to @{text symKeys_neq_imp_neq} don't seem any better -in practice.*} +text\These alternatives to \symKeys_neq_imp_neq\ don't seem any better +in practice.\ lemma publicKey_neq_symKey: "K \ symKeys ==> publicKey b A \ K" by blast @@ -241,12 +241,12 @@ by auto -subsection{*"Image" Equations That Hold for Injective Functions *} +subsection\"Image" Equations That Hold for Injective Functions\ lemma invKey_image_eq [iff]: "(invKey x \ invKey`A) = (x\A)" by auto -text{*holds because invKey is injective*} +text\holds because invKey is injective\ lemma publicKey_image_eq [iff]: "(publicKey b A \ publicKey c ` AS) = (b=c & A\AS)" by auto @@ -269,7 +269,7 @@ apply (auto intro: range_eqI) done -text{*for proving @{text new_keys_not_used}*} +text\for proving \new_keys_not_used\\ lemma keysFor_parts_insert: "[| K \ keysFor (parts (insert X H)); X \ synth (analz H) |] ==> K \ keysFor (parts H) | Key (invKey K) \ parts H" @@ -282,22 +282,22 @@ "[|K \ symKeys; Crypt K X \ H|] ==> K \ keysFor H" by (drule Crypt_imp_invKey_keysFor, simp) -text{*Agents see their own private keys!*} +text\Agents see their own private keys!\ lemma privateKey_in_initStateCA [iff]: "Key (invKey (publicKey b A)) \ initState A" by (case_tac "A", auto) -text{*Agents see their own public keys!*} +text\Agents see their own public keys!\ lemma publicKey_in_initStateCA [iff]: "Key (publicKey b A) \ initState A" by (case_tac "A", auto) -text{*RCA sees CAs' public keys! *} +text\RCA sees CAs' public keys!\ lemma pubK_CA_in_initState_RCA [iff]: "Key (publicKey b (CA i)) \ initState RCA" by auto -text{*Spy knows all public keys*} +text\Spy knows all public keys\ lemma knows_Spy_pubEK_i [iff]: "Key (publicKey b A) \ knows Spy evs" apply (induct_tac "evs") apply (simp_all add: imageI knows_Cons split add: event.split) @@ -306,13 +306,13 @@ declare knows_Spy_pubEK_i [THEN analz.Inj, iff] (*needed????*) -text{*Spy sees private keys of bad agents! [and obviously public keys too]*} +text\Spy sees private keys of bad agents! [and obviously public keys too]\ lemma knows_Spy_bad_privateKey [intro!]: "A \ bad ==> Key (invKey (publicKey b A)) \ knows Spy evs" by (rule initState_subset_knows [THEN subsetD], simp) -subsection{*Fresh Nonces for Possibility Theorems*} +subsection\Fresh Nonces for Possibility Theorems\ lemma Nonce_notin_initState [iff]: "Nonce N \ parts (initState B)" by (induct_tac "B", auto) @@ -320,7 +320,7 @@ lemma Nonce_notin_used_empty [simp]: "Nonce N \ used []" by (simp add: used_Nil) -text{*In any trace, there is an upper bound N on the greatest nonce in use.*} +text\In any trace, there is an upper bound N on the greatest nonce in use.\ lemma Nonce_supply_lemma: "\N. \n. N<=n --> Nonce n \ used evs" apply (induct_tac "evs") apply (rule_tac x = 0 in exI) @@ -337,10 +337,10 @@ done -subsection{*Specialized Methods for Possibility Theorems*} +subsection\Specialized Methods for Possibility Theorems\ ML -{* +\ (*Tactic for possibility theorems*) fun possibility_tac ctxt = REPEAT (*omit used_Says so that Nonces start from different traces!*) @@ -356,18 +356,18 @@ (ALLGOALS (asm_simp_tac (ctxt setSolver safe_solver)) THEN REPEAT_FIRST (resolve_tac ctxt [refl, conjI])) -*} +\ -method_setup possibility = {* - Scan.succeed (SIMPLE_METHOD o possibility_tac) *} +method_setup possibility = \ + Scan.succeed (SIMPLE_METHOD o possibility_tac)\ "for proving possibility theorems" -method_setup basic_possibility = {* - Scan.succeed (SIMPLE_METHOD o basic_possibility_tac) *} +method_setup basic_possibility = \ + Scan.succeed (SIMPLE_METHOD o basic_possibility_tac)\ "for proving possibility theorems" -subsection{*Specialized Rewriting for Theorems About @{term analz} and Image*} +subsection\Specialized Rewriting for Theorems About @{term analz} and Image\ lemma insert_Key_singleton: "insert (Key K) H = Key ` {K} Un H" by blast @@ -376,17 +376,17 @@ "insert (Key K) (Key`KK Un C) = Key ` (insert K KK) Un C" by blast -text{*Needed for @{text DK_fresh_not_KeyCryptKey}*} +text\Needed for \DK_fresh_not_KeyCryptKey\\ lemma publicKey_in_used [iff]: "Key (publicKey b A) \ used evs" by auto lemma privateKey_in_used [iff]: "Key (invKey (publicKey b A)) \ used evs" by (blast intro!: initState_into_used) -text{*Reverse the normal simplification of "image" to build up (not break down) - the set of keys. Based on @{text analz_image_freshK_ss}, but simpler.*} +text\Reverse the normal simplification of "image" to build up (not break down) + the set of keys. Based on \analz_image_freshK_ss\, but simpler.\ lemmas analz_image_keys_simps = - simp_thms mem_simps --{*these two allow its use with @{text "only:"}*} + simp_thms mem_simps \\these two allow its use with \only:\\ image_insert [THEN sym] image_Un [THEN sym] rangeI symKeys_neq_imp_neq insert_Key_singleton insert_Key_image Un_assoc [THEN sym] @@ -394,16 +394,16 @@ (*General lemmas proved by Larry*) -subsection{*Controlled Unfolding of Abbreviations*} +subsection\Controlled Unfolding of Abbreviations\ -text{*A set is expanded only if a relation is applied to it*} +text\A set is expanded only if a relation is applied to it\ lemma def_abbrev_simp_relation: "A = B ==> (A \ X) = (B \ X) & (u = A) = (u = B) & (A = u) = (B = u)" by auto -text{*A set is expanded only if one of the given functions is applied to it*} +text\A set is expanded only if one of the given functions is applied to it\ lemma def_abbrev_simp_function: "A = B ==> parts (insert A X) = parts (insert B X) & @@ -411,15 +411,15 @@ keysFor (insert A X) = keysFor (insert B X)" by auto -subsubsection{*Special Simplification Rules for @{term signCert}*} +subsubsection\Special Simplification Rules for @{term signCert}\ -text{*Avoids duplicating X and its components!*} +text\Avoids duplicating X and its components!\ lemma parts_insert_signCert: "parts (insert (signCert K X) H) = insert \X, Crypt K X\ (parts (insert (Crypt K X) H))" by (simp add: signCert_def insert_commute [of X]) -text{*Avoids a case split! [X is always available]*} +text\Avoids a case split! [X is always available]\ lemma analz_insert_signCert: "analz (insert (signCert K X) H) = insert \X, Crypt K X\ (insert (Crypt K X) (analz (insert X H)))" @@ -428,9 +428,9 @@ lemma keysFor_insert_signCert: "keysFor (insert (signCert K X) H) = keysFor H" by (simp add: signCert_def) -text{*Controlled rewrite rules for @{term signCert}, just the definitions +text\Controlled rewrite rules for @{term signCert}, just the definitions of the others. Encryption primitives are just expanded, despite their huge - redundancy!*} + redundancy!\ lemmas abbrev_simps [simp] = parts_insert_signCert analz_insert_signCert keysFor_insert_signCert sign_def [THEN def_abbrev_simp_relation] @@ -451,7 +451,7 @@ EncB_def [THEN def_abbrev_simp_function] -subsubsection{*Elimination Rules for Controlled Rewriting *} +subsubsection\Elimination Rules for Controlled Rewriting\ lemma Enc_partsE: "!!R. [|Enc SK K EK M \ parts H; @@ -477,7 +477,7 @@ by (unfold EXcrypt_def, blast) -subsection{*Lemmas to Simplify Expressions Involving @{term analz} *} +subsection\Lemmas to Simplify Expressions Involving @{term analz}\ lemma analz_knows_absorb: "Key K \ analz (knows Spy evs) @@ -505,13 +505,13 @@ subset_insertI [THEN [2] subset_trans] -subsection{*Freshness Lemmas*} +subsection\Freshness Lemmas\ lemma in_parts_Says_imp_used: "[|Key K \ parts {X}; Says A B X \ set evs|] ==> Key K \ used evs" by (blast intro: parts_trans dest!: Says_imp_knows_Spy [THEN parts.Inj]) -text{*A useful rewrite rule with @{term analz_image_keys_simps}*} +text\A useful rewrite rule with @{term analz_image_keys_simps}\ lemma Crypt_notin_image_Key: "Crypt K X \ Key ` KK" by auto