src/HOL/Auth/Message.thy
author haftmann
Sun, 18 May 2025 14:33:01 +0000
changeset 82630 2bb4a8d0111d
parent 81182 fc5066122e68
permissions -rw-r--r--
dropped unused ML bindings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37936
1e4c5015a72e updated some headers;
wenzelm
parents: 35566
diff changeset
     1
(*  Title:      HOL/Auth/Message.thy
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     3
    Copyright   1996  University of Cambridge
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     4
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     5
Datatypes of agents and messages;
1913
2809adb15eb0 Renaming of functions, and tidying
paulson
parents: 1839
diff changeset
     6
Inductive relations "parts", "analz" and "synth"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     7
*)
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     8
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
     9
section\<open>Theory of Agents and Messages for Security Protocols\<close>
13956
8fe7e12290e1 improved presentation of HOL/Auth theories
paulson
parents: 13926
diff changeset
    10
27105
5f139027c365 slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
haftmann
parents: 26807
diff changeset
    11
theory Message
5f139027c365 slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
haftmann
parents: 26807
diff changeset
    12
imports Main
5f139027c365 slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
haftmann
parents: 26807
diff changeset
    13
begin
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    14
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    15
(*Needed occasionally with spy_analz_tac, e.g. in analz_insert_Key_newK*)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    16
lemma [simp] : "A \<union> (B \<union> A) = B \<union> A"
76288
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
    17
  by blast
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    18
41774
13b97824aec6 modernized specifications;
wenzelm
parents: 41693
diff changeset
    19
type_synonym
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    20
  key = nat
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    21
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    22
consts
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    23
  all_symmetric :: bool        \<comment> \<open>true if all keys are symmetric\<close>
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
    24
  invKey        :: "key\<Rightarrow>key"  \<comment> \<open>inverse of a symmetric key\<close>
14126
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    25
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    26
specification (invKey)
14181
942db403d4bb new, separate specifications
paulson
parents: 14145
diff changeset
    27
  invKey [simp]: "invKey (invKey K) = K"
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
    28
  invKey_symmetric: "all_symmetric \<longrightarrow> invKey = id"
14126
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    29
    by (rule exI [of _ id], auto)
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    30
14126
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    31
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
    32
text\<open>The inverse of a symmetric key is itself; that of a public key
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
    33
      is the private key and vice versa\<close>
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    34
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35109
diff changeset
    35
definition symKeys :: "key set" where
11230
756c5034f08b misc tidying; changing the predicate isSymKey to the set symKeys
paulson
parents: 11192
diff changeset
    36
  "symKeys == {K. invKey K = K}"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    37
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    38
datatype  \<comment> \<open>We allow any number of friendly agents\<close>
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2010
diff changeset
    39
  agent = Server | Friend nat | Spy
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    40
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
    41
datatype
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    42
     msg = Agent  agent     \<comment> \<open>Agent names\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    43
         | Number nat       \<comment> \<open>Ordinary integers, timestamps, ...\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    44
         | Nonce  nat       \<comment> \<open>Unguessable nonces\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    45
         | Key    key       \<comment> \<open>Crypto keys\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    46
         | Hash   msg       \<comment> \<open>Hashing\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    47
         | MPair  msg msg   \<comment> \<open>Compound messages\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    48
         | Crypt  key msg   \<comment> \<open>Encryption, public- or shared-key\<close>
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    49
5234
701fa0ed77b7 Better comments
paulson
parents: 5183
diff changeset
    50
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    51
text\<open>Concrete syntax: messages appear as \<open>\<lbrace>A,B,NA\<rbrace>\<close>, etc...\<close>
5234
701fa0ed77b7 Better comments
paulson
parents: 5183
diff changeset
    52
syntax
81019
dd59daa3c37a clarified inner-syntax markup, notably for enumerations: prefer "notation=mixfix" over "entity" via 'syntax_consts' (see also 70076ba563d2);
wenzelm
parents: 80914
diff changeset
    53
  "_MTuple" :: "['a, args] \<Rightarrow> 'a * 'b"  (\<open>(\<open>indent=2 notation=\<open>mixfix message tuple\<close>\<close>\<lbrace>_,/ _\<rbrace>)\<close>)
81182
fc5066122e68 more inner-syntax markup;
wenzelm
parents: 81091
diff changeset
    54
syntax_consts
fc5066122e68 more inner-syntax markup;
wenzelm
parents: 81091
diff changeset
    55
  "_MTuple" \<rightleftharpoons> MPair
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    56
translations
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    57
  "\<lbrace>x, y, z\<rbrace>" \<rightleftharpoons> "\<lbrace>x, \<lbrace>y, z\<rbrace>\<rbrace>"
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    58
  "\<lbrace>x, y\<rbrace>" \<rightleftharpoons> "CONST MPair x y"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    59
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    60
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 80786
diff changeset
    61
definition HPair :: "[msg,msg] \<Rightarrow> msg" (\<open>(4Hash[_] /_)\<close> [0, 1000]) where
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    62
    \<comment> \<open>Message Y paired with a MAC computed with the help of X\<close>
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    63
    "Hash[X] Y == \<lbrace>Hash\<lbrace>X,Y\<rbrace>, Y\<rbrace>"
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2373
diff changeset
    64
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
    65
definition keysFor :: "msg set \<Rightarrow> key set" where
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62390
diff changeset
    66
    \<comment> \<open>Keys useful to decrypt elements of a message set\<close>
11192
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
    67
  "keysFor H == invKey ` {K. \<exists>X. Crypt K X \<in> H}"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    68
16818
paulson
parents: 16796
diff changeset
    69
76299
0ad6f6508274 Tidying of some very old proofs
paulson <lp15@cam.ac.uk>
parents: 76291
diff changeset
    70
subsection\<open>Inductive Definition of All Parts of a Message\<close>
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    71
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    72
inductive_set
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
    73
  parts :: "msg set \<Rightarrow> msg set"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    74
  for H :: "msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    75
  where
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
    76
    Inj [intro]: "X \<in> H \<Longrightarrow> X \<in> parts H"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
    77
  | Fst:         "\<lbrace>X,Y\<rbrace> \<in> parts H \<Longrightarrow> X \<in> parts H"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
    78
  | Snd:         "\<lbrace>X,Y\<rbrace> \<in> parts H \<Longrightarrow> Y \<in> parts H"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
    79
  | Body:        "Crypt K X \<in> parts H \<Longrightarrow> X \<in> parts H"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    80
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    81
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
    82
text\<open>Monotonicity\<close>
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
    83
lemma parts_mono_aux: "\<lbrakk>G \<subseteq> H; X \<in> parts G\<rbrakk> \<Longrightarrow> X \<in> parts H"
76288
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
    84
  by (erule parts.induct) (auto dest: parts.Fst parts.Snd parts.Body)
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
    85
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
    86
