src/HOL/Auth/Guard/Guard.thy
author blanchet
Wed, 12 Feb 2014 08:37:06 +0100
changeset 55417 01fbfb60c33e
parent 45600 1bbbac9a0cb0
child 56681 e8d5d60d655e
permissions -rw-r--r--
adapted to 'xxx_{case,rec}' renaming, to new theorem names, and to new variable names in theorems * * * more transition of 'xxx_rec' to 'rec_xxx' and same for case * * * compile * * * 'rename_tac's to avoid referring to generated names * * * more robust scripts with 'rename_tac' * * * 'where' -> 'of' * * * 'where' -> 'of' * * * renamed 'xxx_rec' to 'rec_xxx'
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41775
6214816d79d3 standardized headers;
wenzelm
parents: 37596
diff changeset
     1
(*  Title:      HOL/Auth/Guard/Guard.thy
6214816d79d3 standardized headers;
wenzelm
parents: 37596
diff changeset
     2
    Author:     Frederic Blanqui, University of Cambridge Computer Laboratory
6214816d79d3 standardized headers;
wenzelm
parents: 37596
diff changeset
     3
    Copyright   2002  University of Cambridge
6214816d79d3 standardized headers;
wenzelm
parents: 37596
diff changeset
     4
*)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
     5
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
     6
