src/HOL/Auth/Guard/Guard_Shared.thy
author wenzelm
Fri Feb 18 16:07:32 2011 +0100 (2011-02-18)
changeset 41775 6214816d79d3
parent 41413 64cd30d6b0b8
child 56681 e8d5d60d655e
permissions -rw-r--r--
standardized headers;
wenzelm@41775
     1
(*  Title:      HOL/Auth/Guard/Guard_Shared.thy
wenzelm@41775
     2
    Author:     Frederic Blanqui, University of Cambridge Computer Laboratory
wenzelm@41775
     3
    Copyright   2002  University of Cambridge
wenzelm@41775
     4
*)
paulson@13508
     5
paulson@13508
     6
header{*lemmas on guarded messages for protocols with symmetric keys*}
paulson@13508
     7
wenzelm@41413
     8
theory Guard_Shared imports Guard GuardK "../Shared" begin
paulson@13508
     9
paulson@13508
    10
subsection{*Extensions to Theory @{text Shared}*}
paulson@13508
    11
paulson@13508
    12
declare initState.simps [simp del]
paulson@13508
    13
paulson@13508
    14
subsubsection{*a little abbreviation*}
paulson@13508
    15
wenzelm@19363
    16
abbreviation
wenzelm@21404
    17
  Ciph :: "agent => msg => msg" where
wenzelm@19363
    18
  "Ciph A X == Crypt (shrK A) X"
paulson@13508
    19
paulson@13508
    20
subsubsection{*agent associated to a key*}
paulson@13508
    21
haftmann@35416
    22
definition agt :: "key => agent" where
paulson@13508
    23
"agt K == @A. K = shrK A"
paulson@13508
    24
paulson@13508
    25
lemma agt_shrK [simp]: "agt (shrK A) = A"
paulson@13508
    26
by (simp add: agt_def)
paulson@13508
    27
paulson@13508
    28
subsubsection{*basic facts about @{term initState}*}
paulson@13508
    29
paulson@13508
    30
lemma no_Crypt_in_parts_init [simp]: "Crypt K X ~:parts (initState A)"
paulson@13508
    31
by (cases A, auto simp: initState.simps)
paulson@13508
    32
paulson@13508
    33
lemma no_Crypt_in_analz_init [simp]: "Crypt K X ~:analz (initState A)"
paulson@13508
    34
by auto
paulson@13508
    35
paulson@13508
    36
lemma no_shrK_in_analz_init [simp]: "A ~:bad
paulson@13508
    37
==> Key (shrK A) ~:analz (initState Spy)"
paulson@13508
    38
by (auto simp: initState.simps)
paulson@13508
    39
paulson@13508
    40
lemma shrK_notin_initState_Friend [simp]: "A ~= Friend C
paulson@13508
    41
==> Key (shrK A) ~: parts (initState (Friend C))"
paulson@13508
    42
by (auto simp: initState.simps)
paulson@13508
    43
paulson@13508
    44
lemma keyset_init [iff]: "keyset (initState A)"
paulson@13508
    45
by (cases A, auto simp: keyset_def initState.simps)
paulson@13508
    46
paulson@13508
    47
subsubsection{*sets of symmetric keys*}
paulson@13508
    48
haftmann@35416
    49
definition shrK_set :: "key set => bool" where
paulson@13508
    50
"shrK_set Ks == ALL K. K:Ks --> (EX A. K = shrK A)"
paulson@13508
    51
paulson@13508
    52
lemma in_shrK_set: "[| shrK_set Ks; K:Ks |] ==> EX A. K = shrK A"
paulson@13508
    53
by (simp add: shrK_set_def)
paulson@13508
    54
paulson@13508
    55
lemma shrK_set1 [iff]: "shrK_set {shrK A}"
paulson@13508
    56
by (simp add: shrK_set_def)
paulson@13508
    57
paulson@13508
    58
lemma shrK_set2 [iff]: "shrK_set {shrK A, shrK B}"
paulson@13508
    59
by (simp add: shrK_set_def)
paulson@13508
    60
paulson@13508
    61
subsubsection{*sets of good keys*}
paulson@13508
    62
haftmann@35416
    63
definition good :: "key set => bool" where
paulson@13508
    64
"good Ks == ALL K. K:Ks --> agt K ~:bad"
paulson@13508
    65
paulson@13508
    66