lemma parts_mono: "G \<subseteq> H \<Longrightarrow> parts(G) \<subseteq> parts(H)"
76288
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
    87
  using parts_mono_aux by blast
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    88
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    89
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
    90
text\<open>Equations hold because constructors are injective.\<close>
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
    91
lemma Friend_image_eq [simp]: "(Friend x \<in> Friend`A) = (x \<in>A)"
76288
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
    92
  by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    93
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
    94
lemma Key_image_eq [simp]: "(Key x \<in> Key`A) = (x \<in>A)"
76288
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
    95
  by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    96
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    97
lemma Nonce_Key_image_eq [simp]: "(Nonce x \<notin> Key`A)"
76288
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
    98
  by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    99
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   100
76299
0ad6f6508274 Tidying of some very old proofs
paulson <lp15@cam.ac.uk>
parents: 76291
diff changeset
   101
subsection\<open>Inverse of keys\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   102
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   103
lemma invKey_eq [simp]: "(invKey K = invKey K') = (K=K')"
76288
b82ac7ef65ec Removal of the "unfold" method in favour of "unfolding"
paulson <lp15@cam.ac.uk>
parents: 76287
diff changeset
   104
  by (metis invKey)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   105
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   106
76299
0ad6f6508274 Tidying of some very old proofs
paulson <lp15@cam.ac.uk>
parents: 76291
diff changeset
   107
subsection\<open>The @{term keysFor} operator\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   108
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   109
lemma keysFor_empty [simp]: "keysFor {} = {}"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   110
    unfolding keysFor_def by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   111
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   112
lemma keysFor_Un [simp]: "keysFor (H \<union> H') = keysFor H \<union> keysFor H'"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   113
    unfolding keysFor_def by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   114
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   115
lemma keysFor_UN [simp]: "keysFor (\<Union>i \<in>A. H i) = (\<Union>i \<in>A. keysFor (H i))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   116
    unfolding keysFor_def by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   117
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   118
text\<open>Monotonicity\<close>
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   119
lemma keysFor_mono: "G \<subseteq> H \<Longrightarrow> keysFor(G) \<subseteq> keysFor(H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   120
  unfolding keysFor_def by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   121
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   122
lemma keysFor_insert_Agent [simp]: "keysFor (insert (Agent A) H) = keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   123
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   124
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   125
lemma keysFor_insert_Nonce [simp]: "keysFor (insert (Nonce N) H) = keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   126
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   127
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   128
lemma keysFor_insert_Number [simp]: "keysFor (insert (Number N) H) = keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   129
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   130
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   131
lemma keysFor_insert_Key [simp]: "keysFor (insert (Key K) H) = keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   132
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   133
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   134
lemma keysFor_insert_Hash [simp]: "keysFor (insert (Hash X) H) = keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   135
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   136
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   137
lemma keysFor_insert_MPair [simp]: "keysFor (insert \<lbrace>X,Y\<rbrace> H) = keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   138
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   139
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   140
lemma keysFor_insert_Crypt [simp]: 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   141
    "keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   142
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   143
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   144
lemma keysFor_image_Key [simp]: "keysFor (Key`E) = {}"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   145
  unfolding keysFor_def by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   146
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   147
lemma Crypt_imp_invKey_keysFor: "Crypt K X \<in> H \<Longrightarrow> invKey K \<in> keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   148
  unfolding keysFor_def by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   149
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   150
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   151
subsection\<open>Inductive relation "parts"\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   152
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   153
lemma MPair_parts:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   154
  "\<lbrakk>\<lbrace>X,Y\<rbrace> \<in> parts H;        
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   155
         \<lbrakk>X \<in> parts H; Y \<in> parts H\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   156
  by (blast dest: parts.Fst parts.Snd) 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   157
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   158
declare MPair_parts [elim!]  parts.Body [dest!]
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   159
text\<open>NB These two rules are UNSAFE in the formal sense, as they discard the
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   160
     compound message.  They work well on THIS FILE.  
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   161
  \<open>MPair_parts\<close> is left as SAFE because it speeds up proofs.
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   162
  The Crypt rule is normally kept UNSAFE to avoid breaking up certificates.\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   163
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   164
lemma parts_increasing: "H \<subseteq> parts(H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   165
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   166
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 44174
diff changeset
   167
lemmas parts_insertI = subset_insertI [THEN parts_mono, THEN subsetD]
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   168
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   169
lemma parts_empty_aux: "X \<in> parts{} \<Longrightarrow> False"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   170
  by (induction rule: parts.induct) (blast+)
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   171
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   172
lemma parts_empty [simp]: "parts{} = {}"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   173
  using parts_empty_aux by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   174
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   175
lemma parts_emptyE [elim!]: "X \<in> parts{} \<Longrightarrow> P"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   176
  by simp
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   177
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   178
text\<open>WARNING: loops if H = {Y}, therefore must not be repeated!\<close>
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   179
lemma parts_singleton: "X \<in> parts H \<Longrightarrow> \<exists>Y \<in>H. X \<in> parts {Y}"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   180
  by (erule parts.induct, fast+)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   181
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   182
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   183
subsubsection\<open>Unions\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   184
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   185
lemma parts_Un [simp]: "parts(G \<union> H) = parts(G) \<union> parts(H)"
76340
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   186
proof -
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   187
  have "X \<in> parts (G \<union> H) \<Longrightarrow> X \<in> parts G \<union> parts H" for X
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   188
    by (induction rule: parts.induct) auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   189
  then show ?thesis
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   190
    by (simp add: order_antisym parts_mono subsetI)
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   191
qed
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   192
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   193
lemma parts_insert: "parts (insert X H) = parts {X} \<union> parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   194
  by (metis insert_is_Un parts_Un)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   195
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   196
text\<open>TWO inserts to avoid looping.  This rewrite is better than nothing.
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   197
  But its behaviour can be strange.\<close>
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   198
lemma parts_insert2:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   199
  "parts (insert X (insert Y H)) = parts {X} \<union> parts {Y} \<union> parts H"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   200
  by (metis Un_commute Un_empty_right Un_insert_right insert_is_Un parts_Un)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   201
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 61956
diff changeset
   202
lemma parts_image [simp]:
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   203
  "parts (f ` A) = (\<Union>x \<in>A. parts {f x})"
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 61956
diff changeset
   204
  apply auto
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   205
   apply (metis (mono_tags, opaque_lifting) image_iff parts_singleton)
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 61956
diff changeset
   206
  apply (metis empty_subsetI image_eqI insert_absorb insert_subset parts_mono)
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 61956
diff changeset
   207
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   208
76340
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   209
text\<open>Added to simplify arguments to parts, analz and synth.\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   210
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   211
text\<open>This allows \<open>blast\<close> to simplify occurrences of 
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67613
diff changeset
   212
  \<^term>\<open>parts(G\<union>H)\<close> in the assumption.\<close>
