src/HOL/Auth/Message.thy
author wenzelm
Fri, 20 Mar 2009 15:24:18 +0100
changeset 30607 c3d1590debd8
parent 30549 d2d7874648bd
child 32117 0762b9ad83df
permissions -rw-r--r--
eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/Message
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
13956
8fe7e12290e1 improved presentation of HOL/Auth theories
paulson
parents: 13926
diff changeset
     9
header{*Theory of Agents and Messages for Security Protocols*}
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"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    17
by blast
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    18
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    19
types 
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
14126
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    23
  all_symmetric :: bool        --{*true if all keys are symmetric*}
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    24
  invKey        :: "key=>key"  --{*inverse of a symmetric key*}
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"
942db403d4bb new, separate specifications
paulson
parents: 14145
diff changeset
    28
  invKey_symmetric: "all_symmetric --> 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
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    32
text{*The inverse of a symmetric key is itself; that of a public key
28824746d046 Tidying and replacement of some axioms by specifications
paulson
parents: 13956
diff changeset
    33
      is the private key and vice versa*}
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    34
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    35
constdefs
11230
756c5034f08b misc tidying; changing the predicate isSymKey to the set symKeys
paulson
parents: 11192
diff changeset
    36
  symKeys :: "key set"
756c5034f08b misc tidying; changing the predicate isSymKey to the set symKeys
paulson
parents: 11192
diff changeset
    37
  "symKeys == {K. invKey K = K}"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    38
16818
paulson
parents: 16796
diff changeset
    39
datatype  --{*We allow any number of friendly agents*}
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2010
diff changeset
    40
  agent = Server | Friend nat | Spy
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    41
3668
a39baf59ea47 Split base cases from "msg" to "atomic" in order
paulson
parents: 2516
diff changeset
    42
datatype
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
    43
     msg = Agent  agent	    --{*Agent names*}
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
    44
         | Number nat       --{*Ordinary integers, timestamps, ...*}
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
    45
         | Nonce  nat       --{*Unguessable nonces*}
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
    46
         | Key    key       --{*Crypto keys*}
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
    47
	 | Hash   msg       --{*Hashing*}
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
    48
	 | MPair  msg msg   --{*Compound messages*}
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
    49
	 | Crypt  key msg   --{*Encryption, public- or shared-key*}
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    50
5234
701fa0ed77b7 Better comments
paulson
parents: 5183
diff changeset
    51
16818
paulson
parents: 16796
diff changeset
    52
text{*Concrete syntax: messages appear as {|A,B,NA|}, etc...*}
5234
701fa0ed77b7 Better comments
paulson
parents: 5183
diff changeset
    53
syntax
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
    54
  "@MTuple"      :: "['a, args] => 'a * 'b"       ("(2{|_,/ _|})")
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    55
9686
87b460d72e80 xsymbols for {| and |}
paulson
parents: 7057
diff changeset
    56
syntax (xsymbols)
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    57
  "@MTuple"      :: "['a, args] => 'a * 'b"       ("(2\<lbrace>_,/ _\<rbrace>)")
9686
87b460d72e80 xsymbols for {| and |}
paulson
parents: 7057
diff changeset
    58
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    59
translations
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    60
  "{|x, y, z|}"   == "{|x, {|y, z|}|}"
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    61
  "{|x, y|}"      == "MPair x y"
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    62
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    63
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2373
diff changeset
    64
constdefs
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    65
  HPair :: "[msg,msg] => msg"                       ("(4Hash[_] /_)" [0, 1000])
16818
paulson
parents: 16796
diff changeset
    66
    --{*Message Y paired with a MAC computed with the help of X*}
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2484
diff changeset
    67
    "Hash[X] Y == {| Hash{|X,Y|}, Y|}"
2484
596a5b5a68ff Incorporation of HPair into Message
paulson
parents: 2373
diff changeset
    68
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    69
  keysFor :: "msg set => key set"
16818
paulson
parents: 16796
diff changeset
    70
    --{*Keys useful to decrypt elements of a message set*}
11192
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
    71
  "keysFor H == invKey ` {K. \<exists>X. Crypt K X \<in> H}"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    72
16818
paulson
parents: 16796
diff changeset
    73
paulson
parents: 16796
diff changeset
    74