header{*Protocol-Independent Confidentiality Theorem on Nonces*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15236
diff changeset
     8
theory Guard imports Analz Extensions begin
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
     9
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    10
(******************************************************************************
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    11
messages where all the occurrences of Nonce n are
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    12
in a sub-message of the form Crypt (invKey K) X with K:Ks
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    13
******************************************************************************)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    14
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    15
inductive_set
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    16
  guard :: "nat => key set => msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    17
  for n :: nat and Ks :: "key set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    18
where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    19
  No_Nonce [intro]: "Nonce n ~:parts {X} ==> X:guard n Ks"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    20
| Guard_Nonce [intro]: "invKey K:Ks ==> Crypt K X:guard n Ks"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    21
| Crypt [intro]: "X:guard n Ks ==> Crypt K X:guard n Ks"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    22
| Pair [intro]: "[| X:guard n Ks; Y:guard n Ks |] ==> {|X,Y|}:guard n Ks"
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    23
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    24
subsection{*basic facts about @{term guard}*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    25
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    26
lemma Key_is_guard [iff]: "Key K:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    27
by auto
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    28
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    29
lemma Agent_is_guard [iff]: "Agent A:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    30
by auto
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    31
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    32
lemma Number_is_guard [iff]: "Number r:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    33
by auto
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    34
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    35
lemma Nonce_notin_guard: "X:guard n Ks ==> X ~= Nonce n"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    36
by (erule guard.induct, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    37
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    38
lemma Nonce_notin_guard_iff [iff]: "Nonce n ~:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    39
by (auto dest: Nonce_notin_guard)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    40
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    41
lemma guard_has_Crypt [rule_format]: "X:guard n Ks ==> Nonce n:parts {X}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    42
--> (EX K Y. Crypt K Y:kparts {X} & Nonce n:parts {Y})"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    43
by (erule guard.induct, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    44
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    45
lemma Nonce_notin_kparts_msg: "X:guard n Ks ==> Nonce n ~:kparts {X}"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    46
by (erule guard.induct, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    47
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    48
lemma Nonce_in_kparts_imp_no_guard: "Nonce n:kparts H
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    49
==> EX X. X:H & X ~:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    50
apply (drule in_kparts, clarify)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    51
apply (rule_tac x=X in exI, clarify)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    52
by (auto dest: Nonce_notin_kparts_msg)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    53
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    54
lemma guard_kparts [rule_format]: "X:guard n Ks ==>
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    55
Y:kparts {X} --> Y:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    56
by (erule guard.induct, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    57
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    58
lemma guard_Crypt: "[| Crypt K Y:guard n Ks; K ~:invKey`Ks |] ==> Y:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    59
by (ind_cases "Crypt K Y:guard n Ks", auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    60
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    61
lemma guard_MPair [iff]: "({|X,Y|}:guard n Ks) = (X:guard n Ks & Y:guard n Ks)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    62
by (auto, (ind_cases "{|X,Y|}:guard n Ks", auto)+)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    63
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    64
lemma guard_not_guard [rule_format]: "X:guard n Ks ==>
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    65
Crypt K Y:kparts {X} --> Nonce n:kparts {Y} --> Y ~:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    66
by (erule guard.induct, auto dest: guard_kparts)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    67
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    68
lemma guard_extand: "[| X:guard n Ks; Ks <= Ks' |] ==> X:guard n Ks'"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    69
by (erule guard.induct, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    70
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    71
subsection{*guarded sets*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    72
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 25134
diff changeset
    73
definition Guard :: "nat => key set => msg set => bool" where
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    74
"Guard n Ks H == ALL X. X:H --> X:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    75
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    76
subsection{*basic facts about @{term Guard}*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    77
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    78
lemma Guard_empty [iff]: "Guard n Ks {}"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    79
by (simp add: Guard_def)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    80
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    81
lemma notin_parts_Guard [intro]: "Nonce n ~:parts G ==> Guard n Ks G"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    82
apply (unfold Guard_def, clarify)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    83
apply (subgoal_tac "Nonce n ~:parts {X}")
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    84
by (auto dest: parts_sub)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    85
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    86
lemma Nonce_notin_kparts [simplified]: "Guard n Ks H ==> Nonce n ~:kparts H"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    87
by (auto simp: Guard_def dest: in_kparts Nonce_notin_kparts_msg)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    88
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    89
lemma Guard_must_decrypt: "[| Guard n Ks H; Nonce n:analz H |] ==>
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    90
EX K Y. Crypt K Y:kparts H & Key (invKey K):kparts H"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    91
apply (drule_tac P="%G. Nonce n:G" in analz_pparts_kparts_substD, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    92
by (drule must_decrypt, auto dest: Nonce_notin_kparts)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    93
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    94
lemma Guard_kparts [intro]: "Guard n Ks H ==> Guard n Ks (kparts H)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    95
by (auto simp: Guard_def dest: in_kparts guard_kparts)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    96
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    97
lemma Guard_mono: "[| Guard n Ks H; G <= H |] ==> Guard n Ks G"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    98
by (auto simp: Guard_def)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
    99
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   100
lemma Guard_insert [iff]: "Guard n Ks (insert X H)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   101
= (Guard n Ks H & X:guard n Ks)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   102
by (auto simp: Guard_def)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   103
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   104
lemma Guard_Un [iff]: "Guard n Ks (G Un H) = (Guard n Ks G & Guard n Ks H)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   105
by (auto simp: Guard_def)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   106
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   107
lemma Guard_synth [intro]: "Guard n Ks G ==> Guard n Ks (synth G)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   108
by (auto simp: Guard_def, erule synth.induct, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   109
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   110
lemma Guard_analz [intro]: "[| Guard n Ks G; ALL K. K:Ks --> Key K ~:analz G |]
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   111
==> Guard n Ks (analz G)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   112
apply (auto simp: Guard_def)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   113
apply (erule analz.induct, auto)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   114
by (ind_cases "Crypt K Xa:guard n Ks" for K Xa, auto)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   115
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   116
lemma in_Guard [dest]: "[| X:G; Guard n Ks G |] ==> X:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   117
by (auto simp: Guard_def)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   118
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   119
lemma in_synth_Guard: "[| X:synth G; Guard n Ks G |] ==> X:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   120
by (drule Guard_synth, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   121
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   122
lemma in_analz_Guard: "[| X:analz G; Guard n Ks G;
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   123
ALL K. K:Ks --> Key K ~:analz G |] ==> X:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   124
by (drule Guard_analz, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   125
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   126
lemma Guard_keyset [simp]: "keyset G ==> Guard n Ks G"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   127
by (auto simp: Guard_def)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   128
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   129
lemma Guard_Un_keyset: "[| Guard n Ks G; keyset H |] ==> Guard n Ks (G Un H)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   130
by auto
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   131
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   132
lemma in_Guard_kparts: "[| X:G; Guard n Ks G; Y:kparts {X} |] ==> Y:guard n Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   133
by blast
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   134
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   135
lemma in_Guard_kparts_neq: "[| X:G; Guard n Ks G; Nonce n':kparts {X} |]
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   136
==> n ~= n'"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   137
by (blast dest: in_Guard_kparts)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   138
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   139
lemma in_Guard_kparts_Crypt: "[| X:G; Guard n Ks G; is_MPair X;
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   140
Crypt K Y:kparts {X}; Nonce n:kparts {Y} |] ==> invKey K:Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   141
apply (drule in_Guard, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   142
apply (frule guard_not_guard, simp+)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   143
apply (drule guard_kparts, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   144
by (ind_cases "Crypt K Y:guard n Ks", auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   145
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   146
lemma Guard_extand: "[| Guard n Ks G; Ks <= Ks' |] ==> Guard n Ks' G"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   147
by (auto simp: Guard_def dest: guard_extand)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   148
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   149
lemma guard_invKey [rule_format]: "[| X:guard n Ks; Nonce n:kparts {Y} |] ==>
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   150
Crypt K Y:kparts {X} --> invKey K:Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   151
by (erule guard.induct, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   152
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   153
lemma Crypt_guard_invKey [rule_format]: "[| Crypt K Y:guard n Ks;
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   154
Nonce n:kparts {Y} |] ==> invKey K:Ks"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   155
by (auto dest: guard_invKey)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   156
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   157
subsection{*set obtained by decrypting a message*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   158
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 19233
diff changeset
   159
abbreviation (input)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   160
  decrypt :: "msg set => key => msg => msg set" where
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 19233
diff changeset
   161
  "decrypt H K Y == insert Y (H - {Crypt K Y})"
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   162
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   163
lemma analz_decrypt: "[| Crypt K Y:H; Key (invKey K):H; Nonce n:analz H |]
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   164
==> Nonce n:analz (decrypt H K Y)"
14307
1cbc24648cf7 tidying of HOL/Auth esp Guard lemmas
paulson
parents: 13508
diff changeset
   165
apply (drule_tac P="%H. Nonce n:analz H" in ssubst [OF insert_Diff])
1cbc24648cf7 tidying of HOL/Auth esp Guard lemmas
paulson
parents: 13508
diff changeset
   166
apply assumption
1cbc24648cf7 tidying of HOL/Auth esp Guard lemmas
paulson
parents: 13508
diff changeset
   167
apply (simp only: analz_Crypt_if, simp)
1cbc24648cf7 tidying of HOL/Auth esp Guard lemmas
paulson
parents: 13508
diff changeset
   168
done
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   169
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   170
lemma parts_decrypt: "[| Crypt K Y:H; X:parts (decrypt H K Y) |] ==> X:parts H"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   171
by (erule parts.induct, auto intro: parts.Fst parts.Snd parts.Body)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   172
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   173
subsection{*number of Crypt's in a message*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   174
35418
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   175
fun crypt_nb :: "msg => nat"
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   176
where
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   177
  "crypt_nb (Crypt K X) = Suc (crypt_nb X)"
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   178
| "crypt_nb {|X,Y|} = crypt_nb X + crypt_nb Y"
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   179
| "crypt_nb X = 0" (* otherwise *)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   180
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   181
subsection{*basic facts about @{term crypt_nb}*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   182
25134
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 23746
diff changeset
   183
lemma non_empty_crypt_msg: "Crypt K Y:parts {X} ==> crypt_nb X \<noteq> 0"
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   184
by (induct X, simp_all, safe, simp_all)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   185
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   186
subsection{*number of Crypt's in a message list*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   187
35418
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   188
primrec cnb :: "msg list => nat"
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   189
where
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   190
  "cnb [] = 0"
83b0f75810f0 killed recdefs in HOL-Auth
krauss
parents: 35416
diff changeset
   191
| "cnb (X#l) = crypt_nb X + cnb l"
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   192
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   193
subsection{*basic facts about @{term cnb}*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   194
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   195
lemma cnb_app [simp]: "cnb (l @ l') = cnb l + cnb l'"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   196
by (induct l, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   197
37596
248db70c9bcf dropped ancient infix mem
haftmann
parents: 35418
diff changeset
   198
lemma mem_cnb_minus: "x \<in> set l ==> cnb l = crypt_nb x + (cnb l - crypt_nb x)"
248db70c9bcf dropped ancient infix mem
haftmann
parents: 35418
diff changeset
   199
  by (induct l) auto
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   200
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   201
lemmas mem_cnb_minus_substI = mem_cnb_minus [THEN ssubst]
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   202
37596
248db70c9bcf dropped ancient infix mem
haftmann
parents: 35418
diff changeset
   203
lemma cnb_minus [simp]: "x \<in> set l ==> cnb (remove l x) = cnb l - crypt_nb x"
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   204
apply (induct l, auto)
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 41775
diff changeset
   205
apply (erule_tac l=l and x=x in mem_cnb_minus_substI)
37596
248db70c9bcf dropped ancient infix mem
haftmann
parents: 35418
diff changeset
   206
apply simp
248db70c9bcf dropped ancient infix mem
haftmann
parents: 35418
diff changeset
   207
done
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   208
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   209
lemma parts_cnb: "Z:parts (set l) ==>
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   210
cnb l = (cnb l - crypt_nb Z) + crypt_nb Z"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   211
by (erule parts.induct, auto simp: in_set_conv_decomp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   212
25134
3d4953e88449 Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents: 23746
diff changeset
   213
lemma non_empty_crypt: "Crypt K Y:parts (set l) ==> cnb l \<noteq> 0"
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   214
by (induct l, auto dest: non_empty_crypt_msg parts_insert_substD)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   215
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   216
subsection{*list of kparts*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   217
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   218
lemma kparts_msg_set: "EX l. kparts {X} = set l & cnb l = crypt_nb X"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   219
apply (induct X, simp_all)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   220
apply (rule_tac x="[Agent agent]" in exI, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   221
apply (rule_tac x="[Number nat]" in exI, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   222
apply (rule_tac x="[Nonce nat]" in exI, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   223
apply (rule_tac x="[Key nat]" in exI, simp)
15236
f289e8ba2bb3 Proofs needed to be updated because induction now preserves name of
nipkow
parents: 14307
diff changeset
   224
apply (rule_tac x="[Hash X]" in exI, simp)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   225
apply (clarify, rule_tac x="l@la" in exI, simp)
15236
f289e8ba2bb3 Proofs needed to be updated because induction now preserves name of
nipkow
parents: 14307
diff changeset
   226
by (clarify, rule_tac x="[Crypt nat X]" in exI, simp)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   227
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   228
lemma kparts_set: "EX l'. kparts (set l) = set l' & cnb l' = cnb l"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   229
apply (induct l)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   230
apply (rule_tac x="[]" in exI, simp, clarsimp)
55417
01fbfb60c33e adapted to 'xxx_{case,rec}' renaming, to new theorem names, and to new variable names in theorems
blanchet
parents: 45600
diff changeset
   231
apply (rename_tac a b l')
15236
f289e8ba2bb3 Proofs needed to be updated because induction now preserves name of
nipkow
parents: 14307
diff changeset
   232
apply (subgoal_tac "EX l''.  kparts {a} = set l'' & cnb l'' = crypt_nb a", clarify)
f289e8ba2bb3 Proofs needed to be updated because induction now preserves name of
nipkow
parents: 14307
diff changeset
   233
apply (rule_tac x="l''@l'" in exI, simp)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   234
apply (rule kparts_insert_substI, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   235
by (rule kparts_msg_set)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   236
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   237
subsection{*list corresponding to "decrypt"*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   238
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 25134
diff changeset
   239
definition decrypt' :: "msg list => key => msg => msg list" where
19233
77ca20b0ed77 renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents: 17087
diff changeset
   240
"decrypt' l K Y == Y # remove l (Crypt K Y)"
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   241
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   242
declare decrypt'_def [simp]
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   243
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   244
subsection{*basic facts about @{term decrypt'}*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   245
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   246
lemma decrypt_minus: "decrypt (set l) K Y <= set (decrypt' l K Y)"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   247
by (induct l, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   248
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   249
subsection{*if the analyse of a finite guarded set gives n then it must also gives
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   250
one of the keys of Ks*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   251
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   252
lemma Guard_invKey_by_list [rule_format]: "ALL l. cnb l = p
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   253
--> Guard n Ks (set l) --> Nonce n:analz (set l)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   254
--> (EX K. K:Ks & Key K:analz (set l))"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   255
apply (induct p)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   256
(* case p=0 *)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   257
apply (clarify, drule Guard_must_decrypt, simp, clarify)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   258
apply (drule kparts_parts, drule non_empty_crypt, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   259
(* case p>0 *)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   260
apply (clarify, frule Guard_must_decrypt, simp, clarify)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   261
apply (drule_tac P="%G. Nonce n:G" in analz_pparts_kparts_substD, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   262
apply (frule analz_decrypt, simp_all)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   263
apply (subgoal_tac "EX l'. kparts (set l) = set l' & cnb l' = cnb l", clarsimp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   264
apply (drule_tac G="insert Y (set l' - {Crypt K Y})"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   265
and H="set (decrypt' l' K Y)" in analz_sub, rule decrypt_minus)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   266
apply (rule_tac analz_pparts_kparts_substI, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   267
apply (case_tac "K:invKey`Ks")
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   268
(* K:invKey`Ks *)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   269
apply (clarsimp, blast)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   270
(* K ~:invKey`Ks *)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   271
apply (subgoal_tac "Guard n Ks (set (decrypt' l' K Y))")
37596
248db70c9bcf dropped ancient infix mem
haftmann
parents: 35418
diff changeset
   272
apply (drule_tac x="decrypt' l' K Y" in spec, simp)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   273
apply (subgoal_tac "Crypt K Y:parts (set l)")
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   274
apply (drule parts_cnb, rotate_tac -1, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   275
apply (clarify, drule_tac X="Key Ka" and H="insert Y (set l')" in analz_sub)
19233
77ca20b0ed77 renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents: 17087
diff changeset
   276
apply (rule insert_mono, rule set_remove)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   277
apply (simp add: analz_insertD, blast)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   278
(* Crypt K Y:parts (set l) *)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   279
apply (blast dest: kparts_parts)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   280
(* Guard n Ks (set (decrypt' l' K Y)) *)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   281
apply (rule_tac H="insert Y (set l')" in Guard_mono)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   282
apply (subgoal_tac "Guard n Ks (set l')", simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   283
apply (rule_tac K=K in guard_Crypt, simp add: Guard_def, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   284
apply (drule_tac t="set l'" in sym, simp)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   285
apply (rule Guard_kparts, simp, simp)
19233
77ca20b0ed77 renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents: 17087
diff changeset
   286
apply (rule_tac B="set l'" in subset_trans, rule set_remove, blast)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   287
by (rule kparts_set)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   288
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   289
lemma Guard_invKey_finite: "[| Nonce n:analz G; Guard n Ks G; finite G |]
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   290
==> EX K. K:Ks & Key K:analz G"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   291
apply (drule finite_list, clarify)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   292
by (rule Guard_invKey_by_list, auto)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   293
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   294
lemma Guard_invKey: "[| Nonce n:analz G; Guard n Ks G |]
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   295
==> EX K. K:Ks & Key K:analz G"
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   296
by (auto dest: analz_needs_only_finite Guard_invKey_finite)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   297
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   298
subsection{*if the analyse of a finite guarded set and a (possibly infinite) set of keys
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   299
gives n then it must also gives Ks*}
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   300
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   301
lemma Guard_invKey_keyset: "[| Nonce n:analz (G Un H); Guard n Ks G; finite G;
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   302
keyset H |] ==> EX K. K:Ks & Key K:analz (G Un H)"
45600
1bbbac9a0cb0 'lemmas' / 'theorems' commands allow 'for' fixes and standardize the result before storing;
wenzelm
parents: 41775
diff changeset
   303
apply (frule_tac P="%G. Nonce n:G" and G=G in analz_keyset_substD, simp_all)
13508
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   304
apply (drule_tac G="G Un (H Int keysfor G)" in Guard_invKey_finite)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   305
by (auto simp: Guard_def intro: analz_sub)
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   306
890d736b93a5 Frederic Blanqui's new "guard" examples
paulson
parents:
diff changeset
   307
end