17729
d74d0b5052a0 theorems need names
paulson
parents: 17689
diff changeset
   213
lemmas in_parts_UnE = parts_Un [THEN equalityD1, THEN subsetD, THEN UnE] 
d74d0b5052a0 theorems need names
paulson
parents: 17689
diff changeset
   214
declare in_parts_UnE [elim!]
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   215
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   216
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   217
lemma parts_insert_subset: "insert X (parts H) \<subseteq> parts(insert X H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   218
  by (blast intro: parts_mono [THEN [2] rev_subsetD])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   219
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   220
subsubsection\<open>Idempotence and transitivity\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   221
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   222
lemma parts_partsD [dest!]: "X \<in> parts (parts H) \<Longrightarrow> X \<in> parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   223
  by (erule parts.induct, blast+)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   224
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   225
lemma parts_idem [simp]: "parts (parts H) = parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   226
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   227
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   228
lemma parts_subset_iff [simp]: "(parts G \<subseteq> parts H) = (G \<subseteq> parts H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   229
  by (metis parts_idem parts_increasing parts_mono subset_trans)
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   230
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   231
lemma parts_trans: "\<lbrakk>X \<in> parts G;  G \<subseteq> parts H\<rbrakk> \<Longrightarrow> X \<in> parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   232
  by (metis parts_subset_iff subsetD)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   233
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   234
text\<open>Cut\<close>
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   235
lemma parts_cut:
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   236
  "\<lbrakk>Y \<in> parts (insert X G);  X \<in> parts H\<rbrakk> \<Longrightarrow> Y \<in> parts (G \<union> H)" 
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   237
  by (blast intro: parts_trans) 