subsubsection{*Inductive Definition of All Parts" of a Message*}
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    75
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    76
inductive_set
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    77
  parts :: "msg set => msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    78
  for H :: "msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    79
  where
11192
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
    80
    Inj [intro]:               "X \<in> H ==> X \<in> parts H"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    81
  | Fst:         "{|X,Y|}   \<in> parts H ==> X \<in> parts H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    82
  | Snd:         "{|X,Y|}   \<in> parts H ==> Y \<in> parts H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
    83
  | Body:        "Crypt K X \<in> parts H ==> X \<in> parts H"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    84
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    85
16818
paulson
parents: 16796
diff changeset
    86
text{*Monotonicity*}
paulson
parents: 16796
diff changeset
    87
lemma parts_mono: "G \<subseteq> H ==> parts(G) \<subseteq> parts(H)"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    88
apply auto
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    89
apply (erule parts.induct) 
16818
paulson
parents: 16796
diff changeset
    90
apply (blast dest: parts.Fst parts.Snd parts.Body)+
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
    91
done
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    92
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
    93
16818
paulson
parents: 16796
diff changeset
    94
text{*Equations hold because constructors are injective.*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    95
lemma Friend_image_eq [simp]: "(Friend x \<in> Friend`A) = (x:A)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    96
by auto
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    97
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    98
lemma Key_image_eq [simp]: "(Key x \<in> Key`A) = (x\<in>A)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
    99
by auto
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   100
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   101
lemma Nonce_Key_image_eq [simp]: "(Nonce x \<notin> Key`A)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   102
by auto
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   103
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   104
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   105
subsubsection{*Inverse of keys *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   106
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   107
lemma invKey_eq [simp]: "(invKey K = invKey K') = (K=K')"
28698
b1c4366e1212 metis proof
paulson
parents: 27239
diff changeset
   108
by (metis invKey)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   109
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   110
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   111
subsection{*keysFor operator*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   112
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   113
lemma keysFor_empty [simp]: "keysFor {} = {}"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   114
by (unfold keysFor_def, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   115
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   116
lemma keysFor_Un [simp]: "keysFor (H \<union> H') = keysFor H \<union> keysFor H'"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   117
by (unfold keysFor_def, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   118
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   119
lemma keysFor_UN [simp]: "keysFor (\<Union>i\<in>A. H i) = (\<Union>i\<in>A. keysFor (H i))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   120
by (unfold keysFor_def, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   121
16818
paulson
parents: 16796
diff changeset
   122
text{*Monotonicity*}
paulson
parents: 16796
diff changeset
   123
lemma keysFor_mono: "G \<subseteq> H ==> keysFor(G) \<subseteq> keysFor(H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   124
by (unfold keysFor_def, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   125
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   126
lemma keysFor_insert_Agent [simp]: "keysFor (insert (Agent A) H) = keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   127
by (unfold keysFor_def, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   128
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   129
lemma keysFor_insert_Nonce [simp]: "keysFor (insert (Nonce N) H) = keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   130
by (unfold keysFor_def, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   131
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   132
lemma keysFor_insert_Number [simp]: "keysFor (insert (Number N) H) = keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   133
by (unfold keysFor_def, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   134
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   135
lemma keysFor_insert_Key [simp]: "keysFor (insert (Key K) H) = keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   136
by (unfold keysFor_def, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   137
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   138
lemma keysFor_insert_Hash [simp]: "keysFor (insert (Hash X) H) = keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   139
by (unfold keysFor_def, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   140
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   141
lemma keysFor_insert_MPair [simp]: "keysFor (insert {|X,Y|} H) = keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   142
by (unfold keysFor_def, auto)
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_insert_Crypt [simp]: 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   145
    "keysFor (insert (Crypt K X) H) = insert (invKey K) (keysFor H)"
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   146
by (unfold keysFor_def, auto)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   147
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   148
lemma keysFor_image_Key [simp]: "keysFor (Key`E) = {}"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   149
by (unfold keysFor_def, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   150
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   151
lemma Crypt_imp_invKey_keysFor: "Crypt K X \<in> H ==> invKey K \<in> keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   152
by (unfold keysFor_def, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   153
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   154
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   155
subsection{*Inductive relation "parts"*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   156
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   157
lemma MPair_parts:
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   158
     "[| {|X,Y|} \<in> parts H;        
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   159
         [| X \<in> parts H; Y \<in> parts H |] ==> P |] ==> P"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   160
by (blast dest: parts.Fst parts.Snd) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   161
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   162
declare MPair_parts [elim!]  parts.Body [dest!]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   163
text{*NB These two rules are UNSAFE in the formal sense, as they discard the
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   164
     compound message.  They work well on THIS FILE.  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   165
  @{text MPair_parts} is left as SAFE because it speeds up proofs.
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   166
  The Crypt rule is normally kept UNSAFE to avoid breaking up certificates.*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   167
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   168
lemma parts_increasing: "H \<subseteq> parts(H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   169
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   170
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   171
lemmas parts_insertI = subset_insertI [THEN parts_mono, THEN subsetD, standard]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   172
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   173
lemma parts_empty [simp]: "parts{} = {}"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   174
apply safe
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   175
apply (erule parts.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   176
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   177
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   178
lemma parts_emptyE [elim!]: "X\<in> parts{} ==> P"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   179
by simp
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   180
16818
paulson
parents: 16796
diff changeset
   181
text{*WARNING: loops if H = {Y}, therefore must not be repeated!*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   182
lemma parts_singleton: "X\<in> parts H ==> \<exists>Y\<in>H. X\<in> parts {Y}"
26807
4cd176ea28dc Replaced blast by fast in proof of parts_singleton, since blast looped
berghofe
parents: 26342
diff changeset
   183
by (erule parts.induct, fast+)
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
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   186
subsubsection{*Unions *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   187
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   188
lemma parts_Un_subset1: "parts(G) \<union> parts(H) \<subseteq> parts(G \<union> H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   189
by (intro Un_least parts_mono Un_upper1 Un_upper2)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   190
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   191
lemma parts_Un_subset2: "parts(G \<union> H) \<subseteq> parts(G) \<union> parts(H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   192
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   193
apply (erule parts.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   194
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   195
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   196
lemma parts_Un [simp]: "parts(G \<union> H) = parts(G) \<union> parts(H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   197
by (intro equalityI parts_Un_subset1 parts_Un_subset2)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   198
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   199
lemma parts_insert: "parts (insert X H) = parts {X} \<union> parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   200
apply (subst insert_is_Un [of _ H])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   201
apply (simp only: parts_Un)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   202
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   203
16818
paulson
parents: 16796
diff changeset
   204
text{*TWO inserts to avoid looping.  This rewrite is better than nothing.
paulson
parents: 16796
diff changeset
   205
  Not suitable for Addsimps: its behaviour can be strange.*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   206
lemma parts_insert2:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   207
     "parts (insert X (insert Y H)) = parts {X} \<union> parts {Y} \<union> parts H"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   208
apply (simp add: Un_assoc)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   209
apply (simp add: parts_insert [symmetric])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   210
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   211
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   212
lemma parts_UN_subset1: "(\<Union>x\<in>A. parts(H x)) \<subseteq> parts(\<Union>x\<in>A. H x)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   213
by (intro UN_least parts_mono UN_upper)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   214
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   215
lemma parts_UN_subset2: "parts(\<Union>x\<in>A. H x) \<subseteq> (\<Union>x\<in>A. parts(H x))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   216
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   217
apply (erule parts.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   218
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   219
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   220
lemma parts_UN [simp]: "parts(\<Union>x\<in>A. H x) = (\<Union>x\<in>A. parts(H x))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   221
by (intro equalityI parts_UN_subset1 parts_UN_subset2)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   222
16818
paulson
parents: 16796
diff changeset
   223
text{*Added to simplify arguments to parts, analz and synth.
paulson
parents: 16796
diff changeset
   224
  NOTE: the UN versions are no longer used!*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   225
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   226
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   227
text{*This allows @{text blast} to simplify occurrences of 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   228
  @{term "parts(G\<union>H)"} in the assumption.*}
17729
d74d0b5052a0 theorems need names
paulson
parents: 17689
diff changeset
   229
lemmas in_parts_UnE = parts_Un [THEN equalityD1, THEN subsetD, THEN UnE] 
d74d0b5052a0 theorems need names
paulson
parents: 17689
diff changeset
   230
declare in_parts_UnE [elim!]
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   231
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   232
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   233
lemma parts_insert_subset: "insert X (parts H) \<subseteq> parts(insert X H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   234
by (blast intro: parts_mono [THEN [2] rev_subsetD])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   235
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   236
subsubsection{*Idempotence and transitivity *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   237
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   238
lemma parts_partsD [dest!]: "X\<in> parts (parts H) ==> X\<in> parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   239
by (erule parts.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   240
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   241
lemma parts_idem [simp]: "parts (parts H) = parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   242
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   243
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   244
lemma parts_subset_iff [simp]: "(parts G \<subseteq> parts H) = (G \<subseteq> parts H)"
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   245
apply (rule iffI)
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   246
apply (iprover intro: subset_trans parts_increasing)  
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   247
apply (frule parts_mono, simp) 
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   248
done
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   249
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   250
lemma parts_trans: "[| X\<in> parts G;  G \<subseteq> parts H |] ==> X\<in> parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   251
by (drule parts_mono, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   252
16818
paulson
parents: 16796
diff changeset
   253
text{*Cut*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   254
lemma parts_cut:
18492
b0fe60800623 shorter proof
paulson
parents: 17729
diff changeset
   255
     "[| Y\<in> parts (insert X G);  X\<in> parts H |] ==> Y\<in> parts (G \<union> H)" 
b0fe60800623 shorter proof
paulson
parents: 17729
diff changeset
   256
by (blast intro: parts_trans) 
b0fe60800623 shorter proof
paulson
parents: 17729
diff changeset
   257
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   258
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   259
lemma parts_cut_eq [simp]: "X\<in> parts H ==> parts (insert X H) = parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   260
by (force dest!: parts_cut intro: parts_insertI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   261
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   262
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   263
subsubsection{*Rewrite rules for pulling out atomic messages *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   264
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   265
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
   266
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   267
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   268
lemma parts_insert_Agent [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   269
     "parts (insert (Agent agt) H) = insert (Agent agt) (parts H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   270
apply (rule parts_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   271
apply (erule parts.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   272
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   273
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   274
lemma parts_insert_Nonce [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   275
     "parts (insert (Nonce N) H) = insert (Nonce N) (parts H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   276
apply (rule parts_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   277
apply (erule parts.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   278
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   279
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   280
lemma parts_insert_Number [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   281
     "parts (insert (Number N) H) = insert (Number N) (parts H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   282
apply (rule parts_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   283
apply (erule parts.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   284
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   285
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   286
lemma parts_insert_Key [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   287
     "parts (insert (Key K) H) = insert (Key K) (parts H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   288
apply (rule parts_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   289
apply (erule parts.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   290
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   291
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   292
lemma parts_insert_Hash [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   293
     "parts (insert (Hash X) H) = insert (Hash X) (parts H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   294
apply (rule parts_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   295
apply (erule parts.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   296
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   297
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   298
lemma parts_insert_Crypt [simp]:
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   299
     "parts (insert (Crypt K X) H) = insert (Crypt K X) (parts (insert X H))"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   300
apply (rule equalityI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   301
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   302
apply (erule parts.induct, auto)
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   303
apply (blast intro: parts.Body)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   304
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   305
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   306
lemma parts_insert_MPair [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   307
     "parts (insert {|X,Y|} H) =  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   308
          insert {|X,Y|} (parts (insert X (insert Y H)))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   309
apply (rule equalityI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   310
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   311
apply (erule parts.induct, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   312
apply (blast intro: parts.Fst parts.Snd)+
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   313
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   314
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   315
lemma parts_image_Key [simp]: "parts (Key`N) = Key`N"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   316
apply auto
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   317
apply (erule parts.induct, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   318
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   319
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   320
16818
paulson
parents: 16796
diff changeset
   321
text{*In any message, there is an upper bound N on its greatest nonce.*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   322
lemma msg_Nonce_supply: "\<exists>N. \<forall>n. N\<le>n --> Nonce n \<notin> parts {msg}"
27105
5f139027c365 slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
haftmann
parents: 26807
diff changeset
   323
apply (induct msg)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   324
apply (simp_all (no_asm_simp) add: exI parts_insert2)
16818
paulson
parents: 16796
diff changeset
   325
 txt{*MPair case: blast works out the necessary sum itself!*}
22424
8a5412121687 *** empty log message ***
haftmann
parents: 21588
diff changeset
   326
 prefer 2 apply auto apply (blast elim!: add_leE)
16818
paulson
parents: 16796
diff changeset
   327
txt{*Nonce case*}
paulson
parents: 16796
diff changeset
   328
apply (rule_tac x = "N + Suc nat" in exI, auto) 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   329
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   330
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   331
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   332
subsection{*Inductive relation "analz"*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   333
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   334
text{*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
   335
    messages, including keys.  A form of downward closure.  Pairs can
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   336
    be taken apart; messages decrypted with known keys.  *}
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   337
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   338
inductive_set
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   339
  analz :: "msg set => msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   340
  for H :: "msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   341
  where
11192
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   342
    Inj [intro,simp] :    "X \<in> H ==> X \<in> analz H"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   343
  | Fst:     "{|X,Y|} \<in> analz H ==> X \<in> analz H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   344
  | Snd:     "{|X,Y|} \<in> analz H ==> Y \<in> analz H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   345
  | Decrypt [dest]: 
11192
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   346
             "[|Crypt K X \<in> analz H; Key(invKey K): analz H|] ==> X \<in> analz H"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   347
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   348
16818
paulson
parents: 16796
diff changeset
   349
text{*Monotonicity; Lemma 1 of Lowe's paper*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   350
lemma analz_mono: "G\<subseteq>H ==> analz(G) \<subseteq> analz(H)"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   351
apply auto
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   352
apply (erule analz.induct) 
16818
paulson
parents: 16796
diff changeset
   353
apply (auto dest: analz.Fst analz.Snd) 
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   354
done
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   355
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   356
text{*Making it safe speeds up proofs*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   357
lemma MPair_analz [elim!]:
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   358
     "[| {|X,Y|} \<in> analz H;        
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   359
             [| X \<in> analz H; Y \<in> analz H |] ==> P   
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   360
          |] ==> P"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   361
by (blast dest: analz.Fst analz.Snd)
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_increasing: "H \<subseteq> analz(H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   364
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   365
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   366
lemma analz_subset_parts: "analz H \<subseteq> parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   367
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   368
apply (erule analz.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   369
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   370
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   371
lemmas analz_into_parts = analz_subset_parts [THEN subsetD, standard]
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   372
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   373
lemmas not_parts_not_analz = analz_subset_parts [THEN contra_subsetD, standard]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   374
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
lemma parts_analz [simp]: "parts (analz H) = parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   377
apply (rule equalityI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   378
apply (rule analz_subset_parts [THEN parts_mono, THEN subset_trans], simp)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   379
apply (blast intro: analz_increasing [THEN parts_mono, THEN subsetD])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   380
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   381
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   382
lemma analz_parts [simp]: "analz (parts H) = parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   383
apply auto
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   384
apply (erule analz.induct, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   385
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   386
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   387
lemmas analz_insertI = subset_insertI [THEN analz_mono, THEN [2] rev_subsetD, standard]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   388
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   389
subsubsection{*General equational properties *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   390
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   391
lemma analz_empty [simp]: "analz{} = {}"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   392
apply safe
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   393
apply (erule analz.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   394
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   395
16818
paulson
parents: 16796
diff changeset
   396
text{*Converse fails: we can analz more from the union than from the 
paulson
parents: 16796
diff changeset
   397
  separate parts, as a key in one might decrypt a message in the other*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   398
lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   399
by (intro Un_least analz_mono Un_upper1 Un_upper2)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   400
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   401
lemma analz_insert: "insert X (analz H) \<subseteq> analz(insert X H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   402
by (blast intro: analz_mono [THEN [2] rev_subsetD])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   403
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   404
subsubsection{*Rewrite rules for pulling out atomic messages *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   405
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   406
lemmas analz_insert_eq_I = equalityI [OF subsetI analz_insert]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   407
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   408
lemma analz_insert_Agent [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   409
     "analz (insert (Agent agt) H) = insert (Agent agt) (analz H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   410
apply (rule analz_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   411
apply (erule analz.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   412
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   413
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   414
lemma analz_insert_Nonce [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   415
     "analz (insert (Nonce N) H) = insert (Nonce N) (analz H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   416
apply (rule analz_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   417
apply (erule analz.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   418
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   419
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   420
lemma analz_insert_Number [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   421
     "analz (insert (Number N) H) = insert (Number N) (analz H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   422
apply (rule analz_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   423
apply (erule analz.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   424
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   425
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   426
lemma analz_insert_Hash [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   427
     "analz (insert (Hash X) H) = insert (Hash X) (analz H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   428
apply (rule analz_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   429
apply (erule analz.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   430
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   431
16818
paulson
parents: 16796
diff changeset
   432
text{*Can only pull out Keys if they are not needed to decrypt the rest*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   433
lemma analz_insert_Key [simp]: 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   434
    "K \<notin> keysFor (analz H) ==>   
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   435
          analz (insert (Key K) H) = insert (Key K) (analz H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   436
apply (unfold keysFor_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   437
apply (rule analz_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   438
apply (erule analz.induct, auto) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   439
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   440
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   441
lemma analz_insert_MPair [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   442
     "analz (insert {|X,Y|} H) =  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   443
          insert {|X,Y|} (analz (insert X (insert Y H)))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   444
apply (rule equalityI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   445
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   446
apply (erule analz.induct, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   447
apply (erule analz.induct)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   448
apply (blast intro: analz.Fst analz.Snd)+
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   449
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   450
16818
paulson
parents: 16796
diff changeset
   451
text{*Can pull out enCrypted message if the Key is not known*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   452
lemma analz_insert_Crypt:
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   453
     "Key (invKey K) \<notin> analz H 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   454
      ==> analz (insert (Crypt K X) H) = insert (Crypt K X) (analz H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   455
apply (rule analz_insert_eq_I) 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   456
apply (erule analz.induct, auto) 
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
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   459
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   460
lemma lemma1: "Key (invKey K) \<in> analz H ==>   
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   461
               analz (insert (Crypt K X) H) \<subseteq>  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   462
               insert (Crypt K X) (analz (insert X H))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   463
apply (rule subsetI)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   464
apply (erule_tac x = x in analz.induct, auto)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   465
done
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
lemma lemma2: "Key (invKey K) \<in> analz H ==>   
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   468
               insert (Crypt K X) (analz (insert X H)) \<subseteq>  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   469
               analz (insert (Crypt K X) H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   470
apply auto
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   471
apply (erule_tac x = x in analz.induct, auto)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   472
apply (blast intro: analz_insertI analz.Decrypt)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   473
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   474
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   475
lemma analz_insert_Decrypt:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   476
     "Key (invKey K) \<in> analz H ==>   
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   477
               analz (insert (Crypt K X) H) =  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   478
               insert (Crypt K X) (analz (insert X H))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   479
by (intro equalityI lemma1 lemma2)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   480
16818
paulson
parents: 16796
diff changeset
   481
text{*Case analysis: either the message is secure, or it is not! Effective,
paulson
parents: 16796
diff changeset
   482
but can cause subgoals to blow up! Use with @{text "split_if"}; apparently
paulson
parents: 16796
diff changeset
   483
@{text "split_tac"} does not cope with patterns such as @{term"analz (insert
paulson
parents: 16796
diff changeset
   484
(Crypt K X) H)"} *} 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   485
lemma analz_Crypt_if [simp]:
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   486
     "analz (insert (Crypt K X) H) =                 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   487
          (if (Key (invKey K) \<in> analz H)                 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   488
           then insert (Crypt K X) (analz (insert X H))  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   489
           else insert (Crypt K X) (analz H))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   490
by (simp add: analz_insert_Crypt analz_insert_Decrypt)
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
16818
paulson
parents: 16796
diff changeset
   493
text{*This rule supposes "for the sake of argument" that we have the key.*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   494
lemma analz_insert_Crypt_subset:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   495
     "analz (insert (Crypt K X) H) \<subseteq>   
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   496
           insert (Crypt K X) (analz (insert X H))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   497
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   498
apply (erule analz.induct, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   499
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   500
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
lemma analz_image_Key [simp]: "analz (Key`N) = Key`N"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   503
apply auto
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   504
apply (erule analz.induct, auto)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   505
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   506
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   507
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   508
subsubsection{*Idempotence and transitivity *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   509
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   510
lemma analz_analzD [dest!]: "X\<in> analz (analz H) ==> X\<in> analz H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   511
by (erule analz.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   512
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   513
lemma analz_idem [simp]: "analz (analz H) = analz H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   514
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   515
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   516
lemma analz_subset_iff [simp]: "(analz G \<subseteq> analz H) = (G \<subseteq> analz H)"
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   517
apply (rule iffI)
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   518
apply (iprover intro: subset_trans analz_increasing)  
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   519
apply (frule analz_mono, simp) 
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   520
done
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   521
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   522
lemma analz_trans: "[| X\<in> analz G;  G \<subseteq> analz H |] ==> X\<in> analz H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   523
by (drule analz_mono, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   524
16818
paulson
parents: 16796
diff changeset
   525
text{*Cut; Lemma 2 of Lowe*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   526
lemma analz_cut: "[| Y\<in> analz (insert X H);  X\<in> analz H |] ==> Y\<in> analz H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   527
by (erule analz_trans, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   528
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   529
(*Cut can be proved easily by induction on
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   530
   "Y: analz (insert X H) ==> X: analz H --> Y: analz H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   531
*)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   532
16818
paulson
parents: 16796
diff changeset
   533
text{*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
   534
  the forwarding of unknown components (X).  Without it, removing occurrences
16818
paulson
parents: 16796
diff changeset
   535
  of X can be very complicated. *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   536
lemma analz_insert_eq: "X\<in> analz H ==> analz (insert X H) = analz H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   537
by (blast intro: analz_cut analz_insertI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   538
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   539
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   540
text{*A congruence rule for "analz" *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   541
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   542
lemma analz_subset_cong:
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   543
     "[| analz G \<subseteq> analz G'; analz H \<subseteq> analz H' |] 
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   544
      ==> analz (G \<union> H) \<subseteq> analz (G' \<union> H')"
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   545
apply simp
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   546
apply (iprover intro: conjI subset_trans analz_mono Un_upper1 Un_upper2) 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   547
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   548
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   549
lemma analz_cong:
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   550
     "[| analz G = analz G'; analz H = analz H' |] 
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   551
      ==> analz (G \<union> H) = analz (G' \<union> H')"
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   552
by (intro equalityI analz_subset_cong, simp_all) 
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   553
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   554
lemma analz_insert_cong:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   555
     "analz H = analz H' ==> analz(insert X H) = analz(insert X H')"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   556
by (force simp only: insert_def intro!: analz_cong)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   557
16818
paulson
parents: 16796
diff changeset
   558
text{*If there are no pairs or encryptions then analz does nothing*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   559
lemma analz_trivial:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   560
     "[| \<forall>X Y. {|X,Y|} \<notin> H;  \<forall>X K. Crypt K X \<notin> H |] ==> analz H = H"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   561
apply safe
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   562
apply (erule analz.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   563
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   564
16818
paulson
parents: 16796
diff changeset
   565
text{*These two are obsolete (with a single Spy) but cost little to prove...*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   566
lemma analz_UN_analz_lemma:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   567
     "X\<in> analz (\<Union>i\<in>A. analz (H i)) ==> X\<in> analz (\<Union>i\<in>A. H i)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   568
apply (erule analz.induct)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   569
apply (blast intro: analz_mono [THEN [2] rev_subsetD])+
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   570
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   571
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   572
lemma analz_UN_analz [simp]: "analz (\<Union>i\<in>A. analz (H i)) = analz (\<Union>i\<in>A. H i)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   573
by (blast intro: analz_UN_analz_lemma analz_mono [THEN [2] rev_subsetD])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   574
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   575
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   576
subsection{*Inductive relation "synth"*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   577
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   578
text{*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
   579
    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
   580
    encrypted with known keys.  Agent names are public domain.
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   581
    Numbers can be guessed, but Nonces cannot be.  *}
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   582
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   583
inductive_set
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   584
  synth :: "msg set => msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   585
  for H :: "msg set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   586
  where
11192
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   587
    Inj    [intro]:   "X \<in> H ==> X \<in> synth H"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   588
  | Agent  [intro]:   "Agent agt \<in> synth H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   589
  | Number [intro]:   "Number n  \<in> synth H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   590
  | Hash   [intro]:   "X \<in> synth H ==> Hash X \<in> synth H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   591
  | MPair  [intro]:   "[|X \<in> synth H;  Y \<in> synth H|] ==> {|X,Y|} \<in> synth H"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 22843
diff changeset
   592
  | Crypt  [intro]:   "[|X \<in> synth H;  Key(K) \<in> H|] ==> Crypt K X \<in> synth H"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   593
16818
paulson
parents: 16796
diff changeset
   594
text{*Monotonicity*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   595
lemma synth_mono: "G\<subseteq>H ==> synth(G) \<subseteq> synth(H)"
16818
paulson
parents: 16796
diff changeset
   596
  by (auto, erule synth.induct, auto)  
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   597
16818
paulson
parents: 16796
diff changeset
   598
text{*NO @{text Agent_synth}, as any Agent name can be synthesized.  
paulson
parents: 16796
diff changeset
   599
  The same holds for @{term Number}*}
11192
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   600
inductive_cases Nonce_synth [elim!]: "Nonce n \<in> synth H"
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   601
inductive_cases Key_synth   [elim!]: "Key K \<in> synth H"
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   602
inductive_cases Hash_synth  [elim!]: "Hash X \<in> synth H"
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   603
inductive_cases MPair_synth [elim!]: "{|X,Y|} \<in> synth H"
5fd02b905a9a a few basic X-symbols
paulson
parents: 11189
diff changeset
   604
inductive_cases Crypt_synth [elim!]: "Crypt K X \<in> synth H"
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   605
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   606
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   607
lemma synth_increasing: "H \<subseteq> synth(H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   608
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   609
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   610
subsubsection{*Unions *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   611
16818
paulson
parents: 16796
diff changeset
   612
text{*Converse fails: we can synth more from the union than from the 
paulson
parents: 16796
diff changeset
   613
  separate parts, building a compound message using elements of each.*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   614
lemma synth_Un: "synth(G) \<union> synth(H) \<subseteq> synth(G \<union> H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   615
by (intro Un_least synth_mono Un_upper1 Un_upper2)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   616
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   617
lemma synth_insert: "insert X (synth H) \<subseteq> synth(insert X H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   618
by (blast intro: synth_mono [THEN [2] rev_subsetD])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   619
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   620
subsubsection{*Idempotence and transitivity *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   621
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   622
lemma synth_synthD [dest!]: "X\<in> synth (synth H) ==> X\<in> synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   623
by (erule synth.induct, blast+)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   624
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   625
lemma synth_idem: "synth (synth H) = synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   626
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   627
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   628
lemma synth_subset_iff [simp]: "(synth G \<subseteq> synth H) = (G \<subseteq> synth H)"
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   629
apply (rule iffI)
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   630
apply (iprover intro: subset_trans synth_increasing)  
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   631
apply (frule synth_mono, simp add: synth_idem) 
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   632
done
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   633
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   634
lemma synth_trans: "[| X\<in> synth G;  G \<subseteq> synth H |] ==> X\<in> synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   635
by (drule synth_mono, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   636
16818
paulson
parents: 16796
diff changeset
   637
text{*Cut; Lemma 2 of Lowe*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   638
lemma synth_cut: "[| Y\<in> synth (insert X H);  X\<in> synth H |] ==> Y\<in> synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   639
by (erule synth_trans, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   640
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   641
lemma Agent_synth [simp]: "Agent A \<in> synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   642
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   643
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   644
lemma Number_synth [simp]: "Number n \<in> synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   645
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   646
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   647
lemma Nonce_synth_eq [simp]: "(Nonce N \<in> synth H) = (Nonce N \<in> H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   648
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   649
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   650
lemma Key_synth_eq [simp]: "(Key K \<in> synth H) = (Key K \<in> H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   651
by blast
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 Crypt_synth_eq [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   654
     "Key K \<notin> H ==> (Crypt K X \<in> synth H) = (Crypt K X \<in> H)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   655
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   656
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   657
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   658
lemma keysFor_synth [simp]: 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   659
    "keysFor (synth H) = keysFor H \<union> invKey`{K. Key K \<in> H}"
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   660
by (unfold keysFor_def, blast)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   661
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
subsubsection{*Combinations of parts, analz and synth *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   664
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   665
lemma parts_synth [simp]: "parts (synth H) = parts H \<union> synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   666
apply (rule equalityI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   667
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   668
apply (erule parts.induct)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   669
apply (blast intro: synth_increasing [THEN parts_mono, THEN subsetD] 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   670
                    parts.Fst parts.Snd parts.Body)+
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   671
done
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
lemma analz_analz_Un [simp]: "analz (analz G \<union> H) = analz (G \<union> H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   674
apply (intro equalityI analz_subset_cong)+
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   675
apply simp_all
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   676
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   677
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   678
lemma analz_synth_Un [simp]: "analz (synth G \<union> H) = analz (G \<union> H) \<union> synth G"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   679
apply (rule equalityI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   680
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   681
apply (erule analz.induct)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   682
prefer 5 apply (blast intro: analz_mono [THEN [2] rev_subsetD])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   683
apply (blast intro: analz.Fst analz.Snd analz.Decrypt)+
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   684
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   685
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   686
lemma analz_synth [simp]: "analz (synth H) = analz H \<union> synth H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   687
apply (cut_tac H = "{}" in analz_synth_Un)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   688
apply (simp (no_asm_use))
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   689
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   690
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   691
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   692
subsubsection{*For reasoning about the Fake rule in traces *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   693
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   694
lemma parts_insert_subset_Un: "X\<in> G ==> parts(insert X H) \<subseteq> parts G \<union> parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   695
by (rule subset_trans [OF parts_mono parts_Un_subset2], blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   696
16818
paulson
parents: 16796
diff changeset
   697
text{*More specifically for Fake.  Very occasionally we could do with a version
paulson
parents: 16796
diff changeset
   698
  of the form  @{term"parts{X} \<subseteq> synth (analz H) \<union> parts H"} *}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   699
lemma Fake_parts_insert:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   700
     "X \<in> synth (analz H) ==>  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   701
      parts (insert X H) \<subseteq> synth (analz H) \<union> parts H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   702
apply (drule parts_insert_subset_Un)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   703
apply (simp (no_asm_use))
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   704
apply blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   705
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   706
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   707
lemma Fake_parts_insert_in_Un:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   708
     "[|Z \<in> parts (insert X H);  X: synth (analz H)|] 
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   709
      ==> Z \<in>  synth (analz H) \<union> parts H";
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   710
by (blast dest: Fake_parts_insert  [THEN subsetD, dest])
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   711
16818
paulson
parents: 16796
diff changeset
   712
text{*@{term H} is sometimes @{term"Key ` KK \<union> spies evs"}, so can't put 
paulson
parents: 16796
diff changeset
   713
  @{term "G=H"}.*}
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   714
lemma Fake_analz_insert:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   715
     "X\<in> synth (analz G) ==>  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   716
      analz (insert X H) \<subseteq> synth (analz G) \<union> analz (G \<union> H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   717
apply (rule subsetI)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   718
apply (subgoal_tac "x \<in> analz (synth (analz G) \<union> H) ")
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   719
prefer 2 apply (blast intro: analz_mono [THEN [2] rev_subsetD] analz_mono [THEN synth_mono, THEN [2] rev_subsetD])
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   720
apply (simp (no_asm_use))
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   721
apply blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   722
done
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   723
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   724
lemma analz_conj_parts [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   725
     "(X \<in> analz H & X \<in> parts H) = (X \<in> analz H)"
14145
2e31b8cc8788 ZhouGollmann: new example (fair non-repudiation protocol)
paulson
parents: 14126
diff changeset
   726
by (blast intro: analz_subset_parts [THEN subsetD])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   727
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   728
lemma analz_disj_parts [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   729
     "(X \<in> analz H | X \<in> parts H) = (X \<in> parts H)"
14145
2e31b8cc8788 ZhouGollmann: new example (fair non-repudiation protocol)
paulson
parents: 14126
diff changeset
   730
by (blast intro: analz_subset_parts [THEN subsetD])
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   731
16818
paulson
parents: 16796
diff changeset
   732
text{*Without this equation, other rules for synth and analz would yield
paulson
parents: 16796
diff changeset
   733
  redundant cases*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   734
lemma MPair_synth_analz [iff]:
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   735
     "({|X,Y|} \<in> synth (analz H)) =  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   736
      (X \<in> synth (analz H) & Y \<in> synth (analz H))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   737
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   738
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   739
lemma Crypt_synth_analz:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   740
     "[| Key K \<in> analz H;  Key (invKey K) \<in> analz H |]  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   741
       ==> (Crypt K X \<in> synth (analz H)) = (X \<in> synth (analz H))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   742
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   743
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   744
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   745
lemma Hash_synth_analz [simp]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   746
     "X \<notin> synth (analz H)  
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   747
      ==> (Hash{|X,Y|} \<in> synth (analz H)) = (Hash{|X,Y|} \<in> analz H)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   748
by blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   749
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   750
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   751
subsection{*HPair: a combination of Hash and MPair*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   752
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   753
subsubsection{*Freeness *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   754
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   755
lemma Agent_neq_HPair: "Agent A ~= Hash[X] Y"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   756
by (unfold HPair_def, simp)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   757
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   758
lemma Nonce_neq_HPair: "Nonce N ~= Hash[X] Y"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   759
by (unfold HPair_def, simp)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   760
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   761
lemma Number_neq_HPair: "Number N ~= Hash[X] Y"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   762
by (unfold HPair_def, simp)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   763
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   764
lemma Key_neq_HPair: "Key K ~= Hash[X] Y"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   765
by (unfold HPair_def, simp)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   766
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   767
lemma Hash_neq_HPair: "Hash Z ~= Hash[X] Y"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   768
by (unfold HPair_def, simp)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   769
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   770
lemma Crypt_neq_HPair: "Crypt K X' ~= Hash[X] Y"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   771
by (unfold HPair_def, simp)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   772
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   773
lemmas HPair_neqs = Agent_neq_HPair Nonce_neq_HPair Number_neq_HPair 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   774
                    Key_neq_HPair Hash_neq_HPair Crypt_neq_HPair
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   775
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   776
declare HPair_neqs [iff]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   777
declare HPair_neqs [symmetric, iff]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   778
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   779
lemma HPair_eq [iff]: "(Hash[X'] Y' = Hash[X] Y) = (X' = X & Y'=Y)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   780
by (simp add: HPair_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   781
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   782
lemma MPair_eq_HPair [iff]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   783
     "({|X',Y'|} = Hash[X] Y) = (X' = Hash{|X,Y|} & Y'=Y)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   784
by (simp add: HPair_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   785
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   786
lemma HPair_eq_MPair [iff]:
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   787
     "(Hash[X] Y = {|X',Y'|}) = (X' = Hash{|X,Y|} & Y'=Y)"
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   788
by (auto simp add: HPair_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   789
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   790
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   791
subsubsection{*Specialized laws, proved in terms of those for Hash and MPair *}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   792
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   793
lemma keysFor_insert_HPair [simp]: "keysFor (insert (Hash[X] Y) H) = keysFor H"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   794
by (simp add: HPair_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   795
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   796
lemma parts_insert_HPair [simp]: 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   797
    "parts (insert (Hash[X] Y) H) =  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   798
     insert (Hash[X] Y) (insert (Hash{|X,Y|}) (parts (insert Y H)))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   799
by (simp add: HPair_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   800
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   801
lemma analz_insert_HPair [simp]: 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   802
    "analz (insert (Hash[X] Y) H) =  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   803
     insert (Hash[X] Y) (insert (Hash{|X,Y|}) (analz (insert Y H)))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   804
by (simp add: HPair_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   805
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   806
lemma HPair_synth_analz [simp]:
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   807
     "X \<notin> synth (analz H)  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   808
    ==> (Hash[X] Y \<in> synth (analz H)) =  
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   809
        (Hash {|X, Y|} \<in> analz H & Y \<in> synth (analz H))"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   810
by (simp add: HPair_def)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   811
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   812
16818
paulson
parents: 16796
diff changeset
   813
text{*We do NOT want Crypt... messages broken up in protocols!!*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   814
declare parts.Body [rule del]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   815
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   816
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   817
text{*Rewrites to push in Key and Crypt messages, so that other messages can
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   818
    be pulled out using the @{text analz_insert} rules*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   819
27225
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   820
lemmas pushKeys [standard] =
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   821
  insert_commute [of "Key K" "Agent C"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   822
  insert_commute [of "Key K" "Nonce N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   823
  insert_commute [of "Key K" "Number N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   824
  insert_commute [of "Key K" "Hash X"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   825
  insert_commute [of "Key K" "MPair X Y"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   826
  insert_commute [of "Key K" "Crypt X K'"]
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   827
27225
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   828
lemmas pushCrypts [standard] =
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   829
  insert_commute [of "Crypt X K" "Agent C"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   830
  insert_commute [of "Crypt X K" "Agent C"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   831
  insert_commute [of "Crypt X K" "Nonce N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   832
  insert_commute [of "Crypt X K" "Number N"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   833
  insert_commute [of "Crypt X K" "Hash X'"]
b316dde851f5 eliminated OldGoals.inst;
wenzelm
parents: 27154
diff changeset
   834
  insert_commute [of "Crypt X K" "MPair X' Y"]
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   835
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   836
text{*Cannot be added with @{text "[simp]"} -- messages should not always be
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   837
  re-ordered. *}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   838
lemmas pushes = pushKeys pushCrypts
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   839
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   840
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   841
subsection{*Tactics useful for many protocol proofs*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   842
ML
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   843
{*
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   844
structure Message =
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   845
struct
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   846
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   847
(*Prove base case (subgoal i) and simplify others.  A typical base case
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   848
  concerns  Crypt K X \<notin> Key`shrK`bad  and cannot be proved by rewriting
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   849
  alone.*)
30607
c3d1590debd8 eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents: 30549
diff changeset
   850
fun prove_simple_subgoals_tac (cs, ss) i = 
c3d1590debd8 eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents: 30549
diff changeset
   851
    force_tac (cs, ss addsimps [@{thm image_eq_UN}]) i THEN
c3d1590debd8 eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents: 30549
diff changeset
   852
    ALLGOALS (asm_simp_tac ss)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   853
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   854
(*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
   855
  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
   856
  Abstraction over i is ESSENTIAL: it delays the dereferencing of claset
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   857
  DEPENDS UPON "X" REFERRING TO THE FRADULENT MESSAGE *)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   858
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   859
(*Apply rules to break down assumptions of the form
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   860
  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
   861
*)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   862
val Fake_insert_tac = 
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   863
    dresolve_tac [impOfSubs @{thm Fake_analz_insert},
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   864
                  impOfSubs @{thm Fake_parts_insert}] THEN'
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   865
    eresolve_tac [asm_rl, @{thm synth.Inj}];
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   866
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   867
fun Fake_insert_simp_tac ss i = 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   868
    REPEAT (Fake_insert_tac i) THEN asm_full_simp_tac ss i;
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   869
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   870
fun atomic_spy_analz_tac (cs,ss) = SELECT_GOAL
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   871
    (Fake_insert_simp_tac ss 1
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   872
     THEN
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   873
     IF_UNSOLVED (Blast.depth_tac
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   874
		  (cs addIs [@{thm analz_insertI},
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   875
				   impOfSubs @{thm analz_subset_parts}]) 4 1))
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   876
30607
c3d1590debd8 eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents: 30549
diff changeset
   877
fun spy_analz_tac (cs,ss) i =
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   878
  DETERM
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   879
   (SELECT_GOAL
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   880
     (EVERY 
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   881
      [  (*push in occurrences of X...*)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   882
       (REPEAT o CHANGED)
27239
f2f42f9fa09d pervasive RuleInsts;
wenzelm
parents: 27225
diff changeset
   883
           (res_inst_tac (Simplifier.the_context ss) [(("x", 1), "X")] (insert_commute RS ssubst) 1),
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   884
       (*...allowing further simplifications*)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   885
       simp_tac ss 1,
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   886
       REPEAT (FIRSTGOAL (resolve_tac [allI,impI,notI,conjI,iffI])),
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   887
       DEPTH_SOLVE (atomic_spy_analz_tac (cs,ss) 1)]) i)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   888
24122
fc7f857d33c8 tuned ML bindings (for multithreading);
wenzelm
parents: 23746
diff changeset
   889
end
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   890
*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   891
16818
paulson
parents: 16796
diff changeset
   892
text{*By default only @{text o_apply} is built-in.  But in the presence of
paulson
parents: 16796
diff changeset
   893
eta-expansion this means that some terms displayed as @{term "f o g"} will be
paulson
parents: 16796
diff changeset
   894
rewritten, and others will not!*}
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   895
declare o_def [simp]
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   896
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   897
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   898
lemma Crypt_notin_image_Key [simp]: "Crypt K X \<notin> Key ` A"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   899
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   900
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   901
lemma Hash_notin_image_Key [simp] :"Hash X \<notin> Key ` A"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   902
by auto
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   903
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 14181
diff changeset
   904
lemma synth_analz_mono: "G\<subseteq>H ==> synth (analz(G)) \<subseteq> synth (analz(H))"
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   905
by (iprover intro: synth_mono analz_mono) 
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   906
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   907
lemma Fake_analz_eq [simp]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   908
     "X \<in> synth(analz H) ==> synth (analz (insert X H)) = synth (analz H)"
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   909
apply (drule Fake_analz_insert[of _ _ "H"])
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   910
apply (simp add: synth_increasing[THEN Un_absorb2])
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   911
apply (drule synth_mono)
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   912
apply (simp add: synth_idem)
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   913
apply (rule equalityI)
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   914
apply (simp add: );
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   915
apply (rule synth_analz_mono, blast)   
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   916
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   917
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   918
text{*Two generalizations of @{text analz_insert_eq}*}
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   919
lemma gen_analz_insert_eq [rule_format]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   920
     "X \<in> analz H ==> ALL G. H \<subseteq> G --> analz (insert X G) = analz G";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   921
by (blast intro: analz_cut analz_insertI analz_mono [THEN [2] rev_subsetD])
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   923
lemma synth_analz_insert_eq [rule_format]:
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   924
     "X \<in> synth (analz H) 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   925
      ==> ALL G. H \<subseteq> G --> (Key K \<in> analz (insert X G)) = (Key K \<in> analz G)";
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   926
apply (erule synth.induct) 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   927
apply (simp_all add: gen_analz_insert_eq subset_trans [OF _ subset_insertI]) 
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   928
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   929
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   930
lemma Fake_parts_sing:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13922
diff changeset
   931
     "X \<in> synth (analz H) ==> parts{X} \<subseteq> synth (analz H) \<union> parts H";
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   932
apply (rule subset_trans) 
17689
a04b5b43625e streamlined theory; conformance to recent publication
paulson
parents: 16818
diff changeset
   933
 apply (erule_tac [2] Fake_parts_insert)
20648
paulson
parents: 18492
diff changeset
   934
apply (rule parts_mono, blast)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   935
done
75ae4244a596 Changes required by the certified email protocol
paulson
parents: 11270
diff changeset
   936
14145
2e31b8cc8788 ZhouGollmann: new example (fair non-repudiation protocol)
paulson
parents: 14126
diff changeset
   937
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
   938
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   939
method_setup spy_analz = {*
30607
c3d1590debd8 eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents: 30549
diff changeset
   940
    Scan.succeed (SIMPLE_METHOD' o Message.spy_analz_tac o local_clasimpset_of) *}
11189
1ea763a5d186 conversion of Message.thy to Isar format
paulson
parents: 10833
diff changeset
   941
    "for proving the Fake case when analz is involved"
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   942
11264
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   943
method_setup atomic_spy_analz = {*
30549
d2d7874648bd simplified method setup;
wenzelm
parents: 30510
diff changeset
   944
    Scan.succeed (SIMPLE_METHOD' o Message.atomic_spy_analz_tac o local_clasimpset_of) *}
11264
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   945
    "for debugging spy_analz"
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   946
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   947
method_setup Fake_insert_simp = {*
30549
d2d7874648bd simplified method setup;
wenzelm
parents: 30510
diff changeset
   948
    Scan.succeed (SIMPLE_METHOD' o Message.Fake_insert_simp_tac o local_simpset_of) *}
11264
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   949
    "for debugging spy_analz"
a47a9288f3f6 (rough) conversion of Auth/Recur to Isar format
paulson
parents: 11251
diff changeset
   950
1839
199243afac2b Proving safety properties of authentication protocols
paulson
parents:
diff changeset
   951
end