src/HOL/Auth/Event.ML
author paulson
Thu, 02 Jul 1998 17:48:11 +0200
changeset 5114 c729d4c299c1
parent 5076 fbc9d95b62ba
child 5223 4cb05273f764
permissions -rw-r--r--
Deleted leading parameters thanks to new Goal command
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/Event
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     2
    ID:         $Id$
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     5
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     6
Theory of events for security protocols
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     7
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     8
Datatype of events; function "sees"; freshness
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
     9
*)
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    10
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    11
open Event;
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    12
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    13
AddIffs [Spy_in_bad, Server_not_bad];
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    14
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    15
(**** Function "spies" ****)
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    16
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    17
(** Simplifying   parts (insert X (spies evs))
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    18
      = parts {X} Un parts (spies evs) -- since general case loops*)
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    19
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    20
bind_thm ("parts_insert_spies",
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    21
	  parts_insert |> 
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    22
	  read_instantiate_sg (sign_of thy) [("H", "spies evs")]);
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    23
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    24
5114
c729d4c299c1 Deleted leading parameters thanks to new Goal command
paulson
parents: 5076
diff changeset
    25
Goal "P(event_case sf nf ev) = \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    26
\      ((ALL A B X. ev = Says A B X --> P(sf A B X)) & \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    27
\       (ALL A X. ev = Notes A X --> P(nf A X)))";
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    28
by (induct_tac "ev" 1);
4477
b3e5857d8d99 New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents: 4266
diff changeset
    29
by Auto_tac;
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    30
qed "expand_event_case";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    31
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    32
Goal "spies (Says A B X # evs) = insert X (spies evs)";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    33
by (Simp_tac 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    34
qed "spies_Says";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    35
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    36
(*The point of letting the Spy see "bad" agents' notes is to prevent
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    37
  redundant case-splits on whether A=Spy and whether A:bad*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    38
Goal "spies (Notes A X # evs) = \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    39
\         (if A:bad then insert X (spies evs) else spies evs)";
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    40
by (Simp_tac 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    41
qed "spies_Notes";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    42
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    43
Goal "spies evs <= spies (Says A B X # evs)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    44
by (simp_tac (simpset() addsimps [subset_insertI]) 1);
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    45
qed "spies_subset_spies_Says";
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    46
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    47
Goal "spies evs <= spies (Notes A X # evs)";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    48
by (Simp_tac 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    49
by (Fast_tac 1);
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    50
qed "spies_subset_spies_Notes";
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    51
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    52
(*Spy sees all traffic*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    53
Goal "Says A B X : set evs --> X : spies evs";
3667
42a726e008ce Now uses the generic induct_tac
paulson
parents: 3519
diff changeset
    54
by (induct_tac "evs" 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    55
by (ALLGOALS (asm_simp_tac (simpset() addsplits [expand_event_case])));
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    56
qed_spec_mp "Says_imp_spies";
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    57
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    58
(*Spy sees Notes of bad agents*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    59
Goal "Notes A X : set evs --> A: bad --> X : spies evs";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    60
by (induct_tac "evs" 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    61
by (ALLGOALS (asm_simp_tac (simpset() addsplits [expand_event_case])));
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    62
qed_spec_mp "Notes_imp_spies";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    63
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    64
(*Use with addSEs to derive contradictions from old Says events containing
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    65
  items known to be fresh*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    66
val spies_partsEs = make_elim (Says_imp_spies RS parts.Inj) :: partsEs;
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    67
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    68
Addsimps [spies_Says, spies_Notes];
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    69
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    70
(**** NOTE REMOVAL--laws above are cleaner, as they don't involve "case" ****)
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    71
Delsimps [spies_Cons];   
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    72
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    73
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    74
(*** Fresh nonces ***)
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    75
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    76
Goal "parts (spies evs) <= used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    77
by (induct_tac "evs" 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    78
by (ALLGOALS (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    79
	      (simpset() addsimps [parts_insert_spies]
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    80
	                addsplits [expand_event_case])));
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    81
by (ALLGOALS Blast_tac);
3701
6f0ed3eef1a9 Names and saves the theorem parts_spies_subset_used
paulson
parents: 3683
diff changeset
    82
qed "parts_spies_subset_used";
6f0ed3eef1a9 Names and saves the theorem parts_spies_subset_used
paulson
parents: 3683
diff changeset
    83
6f0ed3eef1a9 Names and saves the theorem parts_spies_subset_used
paulson
parents: 3683
diff changeset
    84
bind_thm ("usedI", impOfSubs parts_spies_subset_used);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    85
AddIs [usedI];
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    86
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    87
Goal "parts (initState B) <= used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    88
by (induct_tac "evs" 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    89
by (ALLGOALS (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    90
	      (simpset() addsimps [parts_insert_spies]
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    91
	                addsplits [expand_event_case])));
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    92
by (ALLGOALS Blast_tac);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    93
bind_thm ("initState_into_used", impOfSubs (result()));
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    94
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    95
Goal "used (Says A B X # evs) = parts{X} Un used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    96
by (Simp_tac 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    97
qed "used_Says";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    98
Addsimps [used_Says];
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    99
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
   100
Goal "used (Notes A X # evs) = parts{X} Un used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   101
by (Simp_tac 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   102
qed "used_Notes";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   103
Addsimps [used_Notes];
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   104
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
   105
Goal "used [] <= used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   106
by (Simp_tac 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   107
by (blast_tac (claset() addIs [initState_into_used]) 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   108
qed "used_nil_subset";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   109
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   110
(**** NOTE REMOVAL--laws above are cleaner, as they don't involve "case" ****)
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   111
Delsimps [used_Nil, used_Cons];   
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   112
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   113
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   114
(*currently unused*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
   115
Goal "used evs <= used (evs@evs')";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   116
by (induct_tac "evs" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   117
by (simp_tac (simpset() addsimps [used_nil_subset]) 1);
3667
42a726e008ce Now uses the generic induct_tac
paulson
parents: 3519
diff changeset
   118
by (induct_tac "a" 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   119
by (ALLGOALS Asm_simp_tac);
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   120
by (ALLGOALS Blast_tac);
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   121
qed "used_subset_append";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   122
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   123
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   124
(*For proving theorems of the form X ~: analz (spies evs) --> P
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   125
  New events added by induction to "evs" are discarded.  Provided 
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   126
  this information isn't needed, the proof will be much shorter, since
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   127
  it will omit complicated reasoning about analz.*)
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   128
val analz_mono_contra_tac = 
4266
dab1833cb26d analz_mono_contra_tac was wrong
paulson
parents: 4091
diff changeset
   129
  let val analz_impI = read_instantiate_sg (sign_of thy)
dab1833cb26d analz_mono_contra_tac was wrong
paulson
parents: 4091
diff changeset
   130
                [("P", "?Y ~: analz (spies ?evs)")] impI;
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   131
  in
4266
dab1833cb26d analz_mono_contra_tac was wrong
paulson
parents: 4091
diff changeset
   132
    rtac analz_impI THEN' 
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   133
    REPEAT1 o 
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   134
      (dresolve_tac 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   135
       [spies_subset_spies_Says  RS analz_mono RS contra_subsetD,
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   136
	spies_subset_spies_Notes RS analz_mono RS contra_subsetD])
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   137
    THEN'
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   138
    mp_tac
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   139
  end;