18492
b0fe60800623 shorter proof
paulson
parents: 17729
diff changeset
   238
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   239
lemma parts_cut_eq [simp]: "X \<in> parts H \<Longrightarrow> parts (insert X H) = parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   240
  by (metis insert_absorb parts_idem parts_insert)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   241
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   242
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   243
subsubsection\<open>Rewrite rules for pulling out atomic messages\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   244
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   245
lemmas parts_insert_eq_I = equalityI [OF subsetI parts_insert_subset]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   246
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   247
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   248
lemma parts_insert_Agent [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   249
  "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   250
  apply (rule parts_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   251
  apply (erule parts.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   252
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   253
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   254
lemma parts_insert_Nonce [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   255
  "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   256
  apply (rule parts_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   257
  apply (erule parts.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   258
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   259
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   260
lemma parts_insert_Number [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   261
  "parts (insert (Number N) H) = insert (Number N) (parts H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   262
  apply (rule parts_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   263
  apply (erule parts.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   264
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   265
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   266
lemma parts_insert_Key [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   267
  "parts (insert (Key K) H) = insert (Key K) (parts H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   268
  apply (rule parts_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   269
  apply (erule parts.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   270
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   271
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   272
lemma parts_insert_Hash [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   273
  "parts (insert (Hash X) H) = insert (Hash X) (parts H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   274
  apply (rule parts_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   275
  apply (erule parts.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   276
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   277
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   278
lemma parts_insert_Crypt [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   279
  "parts (insert (Crypt K X) H) = insert (Crypt K X) (parts (insert X H))"
76340
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   280
proof -
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   281
  have "Y \<in> parts (insert (Crypt K X) H) \<Longrightarrow> Y \<in> insert (Crypt K X) (parts (insert X H))" for Y
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   282
    by (induction rule: parts.induct) auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   283
  then show ?thesis
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   284
    by (smt (verit) insertI1 insert_commute parts.simps parts_cut_eq parts_insert_eq_I)
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   285
qed
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   286
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   287
lemma parts_insert_MPair [simp]:
76340
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   288
  "parts (insert \<lbrace>X,Y\<rbrace> H) = insert \<lbrace>X,Y\<rbrace> (parts (insert X (insert Y H)))"
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   289
proof -
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   290
  have "Z \<in> parts (insert \<lbrace>X, Y\<rbrace> H) \<Longrightarrow> Z \<in> insert \<lbrace>X, Y\<rbrace> (parts (insert X (insert Y H)))" for Z
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   291
    by (induction rule: parts.induct) auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   292
  then show ?thesis
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   293
    by (smt (verit) insertI1 insert_commute parts.simps parts_cut_eq parts_insert_eq_I)
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   294
qed
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   295
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   296
lemma parts_image_Key [simp]: "parts (Key`N) = Key`N"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   297
  by auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   298
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   299
text\<open>In any message, there is an upper bound N on its greatest nonce.\<close>
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   300
lemma msg_Nonce_supply: "\<exists>N. \<forall>n. N\<le>n \<longrightarrow> Nonce n \<notin> parts {msg}"
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   301
proof (induct msg)
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   302
  case (Nonce n)
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   303
  show ?case
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   304
    by simp (metis Suc_n_not_le_n)
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   305
next
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   306
  case (MPair X Y)
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   307
  then show ?case \<comment> \<open>metis works out the necessary sum itself!\<close>
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   308
    by (simp add: parts_insert2) (metis le_trans nat_le_linear)
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   309
qed auto
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   310
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   311
subsection\<open>Inductive relation "analz"\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   312
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   313
text\<open>Inductive definition of "analz" -- what can be broken down from a set of
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   314
    messages, including keys.  A form of downward closure.  Pairs can
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   315
    be taken apart; messages decrypted with known keys.\<close>
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   316
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   317
inductive_set
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   318
  analz :: "msg set \<Rightarrow> msg set"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   319
  for H :: "msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   320
  where
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   321
    Inj [intro,simp]: "X \<in> H \<Longrightarrow> X \<in> analz H"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   322
  | Fst:     "\<lbrace>X,Y\<rbrace> \<in> analz H \<Longrightarrow> X \<in> analz H"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   323
  | Snd:     "\<lbrace>X,Y\<rbrace> \<in> analz H \<Longrightarrow> Y \<in> analz H"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   324
  | Decrypt [dest]: 
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   325
    "\<lbrakk>Crypt K X \<in> analz H; Key(invKey K) \<in> analz H\<rbrakk> \<Longrightarrow> X \<in> analz H"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   326
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   327
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   328
text\<open>Monotonicity; Lemma 1 of Lowe's paper\<close>
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   329
lemma analz_mono_aux: "\<lbrakk>G \<subseteq> H; X \<in> analz G\<rbrakk> \<Longrightarrow> X \<in> analz H"
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   330
  by (erule analz.induct) (auto dest: analz.Fst analz.Snd) 
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   331
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   332
lemma analz_mono: "G\<subseteq>H \<Longrightarrow> analz(G) \<subseteq> analz(H)"
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   333
  using analz_mono_aux by blast
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   334
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   335
text\<open>Making it safe speeds up proofs\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   336
lemma MPair_analz [elim!]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   337
  "\<lbrakk>\<lbrace>X,Y\<rbrace> \<in> analz H;        
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   338
    \<lbrakk>X \<in> analz H; Y \<in> analz H\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   339
  by (blast dest: analz.Fst analz.Snd)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   340
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   341
lemma analz_increasing: "H \<subseteq> analz(H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   342
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   343
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   344
lemma analz_into_parts: "X \<in> analz H \<Longrightarrow> X \<in> parts H"
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   345
  by (erule analz.induct) auto
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   346
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   347
lemma analz_subset_parts: "analz H \<subseteq> parts H"
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   348
  using analz_into_parts by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   349
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   350
lemma analz_parts [simp]: "analz (parts H) = parts H"
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   351
  using analz_subset_parts by blast
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   352
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 44174
diff changeset
   353
lemmas not_parts_not_analz = analz_subset_parts [THEN contra_subsetD]
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   354
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   355
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   356
lemma parts_analz [simp]: "parts (analz H) = parts H"
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   357
  by (metis analz_increasing analz_subset_parts parts_idem parts_mono subset_antisym)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   358
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 44174
diff changeset
   359
lemmas analz_insertI = subset_insertI [THEN analz_mono, THEN [2] rev_subsetD]
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   360
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   361
subsubsection\<open>General equational properties\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   362
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   363
lemma analz_empty [simp]: "analz{} = {}"
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   364
  using analz_parts by fastforce
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   365
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   366
text\<open>Converse fails: we can analz more from the union than from the 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   367
  separate parts, as a key in one might decrypt a message in the other\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   368
lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   369
  by (intro Un_least analz_mono Un_upper1 Un_upper2)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   370
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   371
lemma analz_insert: "insert X (analz H) \<subseteq> analz(insert X H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   372
  by (blast intro: analz_mono [THEN [2] rev_subsetD])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   373
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   374
subsubsection\<open>Rewrite rules for pulling out atomic messages\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   375
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   376
lemmas analz_insert_eq_I = equalityI [OF subsetI analz_insert]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   377
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   378
lemma analz_insert_Agent [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   379
  "analz (insert (Agent agt) H) = insert (Agent agt) (analz H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   380
  apply (rule analz_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   381
  apply (erule analz.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   382
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   383
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   384
lemma analz_insert_Nonce [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   385
  "analz (insert (Nonce N) H) = insert (Nonce N) (analz H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   386
  apply (rule analz_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   387
  apply (erule analz.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   388
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   389
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   390
lemma analz_insert_Number [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   391
  "analz (insert (Number N) H) = insert (Number N) (analz H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   392
  apply (rule analz_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   393
  apply (erule analz.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   394
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   395
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   396
lemma analz_insert_Hash [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   397
  "analz (insert (Hash X) H) = insert (Hash X) (analz H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   398
  apply (rule analz_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   399
  apply (erule analz.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   400
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   401
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   402
text\<open>Can only pull out Keys if they are not needed to decrypt the rest\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   403
lemma analz_insert_Key [simp]: 
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   404
  "K \<notin> keysFor (analz H) \<Longrightarrow>   
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   405
          analz (insert (Key K) H) = insert (Key K) (analz H)"
76290
64d29ebb7d3d Mostly, removing the unfold method
paulson <lp15@cam.ac.uk>
parents: 76289
diff changeset
   406
  unfolding keysFor_def
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   407
  apply (rule analz_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   408
  apply (erule analz.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   409
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   410
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   411
lemma analz_insert_MPair [simp]:
76340
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   412
  "analz (insert \<lbrace>X,Y\<rbrace> H) = insert \<lbrace>X,Y\<rbrace> (analz (insert X (insert Y H)))"
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   413
proof -
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   414
  have "Z \<in> analz (insert \<lbrace>X, Y\<rbrace> H) \<Longrightarrow> Z \<in> insert \<lbrace>X, Y\<rbrace> (analz (insert X (insert Y H)))" for Z
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   415
    by (induction rule: analz.induct) auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   416
  moreover have "Z \<in> analz (insert X (insert Y H)) \<Longrightarrow> Z \<in> analz (insert \<lbrace>X, Y\<rbrace> H)" for Z
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   417
    by (induction rule: analz.induct) (use analz.Inj in blast)+
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   418
  ultimately show ?thesis
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   419
    by auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   420
qed
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   421
76340
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   422
text\<open>Can pull out encrypted message if the Key is not known\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   423
lemma analz_insert_Crypt:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   424
  "Key (invKey K) \<notin> analz H 
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   425
      \<Longrightarrow> analz (insert (Crypt K X) H) = insert (Crypt K X) (analz H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   426
  apply (rule analz_insert_eq_I) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   427
  apply (erule analz.induct, auto) 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   428
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   429
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   430
lemma analz_insert_Decrypt:
76340
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   431
  assumes "Key (invKey K) \<in> analz H"
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   432
  shows "analz (insert (Crypt K X) H) = insert (Crypt K X) (analz (insert X H))"
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   433
proof -
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   434
  have "Y \<in> analz (insert (Crypt K X) H) \<Longrightarrow> Y \<in> insert (Crypt K X) (analz (insert X H))" for Y
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   435
    by (induction rule: analz.induct) auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   436
  moreover
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   437
  have "Y \<in> analz (insert X H) \<Longrightarrow> Y \<in> analz (insert (Crypt K X) H)" for Y
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   438
  proof (induction rule: analz.induct)
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   439
    case (Inj X)
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   440
    then show ?case
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   441
      by (metis analz.Decrypt analz.Inj analz_insertI assms insert_iff)
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   442
  qed auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   443
  ultimately show ?thesis
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   444
    by auto
fdb91b733b65 Tidying of old and ugly proofs
paulson <lp15@cam.ac.uk>
parents: 76338
diff changeset
   445
qed
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   446
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   447
text\<open>Case analysis: either the message is secure, or it is not! Effective,
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   448
but can cause subgoals to blow up! Use with \<open>if_split\<close>; apparently
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67613
diff changeset
   449
\<open>split_tac\<close> does not cope with patterns such as \<^term>\<open>analz (insert
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67613
diff changeset
   450
(Crypt K X) H)\<close>\<close> 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   451
lemma analz_Crypt_if [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   452
  "analz (insert (Crypt K X) H) =                 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   453
          (if (Key (invKey K) \<in> analz H)                 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   454
           then insert (Crypt K X) (analz (insert X H))  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   455
           else insert (Crypt K X) (analz H))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   456
  by (simp add: analz_insert_Crypt analz_insert_Decrypt)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   457
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   458
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   459
text\<open>This rule supposes "for the sake of argument" that we have the key.\<close>
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   460
lemma analz_insert_Crypt_subset:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   461
  "analz (insert (Crypt K X) H) \<subseteq>   
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   462
           insert (Crypt K X) (analz (insert X H))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   463
  apply (rule subsetI)
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   464
  apply (erule analz.induct, auto)
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   465
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   466
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   467
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   468
lemma analz_image_Key [simp]: "analz (Key`N) = Key`N"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   469
  apply auto
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   470
  apply (erule analz.induct, auto)
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   471
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   472
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   473
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   474
subsubsection\<open>Idempotence and transitivity\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   475
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   476
lemma analz_analzD [dest!]: "X \<in> analz (analz H) \<Longrightarrow> X \<in> analz H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   477
  by (erule analz.induct, blast+)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   478
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   479
lemma analz_idem [simp]: "analz (analz H) = analz H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   480
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   481
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   482
lemma analz_subset_iff [simp]: "(analz G \<subseteq> analz H) = (G \<subseteq> analz H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   483
  by (metis analz_idem analz_increasing analz_mono subset_trans)
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   484
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   485
lemma analz_trans: "\<lbrakk>X \<in> analz G;  G \<subseteq> analz H\<rbrakk> \<Longrightarrow> X \<in> analz H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   486
  by (drule analz_mono, blast)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   487
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   488
text\<open>Cut; Lemma 2 of Lowe\<close>
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   489
lemma analz_cut: "\<lbrakk>Y \<in> analz (insert X H);  X \<in> analz H\<rbrakk> \<Longrightarrow> Y \<in> analz H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   490
  by (erule analz_trans, blast)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   491
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   492
(*Cut can be proved easily by induction on
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   493
   "Y: analz (insert X H) \<Longrightarrow> X: analz H \<longrightarrow> Y: analz H"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   494
*)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   495
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   496
text\<open>This rewrite rule helps in the simplification of messages that involve
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   497
  the forwarding of unknown components (X).  Without it, removing occurrences
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   498
  of X can be very complicated.\<close>
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   499
lemma analz_insert_eq: "X \<in> analz H \<Longrightarrow> analz (insert X H) = analz H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   500
  by (metis analz_cut analz_insert_eq_I insert_absorb)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   501
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   502
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   503
text\<open>A congruence rule for "analz"\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   504
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   505
lemma analz_subset_cong:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   506
  "\<lbrakk>analz G \<subseteq> analz G'; analz H \<subseteq> analz H'\<rbrakk> 
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   507
      \<Longrightarrow> analz (G \<union> H) \<subseteq> analz (G' \<union> H')"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   508
  by (metis Un_mono analz_Un analz_subset_iff subset_trans)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   509
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   510
lemma analz_cong:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   511
  "\<lbrakk>analz G = analz G'; analz H = analz H'\<rbrakk> 
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   512
      \<Longrightarrow> analz (G \<union> H) = analz (G' \<union> H')"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   513
  by (intro equalityI analz_subset_cong, simp_all) 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   514
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   515
lemma analz_insert_cong:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   516
  "analz H = analz H' \<Longrightarrow> analz(insert X H) = analz(insert X H')"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   517
  by (force simp only: insert_def intro!: analz_cong)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   518
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   519
text\<open>If there are no pairs or encryptions then analz does nothing\<close>
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   520
lemma analz_trivial:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   521
  "\<lbrakk>\<forall>X Y. \<lbrace>X,Y\<rbrace> \<notin> H;  \<forall>X K. Crypt K X \<notin> H\<rbrakk> \<Longrightarrow> analz H = H"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   522
  apply safe
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   523
   apply (erule analz.induct, blast+)
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   524
  done
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   525
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   526
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   527
subsection\<open>Inductive relation "synth"\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   528
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   529
text\<open>Inductive definition of "synth" -- what can be built up from a set of
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   530
    messages.  A form of upward closure.  Pairs can be built, messages
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 2516
diff changeset
   531
    encrypted with known keys.  Agent names are public domain.
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   532
    Numbers can be guessed, but Nonces cannot be.\<close>
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   533
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   534
inductive_set
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   535
  synth :: "msg set => msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   536
  for H :: "msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   537
  where
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   538
    Inj    [intro]:   "X \<in> H \<Longrightarrow> X \<in> synth H"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   539
  | Agent  [intro]:   "Agent agt \<in> synth H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   540
  | Number [intro]:   "Number n  \<in> synth H"
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   541
  | Hash   [intro]:   "X \<in> synth H \<Longrightarrow> Hash X \<in> synth H"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   542
  | MPair  [intro]:   "\<lbrakk>X \<in> synth H;  Y \<in> synth H\<rbrakk> \<Longrightarrow> \<lbrace>X,Y\<rbrace> \<in> synth H"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   543
  | Crypt  [intro]:   "\<lbrakk>X \<in> synth H;  Key(K) \<in> H\<rbrakk> \<Longrightarrow> Crypt K X \<in> synth H"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   544
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   545
text\<open>Monotonicity\<close>
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   546
lemma synth_mono: "G\<subseteq>H \<Longrightarrow> synth(G) \<subseteq> synth(H)"
16818
paulson
parents: 16796
diff changeset
   547
  by (auto, erule synth.induct, auto)  
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   548
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   549
text\<open>NO \<open>Agent_synth\<close>, as any Agent name can be synthesized.  
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67613
diff changeset
   550
  The same holds for \<^term>\<open>Number\<close>\<close>
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   551
39216
62332b382dba tidied using inductive_simps
paulson
parents: 37936
diff changeset
   552
inductive_simps synth_simps [iff]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   553
  "Nonce n \<in> synth H"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   554
  "Key K \<in> synth H"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   555
  "Hash X \<in> synth H"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   556
  "\<lbrace>X,Y\<rbrace> \<in> synth H"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   557
  "Crypt K X \<in> synth H"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   558
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   559
lemma synth_increasing: "H \<subseteq> synth(H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   560
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   561
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   562
subsubsection\<open>Unions\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   563
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   564
text\<open>Converse fails: we can synth more from the union than from the 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   565
  separate parts, building a compound message using elements of each.\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   566
lemma synth_Un: "synth(G) \<union> synth(H) \<subseteq> synth(G \<union> H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   567
  by (intro Un_least synth_mono Un_upper1 Un_upper2)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   568
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   569
lemma synth_insert: "insert X (synth H) \<subseteq> synth(insert X H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   570
  by (blast intro: synth_mono [THEN [2] rev_subsetD])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   571
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   572
subsubsection\<open>Idempotence and transitivity\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   573
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   574
lemma synth_synthD [dest!]: "X \<in> synth (synth H) \<Longrightarrow> X \<in> synth H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   575
  by (erule synth.induct, auto)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   576
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   577
lemma synth_idem: "synth (synth H) = synth H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   578
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   579
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   580
lemma synth_subset_iff [simp]: "(synth G \<subseteq> synth H) = (G \<subseteq> synth H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   581
  by (metis subset_trans synth_idem synth_increasing synth_mono)
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   582
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   583
lemma synth_trans: "\<lbrakk>X \<in> synth G;  G \<subseteq> synth H\<rbrakk> \<Longrightarrow> X \<in> synth H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   584
  by (drule synth_mono, blast)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   585
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   586
text\<open>Cut; Lemma 2 of Lowe\<close>
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   587
lemma synth_cut: "\<lbrakk>Y \<in> synth (insert X H);  X \<in> synth H\<rbrakk> \<Longrightarrow> Y \<in> synth H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   588
  by (erule synth_trans, blast)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   589
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   590
lemma Crypt_synth_eq [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   591
  "Key K \<notin> H \<Longrightarrow> (Crypt K X \<in> synth H) = (Crypt K X \<in> H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   592
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   593
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   594
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   595
lemma keysFor_synth [simp]: 
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   596
  "keysFor (synth H) = keysFor H \<union> invKey`{K. Key K \<in> H}"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   597
  unfolding keysFor_def by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   598
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   599
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   600
subsubsection\<open>Combinations of parts, analz and synth\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   601
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   602
lemma parts_synth [simp]: "parts (synth H) = parts H \<union> synth H"
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   603
proof -
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   604
  have "X \<in> parts (synth H) \<Longrightarrow> X \<in> parts H \<union> synth H" for X
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   605
    by (induction X rule: parts.induct) (auto intro: parts.intros)
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   606
  then show ?thesis
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   607
    by (meson parts_increasing parts_mono subsetI antisym sup_least synth_increasing)
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   608
qed
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   609
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   610
lemma analz_analz_Un [simp]: "analz (analz G \<union> H) = analz (G \<union> H)"
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   611
  using analz_cong by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   612
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   613
lemma analz_synth_Un [simp]: "analz (synth G \<union> H) = analz (G \<union> H) \<union> synth G"
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   614
proof -
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   615
  have "X \<in> analz (synth G \<union> H) \<Longrightarrow> X \<in> analz (G \<union> H) \<union> synth G" for X
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   616
    by (induction X rule: analz.induct) (auto intro: analz.intros)
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   617
  then show ?thesis
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   618
    by (metis analz_subset_iff le_sup_iff subsetI subset_antisym synth_subset_iff)
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   619
qed
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   620
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   621
lemma analz_synth [simp]: "analz (synth H) = analz H \<union> synth H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   622
  by (metis Un_empty_right analz_synth_Un)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   623
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   624
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   625
subsubsection\<open>For reasoning about the Fake rule in traces\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   626
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   627
lemma parts_insert_subset_Un: "X \<in> G \<Longrightarrow> parts(insert X H) \<subseteq> parts G \<union> parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   628
  by (metis UnCI Un_upper2 insert_subset parts_Un parts_mono)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   629
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   630
text\<open>More specifically for Fake. See also \<open>Fake_parts_sing\<close> below\<close>
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   631
lemma Fake_parts_insert:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   632
  "X \<in> synth (analz H) \<Longrightarrow>  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   633
      parts (insert X H) \<subseteq> synth (analz H) \<union> parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   634
  by (metis Un_commute analz_increasing insert_subset parts_analz parts_mono 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   635
      parts_synth synth_mono synth_subset_iff)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   636
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   637
lemma Fake_parts_insert_in_Un:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   638
  "\<lbrakk>Z \<in> parts (insert X H);  X \<in> synth (analz H)\<rbrakk> 
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   639
      \<Longrightarrow> Z \<in> synth (analz H) \<union> parts H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   640
  by (metis Fake_parts_insert subsetD)
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   641
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67613
diff changeset
   642
text\<open>\<^term>\<open>H\<close> is sometimes \<^term>\<open>Key ` KK \<union> spies evs\<close>, so can't put 
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67613
diff changeset
   643
  \<^term>\<open>G=H\<close>.\<close>
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   644
lemma Fake_analz_insert:
76338
e4fa45571bab A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 76299
diff changeset
   645
  "X \<in> synth (analz G) \<Longrightarrow>  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   646
      analz (insert X H) \<subseteq> synth (analz G) \<union> analz (G \<union> H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   647
  by (metis UnCI Un_commute Un_upper1 analz_analz_Un analz_mono analz_synth_Un insert_subset)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   648
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   649
lemma analz_conj_parts [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   650
  "(X \<in> analz H \<and> X \<in> parts H) = (X \<in> analz H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   651
  by (blast intro: analz_subset_parts [THEN subsetD])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   652
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   653
lemma analz_disj_parts [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   654
  "(X \<in> analz H | X \<in> parts H) = (X \<in> parts H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   655
  by (blast intro: analz_subset_parts [THEN subsetD])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   656
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   657
text\<open>Without this equation, other rules for synth and analz would yield
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   658
  redundant cases\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   659
lemma MPair_synth_analz [iff]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   660
  "\<lbrace>X,Y\<rbrace> \<in> synth (analz H) \<longleftrightarrow> X \<in> synth (analz H) \<and> Y \<in> synth (analz H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   661
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   662
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   663
lemma Crypt_synth_analz:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   664
  "\<lbrakk>Key K \<in> analz H;  Key (invKey K) \<in> analz H\<rbrakk>  
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   665
       \<Longrightarrow> (Crypt K X \<in> synth (analz H)) = (X \<in> synth (analz H))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   666
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   667
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   668
lemma Hash_synth_analz [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   669
  "X \<notin> synth (analz H)  
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   670
      \<Longrightarrow> (Hash\<lbrace>X,Y\<rbrace> \<in> synth (analz H)) = (Hash\<lbrace>X,Y\<rbrace> \<in> analz H)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   671
  by blast
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   672
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   673
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   674
subsection\<open>HPair: a combination of Hash and MPair\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   675
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   676
subsubsection\<open>Freeness\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   677
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   678
lemma Agent_neq_HPair: "Agent A \<noteq> Hash[X] Y"
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   679
  unfolding HPair_def by simp
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   680
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   681
lemma Nonce_neq_HPair: "Nonce N \<noteq> Hash[X] Y"
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   682
  unfolding HPair_def by simp
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   683
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   684
lemma Number_neq_HPair: "Number N \<noteq> Hash[X] Y"
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   685
  unfolding HPair_def by simp
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   686
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   687
lemma Key_neq_HPair: "Key K \<noteq> Hash[X] Y"
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   688
  unfolding HPair_def by simp
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   689
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   690
lemma Hash_neq_HPair: "Hash Z \<noteq> Hash[X] Y"
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   691
  unfolding HPair_def by simp
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   692
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   693
lemma Crypt_neq_HPair: "Crypt K X' \<noteq> Hash[X] Y"
57394
7621a3b42ce7 tiny refinements
paulson <lp15@cam.ac.uk>
parents: 51717
diff changeset
   694
  unfolding HPair_def by simp
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   695
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   696
lemmas HPair_neqs = Agent_neq_HPair Nonce_neq_HPair Number_neq_HPair 
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   697
  Key_neq_HPair Hash_neq_HPair Crypt_neq_HPair
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   698
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   699
declare HPair_neqs [iff]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   700
declare HPair_neqs [symmetric, iff]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   701
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   702
lemma HPair_eq [iff]: "(Hash[X'] Y' = Hash[X] Y) = (X' = X \<and> Y'=Y)"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   703
  by (simp add: HPair_def)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   704
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   705
lemma MPair_eq_HPair [iff]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   706
  "(\<lbrace>X',Y'\<rbrace> = Hash[X] Y) = (X' = Hash\<lbrace>X,Y\<rbrace> \<and> Y'=Y)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   707
  by (simp add: HPair_def)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   708
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   709
lemma HPair_eq_MPair [iff]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   710
  "(Hash[X] Y = \<lbrace>X',Y'\<rbrace>) = (X' = Hash\<lbrace>X,Y\<rbrace> \<and> Y'=Y)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   711
  by (auto simp add: HPair_def)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   712
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   713
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   714
subsubsection\<open>Specialized laws, proved in terms of those for Hash and MPair\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   715
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   716
lemma keysFor_insert_HPair [simp]: "keysFor (insert (Hash[X] Y) H) = keysFor H"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   717
  by (simp add: HPair_def)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   718
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   719
lemma parts_insert_HPair [simp]: 
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   720
  "parts (insert (Hash[X] Y) H) =  
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   721
     insert (Hash[X] Y) (insert (Hash\<lbrace>X,Y\<rbrace>) (parts (insert Y H)))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   722
  by (simp add: HPair_def)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   723
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   724
lemma analz_insert_HPair [simp]: 
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   725
  "analz (insert (Hash[X] Y) H) =  
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   726
     insert (Hash[X] Y) (insert (Hash\<lbrace>X,Y\<rbrace>) (analz (insert Y H)))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   727
  by (simp add: HPair_def)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   728
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   729
lemma HPair_synth_analz [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   730
  "X \<notin> synth (analz H)  
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   731
    \<Longrightarrow> (Hash[X] Y \<in> synth (analz H)) =  
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67443
diff changeset
   732
        (Hash \<lbrace>X, Y\<rbrace> \<in> analz H \<and> Y \<in> synth (analz H))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   733
  by (auto simp add: HPair_def)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   734
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   735
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   736
text\<open>We do NOT want Crypt... messages broken up in protocols!!\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   737
declare parts.Body [rule del]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   738
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   739
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   740
text\<open>Rewrites to push in Key and Crypt messages, so that other messages can
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   741
    be pulled out using the \<open>analz_insert\<close> rules\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   742
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 44174
diff changeset
   743
lemmas pushKeys =
27225
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   744
  insert_commute [of "Key K" "Agent C"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   745
  insert_commute [of "Key K" "Nonce N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   746
  insert_commute [of "Key K" "Number N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   747
  insert_commute [of "Key K" "Hash X"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   748
  insert_commute [of "Key K" "MPair X Y"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   749
  insert_commute [of "Key K" "Crypt X K'"]
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 44174
diff changeset
   750
  for K C N X Y K'
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   751
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 44174
diff changeset
   752
lemmas pushCrypts =
27225
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   753
  insert_commute [of "Crypt X K" "Agent C"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   754
  insert_commute [of "Crypt X K" "Agent C"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   755
  insert_commute [of "Crypt X K" "Nonce N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   756
  insert_commute [of "Crypt X K" "Number N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   757
  insert_commute [of "Crypt X K" "Hash X'"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   758
  insert_commute [of "Crypt X K" "MPair X' Y"]
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 44174
diff changeset
   759
  for X K C N X' Y
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   760
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   761
text\<open>Cannot be added with \<open>[simp]\<close> -- messages should not always be
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   762
  re-ordered.\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   763
lemmas pushes = pushKeys pushCrypts
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   764
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   765
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   766
subsection\<open>The set of key-free messages\<close>
43582
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   767
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   768
(*Note that even the encryption of a key-free message remains key-free.
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   769
  This concept is valuable because of the theorem analz_keyfree_into_Un, proved below. *)
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   770
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   771
inductive_set
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   772
  keyfree :: "msg set"
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   773
  where
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   774
    Agent:  "Agent A \<in> keyfree"
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   775
  | Number: "Number N \<in> keyfree"
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   776
  | Nonce:  "Nonce N \<in> keyfree"
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   777
  | Hash:   "Hash X \<in> keyfree"
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   778
  | MPair:  "\<lbrakk>X \<in> keyfree;  Y \<in> keyfree\<rbrakk> \<Longrightarrow> \<lbrace>X,Y\<rbrace> \<in> keyfree"
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   779
  | Crypt:  "\<lbrakk>X \<in> keyfree\<rbrakk> \<Longrightarrow> Crypt K X \<in> keyfree"
43582
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   780
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   781
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   782
declare keyfree.intros [intro] 
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   783
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   784
inductive_cases keyfree_KeyE: "Key K \<in> keyfree"
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   785
inductive_cases keyfree_MPairE: "\<lbrace>X,Y\<rbrace> \<in> keyfree"
43582
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   786
inductive_cases keyfree_CryptE: "Crypt K X \<in> keyfree"
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   787
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   788
lemma parts_keyfree: "parts (keyfree) \<subseteq> keyfree"
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   789
  by (clarify, erule parts.induct, auto elim!: keyfree_KeyE keyfree_MPairE keyfree_CryptE)
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   790
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   791
(*The key-free part of a set of messages can be removed from the scope of the analz operator.*)
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   792
lemma analz_keyfree_into_Un: "\<lbrakk>X \<in> analz (G \<union> H); G \<subseteq> keyfree\<rbrakk> \<Longrightarrow> X \<in> parts G \<union> analz H"
76291
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   793
proof (induction rule: analz.induct)
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   794
  case (Decrypt K X)
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   795
  then show ?case
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   796
    by (metis Un_iff analz.Decrypt in_mono keyfree_KeyE parts.Body parts_keyfree parts_mono)
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   797
qed (auto dest: parts.Body)
43582
ddca453102ab keyfree: The set of key-free messages (and associated theorems)
paulson
parents: 42793
diff changeset
   798
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   799
subsection\<open>Tactics useful for many protocol proofs\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   800
ML
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   801
  \<open>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   802
(*Analysis of Fake cases.  Also works for messages that forward unknown parts,
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   803
  but this application is no longer necessary if analz_insert_eq is used.
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   804
  DEPENDS UPON "X" REFERRING TO THE FRADULENT MESSAGE *)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   805
32117
0762b9ad83df Set.thy: prefer = over == where possible; tuned ML setup; dropped (moved) ML legacy
haftmann
parents: 30607
diff changeset
   806
fun impOfSubs th = th RSN (2, @{thm rev_subsetD})
0762b9ad83df Set.thy: prefer = over == where possible; tuned ML setup; dropped (moved) ML legacy
haftmann
parents: 30607
diff changeset
   807
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   808
(*Apply rules to break down assumptions of the form
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   809
  Y \<in> parts(insert X H)  and  Y \<in> analz(insert X H)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   810
*)
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   811
fun Fake_insert_tac ctxt = 
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   812
    dresolve_tac ctxt [impOfSubs @{thm Fake_analz_insert},
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   813
                  impOfSubs @{thm Fake_parts_insert}] THEN'
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   814
    eresolve_tac ctxt [asm_rl, @{thm synth.Inj}];
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   815
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 51702
diff changeset
   816
fun Fake_insert_simp_tac ctxt i = 
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   817
  REPEAT (Fake_insert_tac ctxt i) THEN asm_full_simp_tac ctxt i;
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   818
42474
8b139b8ee366 simplified/modernized method setup;
wenzelm
parents: 41774
diff changeset
   819
fun atomic_spy_analz_tac ctxt =
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   820
  SELECT_GOAL
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 51702
diff changeset
   821
   (Fake_insert_simp_tac ctxt 1 THEN
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   822
    IF_UNSOLVED
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   823
      (Blast.depth_tac
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   824
        (ctxt addIs [@{thm analz_insertI}, impOfSubs @{thm analz_subset_parts}]) 4 1));
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   825
42474
8b139b8ee366 simplified/modernized method setup;
wenzelm
parents: 41774
diff changeset
   826
fun spy_analz_tac ctxt i =
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   827
  DETERM
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   828
   (SELECT_GOAL
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   829
     (EVERY 
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   830
      [  (*push in occurrences of X...*)
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   831
       (REPEAT o CHANGED)
59780
23b67731f4f0 support 'for' fixes in rule_tac etc.;
wenzelm
parents: 59763
diff changeset
   832
         (Rule_Insts.res_inst_tac ctxt [((("x", 1), Position.none), "X")] []
82630
2bb4a8d0111d dropped unused ML bindings
haftmann
parents: 81182
diff changeset
   833
           (@{thm insert_commute} RS ssubst) 1),
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   834
       (*...allowing further simplifications*)
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 51702
diff changeset
   835
       simp_tac ctxt 1,
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58889
diff changeset
   836
       REPEAT (FIRSTGOAL (resolve_tac ctxt [allI,impI,notI,conjI,iffI])),
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42474
diff changeset
   837
       DEPTH_SOLVE (atomic_spy_analz_tac ctxt 1)]) i);
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   838
\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   839
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   840
text\<open>By default only \<open>o_apply\<close> is built-in.  But in the presence of
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67613
diff changeset
   841
eta-expansion this means that some terms displayed as \<^term>\<open>f o g\<close> will be
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   842
rewritten, and others will not!\<close>
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   843
declare o_def [simp]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   844
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   845
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   846
lemma Crypt_notin_image_Key [simp]: "Crypt K X \<notin> Key ` A"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   847
  by auto
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   848
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   849
lemma Hash_notin_image_Key [simp] :"Hash X \<notin> Key ` A"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   850
  by auto
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   851
76287
cdc14f94c754 Elimination of the archaic ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 73932
diff changeset
   852
lemma synth_analz_mono: "G\<subseteq>H \<Longrightarrow> synth (analz(G)) \<subseteq> synth (analz(H))"
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   853
  by (iprover intro: synth_mono analz_mono) 
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   854
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   855
lemma Fake_analz_eq [simp]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   856
  "X \<in> synth(analz H) \<Longrightarrow> synth (analz (insert X H)) = synth (analz H)"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   857
  by (metis Fake_analz_insert Un_absorb Un_absorb1 Un_commute 
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   858
      subset_insertI synth_analz_mono synth_increasing synth_subset_iff)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   859
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   860
text\<open>Two generalizations of \<open>analz_insert_eq\<close>\<close>
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   861
lemma gen_analz_insert_eq [rule_format]:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   862
  "X \<in> analz H \<Longrightarrow> \<forall>G. H \<subseteq> G \<longrightarrow> analz (insert X G) = analz G"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   863
  by (blast intro: analz_cut analz_insertI analz_mono [THEN [2] rev_subsetD])
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   864
76291
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   865
lemma synth_analz_insert_eq:
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   866
  "\<lbrakk>X \<in> synth (analz H); H \<subseteq> G\<rbrakk>
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   867
      \<Longrightarrow> (Key K \<in> analz (insert X G)) \<longleftrightarrow> (Key K \<in> analz G)"
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   868
proof (induction arbitrary: G rule: synth.induct)
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   869
  case (Inj X)
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   870
  then show ?case
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   871
    using gen_analz_insert_eq by presburger 
616405057951 Trying to clean up some messy proofs
paulson <lp15@cam.ac.uk>
parents: 76290
diff changeset
   872
qed (simp_all add: subset_eq)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   873
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   874
lemma Fake_parts_sing:
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   875
  "X \<in> synth (analz H) \<Longrightarrow> parts{X} \<subseteq> synth (analz H) \<union> parts H"
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   876
  by (metis Fake_parts_insert empty_subsetI insert_mono parts_mono subset_trans)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   877
14145
2e31b8cc8788 ZhouGollmann: new example (fair non-repudiation protocol)
paulson
parents: 14126
diff changeset
   878
lemmas Fake_parts_sing_imp_Un = Fake_parts_sing [THEN [2] rev_subsetD]
2e31b8cc8788 ZhouGollmann: new example (fair non-repudiation protocol)
paulson
parents: 14126
diff changeset
   879
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   880
method_setup spy_analz = \<open>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   881
    Scan.succeed (SIMPLE_METHOD' o spy_analz_tac)\<close>
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   882
  "for proving the Fake case when analz is involved"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   883
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   884
method_setup atomic_spy_analz = \<open>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   885
    Scan.succeed (SIMPLE_METHOD' o atomic_spy_analz_tac)\<close>
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   886
  "for debugging spy_analz"
11264
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   887
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   888
method_setup Fake_insert_simp = \<open>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59780
diff changeset
   889
    Scan.succeed (SIMPLE_METHOD' o Fake_insert_simp_tac)\<close>
76289
a6cc15ec45b2 Mostly trivial simplifications
paulson <lp15@cam.ac.uk>
parents: 76288
diff changeset
   890
  "for debugging spy_analz"
11264
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   891
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   892
end