src/HOL/Auth/Guard/Analz.thy
author wenzelm
Mon Aug 31 21:28:08 2015 +0200 (2015-08-31)
changeset 61070 b72a990adfe2
parent 58889 5b7a9633cfa8
child 61830 4f5ab843cf5b
permissions -rw-r--r--
prefer symbols;
wenzelm@41775
     1
(*  Title:      HOL/Auth/Guard/Analz.thy
wenzelm@41775
     2
    Author:     Frederic Blanqui, University of Cambridge Computer Laboratory
wenzelm@41775
     3
    Copyright   2001  University of Cambridge
wenzelm@41775
     4
*)
paulson@13508
     5
wenzelm@58889
     6
section{*Decomposition of Analz into two parts*}
paulson@13508
     7
haftmann@16417
     8
theory Analz imports Extensions begin
paulson@13508
     9
paulson@13508
    10
text{*decomposition of @{term analz} into two parts: 
paulson@13508
    11
      @{term pparts} (for pairs) and analz of @{term kparts}*}
paulson@13508
    12
paulson@13508
    13
subsection{*messages that do not contribute to analz*}
paulson@13508
    14
berghofe@23746
    15
inductive_set
berghofe@23746
    16
  pparts :: "msg set => msg set"
berghofe@23746
    17
  for H :: "msg set"
berghofe@23746
    18
where
berghofe@23746
    19
  Inj [intro]: "[| X:H; is_MPair X |] ==> X:pparts H"
berghofe@23746
    20
| Fst [dest]: "[| {|X,Y|}:pparts H; is_MPair X |] ==> X:pparts H"
berghofe@23746
    21
| Snd [dest]: "[| {|X,Y|}:pparts H; is_MPair Y |] ==> Y:pparts H"
paulson@13508
    22
paulson@13508
    23
subsection{*basic facts about @{term pparts}*}
paulson@13508
    24
paulson@13508
    25
lemma pparts_is_MPair [dest]: "X:pparts H ==> is_MPair X"
paulson@13508
    26
by (erule pparts.induct, auto)
paulson@13508
    27
paulson@13508
    28
lemma Crypt_notin_pparts [iff]: "Crypt K X ~:pparts H"
paulson@13508
    29
by auto
paulson@13508
    30
paulson@13508
    31
lemma Key_notin_pparts [iff]: "Key K ~:pparts H"
paulson@13508
    32
by auto
paulson@13508
    33
paulson@13508
    34
lemma Nonce_notin_pparts [iff]: "Nonce n ~:pparts H"
paulson@13508
    35
by auto
paulson@13508
    36
paulson@13508
    37
lemma Number_notin_pparts [iff]: "Number n ~:pparts H"
paulson@13508
    38
by auto
paulson@13508
    39
paulson@13508
    40
lemma Agent_notin_pparts [iff]: "Agent A ~:pparts H"
paulson@13508
    41
by auto
paulson@13508
    42
paulson@13508
    43
lemma pparts_empty [iff]: "pparts {} = {}"
paulson@13508
    44
by (auto, erule pparts.induct, auto)
paulson@13508
    45
paulson@13508
    46
lemma pparts_insertI [intro]: "X:pparts H ==> X:pparts (insert Y H)"
paulson@13508
    47
by (erule pparts.induct, auto)
paulson@13508
    48
paulson@13508
    49
lemma pparts_sub: "[| X:pparts G; G<=H |] ==> X:pparts H"
paulson@13508
    50
by (erule pparts.induct, auto)
paulson@13508
    51
paulson@13508
    52
lemma pparts_insert2 [iff]: "pparts (insert X (insert Y H))
paulson@13508
    53
= pparts {X} Un pparts {Y} Un pparts H"
paulson@13508
    54
by (rule eq, (erule pparts.induct, auto)+)
paulson@13508
    55
paulson@13508
    56
lemma pparts_insert_MPair [iff]: "pparts (insert {|X,Y|} H)
paulson@13508
    57
= insert {|X,Y|} (pparts ({X,Y} Un H))"
paulson@13508
    58
apply (rule eq, (erule pparts.induct, auto)+)
paulson@13508
    59
apply (rule_tac Y=Y in pparts.Fst, auto)
paulson@13508
    60
apply (erule pparts.induct, auto)
paulson@13508
    61
by (rule_tac X=X in pparts.Snd, auto)
paulson@13508
    62
paulson@13508
    63
lemma pparts_insert_Nonce [iff]: "pparts (insert (Nonce n) H) = pparts H"
paulson@13508
    64
by (rule eq, erule pparts.induct, auto)
paulson@13508
    65
paulson@13508
    66
lemma pparts_insert_Crypt [iff]: "pparts (insert (Crypt K X) H) = pparts H"
paulson@13508
    67