lemma in_good: "[| good Ks; K:Ks |] ==> agt K ~:bad"
paulson@13508
    67
by (simp add: good_def)
paulson@13508
    68
paulson@13508
    69
lemma good1 [simp]: "A ~:bad ==> good {shrK A}"
paulson@13508
    70
by (simp add: good_def)
paulson@13508
    71
paulson@13508
    72
lemma good2 [simp]: "[| A ~:bad; B ~:bad |] ==> good {shrK A, shrK B}"
paulson@13508
    73
by (simp add: good_def)
paulson@13508
    74
paulson@13508
    75
paulson@13508
    76
subsection{*Proofs About Guarded Messages*}
paulson@13508
    77
paulson@13508
    78
subsubsection{*small hack*}
paulson@13508
    79
paulson@13508
    80
lemma shrK_is_invKey_shrK: "shrK A = invKey (shrK A)"
paulson@13508
    81
by simp
paulson@13508
    82
paulson@13508
    83
lemmas shrK_is_invKey_shrK_substI = shrK_is_invKey_shrK [THEN ssubst]
paulson@13508
    84
paulson@13508
    85
lemmas invKey_invKey_substI = invKey [THEN ssubst]
paulson@13508
    86
paulson@13508
    87
lemma "Nonce n:parts {X} ==> Crypt (shrK A) X:guard n {shrK A}"
paulson@13508
    88
apply (rule shrK_is_invKey_shrK_substI, rule invKey_invKey_substI)
paulson@13508
    89
by (rule Guard_Nonce, simp+)
paulson@13508
    90
paulson@13508
    91
subsubsection{*guardedness results on nonces*}
paulson@13508
    92
paulson@13508
    93
lemma guard_ciph [simp]: "shrK A:Ks ==> Ciph A X:guard n Ks"
paulson@13508
    94
by (rule Guard_Nonce, simp)
paulson@13508
    95
wenzelm@13523
    96
lemma guardK_ciph [simp]: "shrK A:Ks ==> Ciph A X:guardK n Ks"
paulson@13508
    97
by (rule Guard_Key, simp)
paulson@13508
    98
paulson@13508
    99
lemma Guard_init [iff]: "Guard n Ks (initState B)"
paulson@13508
   100
by (induct B, auto simp: Guard_def initState.simps)
paulson@13508
   101
paulson@13508
   102
lemma Guard_knows_max': "Guard n Ks (knows_max' C evs)
paulson@13508
   103
==> Guard n Ks (knows_max C evs)"
paulson@13508
   104
by (simp add: knows_max_def)
paulson@13508
   105
paulson@13508
   106
lemma Nonce_not_used_Guard_spies [dest]: "Nonce n ~:used evs
paulson@13508
   107
==> Guard n Ks (spies evs)"
paulson@13508
   108
by (auto simp: Guard_def dest: not_used_not_known parts_sub)
paulson@13508
   109
paulson@13508
   110
lemma Nonce_not_used_Guard [dest]: "[| evs:p; Nonce n ~:used evs;
paulson@13508
   111
Gets_correct p; one_step p |] ==> Guard n Ks (knows (Friend C) evs)"
paulson@13508
   112
by (auto simp: Guard_def dest: known_used parts_trans)
paulson@13508
   113
paulson@13508
   114
lemma Nonce_not_used_Guard_max [dest]: "[| evs:p; Nonce n ~:used evs;
paulson@13508
   115
Gets_correct p; one_step p |] ==> Guard n Ks (knows_max (Friend C) evs)"
paulson@13508
   116
by (auto simp: Guard_def dest: known_max_used parts_trans)
paulson@13508
   117
paulson@13508
   118
lemma Nonce_not_used_Guard_max' [dest]: "[| evs:p; Nonce n ~:used evs;
paulson@13508
   119
Gets_correct p; one_step p |] ==> Guard n Ks (knows_max' (Friend C) evs)"
paulson@13508
   120
apply (rule_tac H="knows_max (Friend C) evs" in Guard_mono)
paulson@13508
   121
by (auto simp: knows_max_def)
paulson@13508
   122
paulson@13508
   123
subsubsection{*guardedness results on keys*}
paulson@13508
   124
paulson@13508
   125
lemma GuardK_init [simp]: "n ~:range shrK ==> GuardK n Ks (initState B)"
paulson@13508
   126
by (induct B, auto simp: GuardK_def initState.simps)
paulson@13508
   127
paulson@13508
   128
lemma GuardK_knows_max': "[| GuardK n A (knows_max' C evs); n ~:range shrK |]
paulson@13508
   129