by (rule eq, erule pparts.induct, auto)
paulson@13508
    68
paulson@13508
    69
lemma pparts_insert_Key [iff]: "pparts (insert (Key K) H) = pparts H"
paulson@13508
    70
by (rule eq, erule pparts.induct, auto)
paulson@13508
    71
paulson@13508
    72
lemma pparts_insert_Agent [iff]: "pparts (insert (Agent A) H) = pparts H"
paulson@13508
    73
by (rule eq, erule pparts.induct, auto)
paulson@13508
    74
paulson@13508
    75
lemma pparts_insert_Number [iff]: "pparts (insert (Number n) H) = pparts H"
paulson@13508
    76
by (rule eq, erule pparts.induct, auto)
paulson@13508
    77
paulson@13508
    78
lemma pparts_insert_Hash [iff]: "pparts (insert (Hash X) H) = pparts H"
paulson@13508
    79
by (rule eq, erule pparts.induct, auto)
paulson@13508
    80
paulson@13508
    81
lemma pparts_insert: "X:pparts (insert Y H) ==> X:pparts {Y} Un pparts H"
paulson@13508
    82
by (erule pparts.induct, blast+)
paulson@13508
    83
paulson@13508
    84
lemma insert_pparts: "X:pparts {Y} Un pparts H ==> X:pparts (insert Y H)"
paulson@13508
    85
by (safe, erule pparts.induct, auto)
paulson@13508
    86
paulson@13508
    87
lemma pparts_Un [iff]: "pparts (G Un H) = pparts G Un pparts H"
paulson@13508
    88
by (rule eq, erule pparts.induct, auto dest: pparts_sub)
paulson@13508
    89
paulson@13508
    90
lemma pparts_pparts [iff]: "pparts (pparts H) = pparts H"
paulson@13508
    91
by (rule eq, erule pparts.induct, auto)
paulson@13508
    92
paulson@13508
    93
lemma pparts_insert_eq: "pparts (insert X H) = pparts {X} Un pparts H"
paulson@13508
    94
by (rule_tac A=H in insert_Un, rule pparts_Un)
paulson@13508
    95
paulson@13508
    96
lemmas pparts_insert_substI = pparts_insert_eq [THEN ssubst]
paulson@13508
    97
paulson@13508
    98
lemma in_pparts: "Y:pparts H ==> EX X. X:H & Y:pparts {X}"
paulson@13508
    99
by (erule pparts.induct, auto)
paulson@13508
   100
paulson@13508
   101
subsection{*facts about @{term pparts} and @{term parts}*}
paulson@13508
   102
paulson@13508
   103
lemma pparts_no_Nonce [dest]: "[| X:pparts {Y}; Nonce n ~:parts {Y} |]
paulson@13508
   104
==> Nonce n ~:parts {X}"
paulson@13508
   105
by (erule pparts.induct, simp_all)
paulson@13508
   106
paulson@13508
   107
subsection{*facts about @{term pparts} and @{term analz}*}
paulson@13508
   108
paulson@13508
   109
lemma pparts_analz: "X:pparts H ==> X:analz H"
paulson@13508
   110
by (erule pparts.induct, auto)
paulson@13508
   111
paulson@13508
   112
lemma pparts_analz_sub: "[| X:pparts G; G<=H |] ==> X:analz H"
paulson@13508
   113
by (auto dest: pparts_sub pparts_analz)
paulson@13508
   114
paulson@13508
   115
subsection{*messages that contribute to analz*}
paulson@13508
   116
berghofe@23746
   117
inductive_set
berghofe@23746
   118
  kparts :: "msg set => msg set"
berghofe@23746
   119
  for H :: "msg set"
berghofe@23746
   120
where
berghofe@23746
   121
  Inj [intro]: "[| X:H; not_MPair X |] ==> X:kparts H"
berghofe@23746
   122
| Fst [intro]: "[| {|X,Y|}:pparts H; not_MPair X |] ==> X:kparts H"
berghofe@23746
   123
| Snd [intro]: "[| {|X,Y|}:pparts H; not_MPair Y |] ==> Y:kparts H"
paulson@13508
   124
paulson@13508
   125
subsection{*basic facts about @{term kparts}*}
paulson@13508
   126
paulson@13508
   127
lemma kparts_not_MPair [dest]: "X:kparts H ==> not_MPair X"
paulson@13508
   128
by (erule kparts.induct, auto)
paulson@13508
   129
paulson@13508
   130
lemma kparts_empty [iff]: "kparts {} = {}"
paulson@13508
   131
by (rule eq, erule kparts.induct, auto)
paulson@13508
   132
paulson@13508
   133
lemma kparts_insertI [intro]: "X:kparts H ==> X:kparts (insert Y H)"
paulson@13508
   134
by (erule kparts.induct, auto dest: pparts_insertI)
paulson@13508
   135
paulson@13508
   136
lemma kparts_insert2 [iff]: "kparts (insert X (insert Y H))
paulson@13508
   137
= kparts {X} Un kparts {Y} Un kparts H"
paulson@13508
   138
by (rule eq, (erule kparts.induct, auto)+)
paulson@13508
   139
paulson@13508
   140
lemma kparts_insert_MPair [iff]: "kparts (insert {|X,Y|} H)
paulson@13508
   141
= kparts ({X,Y} Un H)"
paulson@13508
   142
by (rule eq, (erule kparts.induct, auto)+)
paulson@13508
   143
paulson@13508
   144
lemma kparts_insert_Nonce [iff]: "kparts (insert (Nonce n) H)
paulson@13508
   145
= insert (Nonce n) (kparts H)"
paulson@13508
   146
by (rule eq, erule kparts.induct, auto)
paulson@13508
   147
paulson@13508
   148
lemma kparts_insert_Crypt [iff]: "kparts (insert (Crypt K X) H)
paulson@13508
   149
= insert (Crypt K X) (kparts H)"
paulson@13508
   150
by (rule eq, erule kparts.induct, auto)
paulson@13508
   151
paulson@13508
   152
lemma kparts_insert_Key [iff]: "kparts (insert (Key K) H)
paulson@13508
   153
= insert (Key K) (kparts H)"
paulson@13508
   154
by (rule eq, erule kparts.induct, auto)
paulson@13508
   155
paulson@13508
   156
lemma kparts_insert_Agent [iff]: "kparts (insert (Agent A) H)
paulson@13508
   157
= insert (Agent A) (kparts H)"
paulson@13508
   158
by (rule eq, erule kparts.induct, auto)
paulson@13508
   159
paulson@13508
   160
lemma kparts_insert_Number [iff]: "kparts (insert (Number n) H)
paulson@13508
   161
= insert (Number n) (kparts H)"
paulson@13508
   162
by (rule eq, erule kparts.induct, auto)
paulson@13508
   163
paulson@13508
   164
lemma kparts_insert_Hash [iff]: "kparts (insert (Hash X) H)
paulson@13508
   165
= insert (Hash X) (kparts H)"
paulson@13508
   166
by (rule eq, erule kparts.induct, auto)
paulson@13508
   167
paulson@13508
   168
lemma kparts_insert: "X:kparts (insert X H) ==> X:kparts {X} Un kparts H"
paulson@13508
   169
by (erule kparts.induct, (blast dest: pparts_insert)+)
paulson@13508
   170
paulson@13508
   171
lemma kparts_insert_fst [rule_format,dest]: "X:kparts (insert Z H) ==>
paulson@13508
   172
X ~:kparts H --> X:kparts {Z}"
paulson@13508
   173
by (erule kparts.induct, (blast dest: pparts_insert)+)
paulson@13508
   174
paulson@13508
   175
lemma kparts_sub: "[| X:kparts G; G<=H |] ==> X:kparts H"
paulson@13508
   176
by (erule kparts.induct, auto dest: pparts_sub)
paulson@13508
   177
paulson@13508
   178
lemma kparts_Un [iff]: "kparts (G Un H) = kparts G Un kparts H"
paulson@13508
   179
by (rule eq, erule kparts.induct, auto dest: kparts_sub)
paulson@13508
   180
paulson@13508
   181
lemma pparts_kparts [iff]: "pparts (kparts H) = {}"
paulson@13508
   182
by (rule eq, erule pparts.induct, auto)
paulson@13508
   183
paulson@13508
   184
lemma kparts_kparts [iff]: "kparts (kparts H) = kparts H"
paulson@13508
   185
by (rule eq, erule kparts.induct, auto)
paulson@13508
   186
paulson@13508
   187
lemma kparts_insert_eq: "kparts (insert X H) = kparts {X} Un kparts H"
paulson@13508
   188
by (rule_tac A=H in insert_Un, rule kparts_Un)
paulson@13508
   189
paulson@13508
   190
lemmas kparts_insert_substI = kparts_insert_eq [THEN ssubst]
paulson@13508
   191
paulson@13508
   192
lemma in_kparts: "Y:kparts H ==> EX X. X:H & Y:kparts {X}"
paulson@13508
   193
by (erule kparts.induct, auto dest: in_pparts)
paulson@13508
   194
paulson@13508
   195
lemma kparts_has_no_pair [iff]: "has_no_pair (kparts H)"
paulson@13508
   196
by auto
paulson@13508
   197
paulson@13508
   198