==> GuardK n A (knows_max C evs)"
paulson@13508
   130
by (simp add: knows_max_def)
paulson@13508
   131
paulson@13508
   132
lemma Key_not_used_GuardK_spies [dest]: "Key n ~:used evs
paulson@13508
   133
==> GuardK n A (spies evs)"
paulson@13508
   134
by (auto simp: GuardK_def dest: not_used_not_known parts_sub)
paulson@13508
   135
paulson@13508
   136
lemma Key_not_used_GuardK [dest]: "[| evs:p; Key n ~:used evs;
paulson@13508
   137
Gets_correct p; one_step p |] ==> GuardK n A (knows (Friend C) evs)"
paulson@13508
   138
by (auto simp: GuardK_def dest: known_used parts_trans)
paulson@13508
   139
paulson@13508
   140
lemma Key_not_used_GuardK_max [dest]: "[| evs:p; Key n ~:used evs;
paulson@13508
   141
Gets_correct p; one_step p |] ==> GuardK n A (knows_max (Friend C) evs)"
paulson@13508
   142
by (auto simp: GuardK_def dest: known_max_used parts_trans)
paulson@13508
   143
paulson@13508
   144
lemma Key_not_used_GuardK_max' [dest]: "[| evs:p; Key n ~:used evs;
paulson@13508
   145
Gets_correct p; one_step p |] ==> GuardK n A (knows_max' (Friend C) evs)"
paulson@13508
   146
apply (rule_tac H="knows_max (Friend C) evs" in GuardK_mono)
paulson@13508
   147
by (auto simp: knows_max_def)
paulson@13508
   148
paulson@13508
   149
subsubsection{*regular protocols*}
paulson@13508
   150
haftmann@35416
   151
definition regular :: "event list set => bool" where
paulson@13508
   152
"regular p == ALL evs A. evs:p --> (Key (shrK A):parts (spies evs)) = (A:bad)"
paulson@13508
   153
paulson@13508
   154
lemma shrK_parts_iff_bad [simp]: "[| evs:p; regular p |] ==>
paulson@13508
   155
(Key (shrK A):parts (spies evs)) = (A:bad)"
paulson@13508
   156
by (auto simp: regular_def)
paulson@13508
   157
paulson@13508
   158
lemma shrK_analz_iff_bad [simp]: "[| evs:p; regular p |] ==>
paulson@13508
   159
(Key (shrK A):analz (spies evs)) = (A:bad)"
paulson@13508
   160
by auto
paulson@13508
   161
paulson@13508
   162
lemma Guard_Nonce_analz: "[| Guard n Ks (spies evs); evs:p;
paulson@13508
   163
shrK_set Ks; good Ks; regular p |] ==> Nonce n ~:analz (spies evs)"
paulson@13508
   164
apply (clarify, simp only: knows_decomp)
paulson@13508
   165
apply (drule Guard_invKey_keyset, simp+, safe)
paulson@13508
   166
apply (drule in_good, simp)
paulson@13508
   167
apply (drule in_shrK_set, simp+, clarify)
paulson@13508
   168
apply (frule_tac A=A in shrK_analz_iff_bad)
paulson@13508
   169
by (simp add: knows_decomp)+
paulson@13508
   170
paulson@13508
   171
lemma GuardK_Key_analz: "[| GuardK n Ks (spies evs); evs:p;
paulson@13508
   172
shrK_set Ks; good Ks; regular p; n ~:range shrK |] ==> Key n ~:analz (spies evs)"
paulson@13508
   173
apply (clarify, simp only: knows_decomp)
berghofe@13601
   174
apply (drule GuardK_invKey_keyset, clarify, simp+, simp add: initState.simps)
paulson@13508
   175
apply clarify
paulson@13508
   176
apply (drule in_good, simp)
paulson@13508
   177
apply (drule in_shrK_set, simp+, clarify)
paulson@13508
   178
apply (frule_tac A=A in shrK_analz_iff_bad)
paulson@13508
   179
by (simp add: knows_decomp)+
paulson@13508
   180
paulson@13508
   181
end