subsection{*facts about @{term kparts} and @{term parts}*}
paulson@13508
   199
paulson@13508
   200
lemma kparts_no_Nonce [dest]: "[| X:kparts {Y}; Nonce n ~:parts {Y} |]
paulson@13508
   201
==> Nonce n ~:parts {X}"
paulson@13508
   202
by (erule kparts.induct, auto)
paulson@13508
   203
paulson@13508
   204
lemma kparts_parts: "X:kparts H ==> X:parts H"
paulson@13508
   205
by (erule kparts.induct, auto dest: pparts_analz)
paulson@13508
   206
paulson@13508
   207
lemma parts_kparts: "X:parts (kparts H) ==> X:parts H"
paulson@13508
   208
by (erule parts.induct, auto dest: kparts_parts
paulson@13508
   209
intro: parts.Fst parts.Snd parts.Body)
paulson@13508
   210
paulson@13508
   211
lemma Crypt_kparts_Nonce_parts [dest]: "[| Crypt K Y:kparts {Z};
paulson@13508
   212
Nonce n:parts {Y} |] ==> Nonce n:parts {Z}"
paulson@13508
   213
by auto
paulson@13508
   214
paulson@13508
   215
subsection{*facts about @{term kparts} and @{term analz}*}
paulson@13508
   216
paulson@13508
   217
lemma kparts_analz: "X:kparts H ==> X:analz H"
paulson@13508
   218
by (erule kparts.induct, auto dest: pparts_analz)
paulson@13508
   219
paulson@13508
   220
lemma kparts_analz_sub: "[| X:kparts G; G<=H |] ==> X:analz H"
paulson@13508
   221
by (erule kparts.induct, auto dest: pparts_analz_sub)
paulson@13508
   222
paulson@13508
   223
lemma analz_kparts [rule_format,dest]: "X:analz H ==>
paulson@13508
   224
Y:kparts {X} --> Y:analz H"
paulson@13508
   225
by (erule analz.induct, auto dest: kparts_analz_sub)
paulson@13508
   226
paulson@13508
   227
lemma analz_kparts_analz: "X:analz (kparts H) ==> X:analz H"
paulson@13508
   228
by (erule analz.induct, auto dest: kparts_analz)
paulson@13508
   229
paulson@39216
   230
lemma analz_kparts_insert: "X:analz (kparts (insert Z H)) ==> X:analz (kparts {Z} Un kparts H)"
paulson@13508
   231
by (rule analz_sub, auto)
paulson@13508
   232
paulson@13508
   233
lemma Nonce_kparts_synth [rule_format]: "Y:synth (analz G)
paulson@13508
   234
==> Nonce n:kparts {Y} --> Nonce n:analz G"
paulson@13508
   235
by (erule synth.induct, auto)
paulson@13508
   236
paulson@13508
   237
lemma kparts_insert_synth: "[| Y:parts (insert X G); X:synth (analz G);
paulson@13508
   238
Nonce n:kparts {Y}; Nonce n ~:analz G |] ==> Y:parts G"
wenzelm@46008
   239
apply (drule parts_insert_substD, clarify)
paulson@13508
   240
apply (drule in_sub, drule_tac X=Y in parts_sub, simp)
wenzelm@46008
   241
apply (auto dest: Nonce_kparts_synth)
wenzelm@46008
   242
done
paulson@13508
   243
paulson@39216
   244
lemma Crypt_insert_synth:
paulson@39216
   245
  "[| Crypt K Y:parts (insert X G); X:synth (analz G); Nonce n:kparts {Y}; Nonce n ~:analz G |] 
paulson@39216
   246
   ==> Crypt K Y:parts G"
paulson@39216
   247
by (metis Fake_parts_insert_in_Un Nonce_kparts_synth UnE analz_conj_parts synth_simps(5))
paulson@39216
   248
paulson@13508
   249
paulson@13508
   250
subsection{*analz is pparts + analz of kparts*}
paulson@13508
   251
paulson@13508
   252
lemma analz_pparts_kparts: "X:analz H ==> X:pparts H | X:analz (kparts H)"
paulson@39216
   253
by (erule analz.induct, auto) 
paulson@13508
   254
paulson@13508
   255
lemma analz_pparts_kparts_eq: "analz H = pparts H Un analz (kparts H)"
paulson@13508
   256
by (rule eq, auto dest: analz_pparts_kparts pparts_analz analz_kparts_analz)
paulson@13508
   257
paulson@13508
   258
lemmas analz_pparts_kparts_substI = analz_pparts_kparts_eq [THEN ssubst]
paulson@39216
   259
lemmas analz_pparts_kparts_substD = analz_pparts_kparts_eq [THEN sym, THEN ssubst]
paulson@13508
   260
paulson@13508
   261
end