src/HOL/Auth/Event.ML
author paulson
Wed, 13 Jan 1999 12:08:18 +0100
changeset 6113 b321f5aaa5f4
parent 5223 4cb05273f764
child 6308 76f3865a2b1d
permissions -rw-r--r--
generalized qed_spec_mp code to work for ZF
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
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    11
AddIffs [Spy_in_bad, Server_not_bad];
3512
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
(**** Function "spies" ****)
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
(** Simplifying   parts (insert X (spies evs))
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    16
      = parts {X} Un parts (spies evs) -- since general case loops*)
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    17
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    18
bind_thm ("parts_insert_spies",
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    19
	  parts_insert |> 
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    20
	  read_instantiate_sg (sign_of thy) [("H", "spies evs")]);
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    21
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    22
5114
c729d4c299c1 Deleted leading parameters thanks to new Goal command
paulson
parents: 5076
diff changeset
    23
Goal "P(event_case sf nf ev) = \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    24
\      ((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
    25
\       (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
    26
by (induct_tac "ev" 1);
4477
b3e5857d8d99 New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents: 4266
diff changeset
    27
by Auto_tac;
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    28
qed "expand_event_case";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    29
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    30
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
    31
by (Simp_tac 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    32
qed "spies_Says";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    33
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    34
(*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
    35
  redundant case-splits on whether A=Spy and whether A:bad*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    36
Goal "spies (Notes A X # evs) = \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    37
\         (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
    38
by (Simp_tac 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    39
qed "spies_Notes";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    40
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    41
Goal "spies evs <= spies (Says A B X # evs)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    42
by (simp_tac (simpset() addsimps [subset_insertI]) 1);
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    43
qed "spies_subset_spies_Says";
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    44
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    45
Goal "spies evs <= spies (Notes A X # evs)";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    46
by (Simp_tac 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    47
by (Fast_tac 1);
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    48
qed "spies_subset_spies_Notes";
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    49
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    50
(*Spy sees all traffic*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    51
Goal "Says A B X : set evs --> X : spies evs";
3667
42a726e008ce Now uses the generic induct_tac
paulson
parents: 3519
diff changeset
    52
by (induct_tac "evs" 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    53
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
    54
qed_spec_mp "Says_imp_spies";
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    55
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    56
(*Spy sees Notes of bad agents*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    57
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
    58
by (induct_tac "evs" 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    59
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
    60
qed_spec_mp "Notes_imp_spies";
3678
414e04d7c2d6 Spy can see Notes of the compromised agents
paulson
parents: 3667
diff changeset
    61
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    62
(*Use with addSEs to derive contradictions from old Says events containing
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    63
  items known to be fresh*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    64
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
    65
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    66
Addsimps [spies_Says, spies_Notes];
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
(**** 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
    69
Delsimps [spies_Cons];   
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    70
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    71
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    72
(*** Fresh nonces ***)
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    73
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    74
Goal "parts (spies evs) <= used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    75
by (induct_tac "evs" 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    76
by (ALLGOALS (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    77
	      (simpset() addsimps [parts_insert_spies]
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    78
	                addsplits [expand_event_case])));
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    79
by (ALLGOALS Blast_tac);
3701
6f0ed3eef1a9 Names and saves the theorem parts_spies_subset_used
paulson
parents: 3683
diff changeset
    80
qed "parts_spies_subset_used";
6f0ed3eef1a9 Names and saves the theorem parts_spies_subset_used
paulson
parents: 3683
diff changeset
    81
6f0ed3eef1a9 Names and saves the theorem parts_spies_subset_used
paulson
parents: 3683
diff changeset
    82
bind_thm ("usedI", impOfSubs parts_spies_subset_used);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    83
AddIs [usedI];
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    84
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    85
Goal "parts (initState B) <= used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    86
by (induct_tac "evs" 1);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    87
by (ALLGOALS (asm_simp_tac
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    88
	      (simpset() addsimps [parts_insert_spies]
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4477
diff changeset
    89
	                addsplits [expand_event_case])));
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    90
by (ALLGOALS Blast_tac);
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    91
bind_thm ("initState_into_used", impOfSubs (result()));
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
    92
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    93
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
    94
by (Simp_tac 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    95
qed "used_Says";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    96
Addsimps [used_Says];
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
    97
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
    98
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
    99
by (Simp_tac 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   100
qed "used_Notes";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   101
Addsimps [used_Notes];
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   102
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
   103
Goal "used [] <= used evs";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   104
by (Simp_tac 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   105
by (blast_tac (claset() addIs [initState_into_used]) 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   106
qed "used_nil_subset";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   107
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   108
(**** 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
   109
Delsimps [used_Nil, used_Cons];   
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   110
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   111
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   112
(*currently unused*)
5076
fbc9d95b62ba Ran isatool fixgoal
paulson
parents: 4686
diff changeset
   113
Goal "used evs <= used (evs@evs')";
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   114
by (induct_tac "evs" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   115
by (simp_tac (simpset() addsimps [used_nil_subset]) 1);
3667
42a726e008ce Now uses the generic induct_tac
paulson
parents: 3519
diff changeset
   116
by (induct_tac "a" 1);
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   117
by (ALLGOALS Asm_simp_tac);
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   118
by (ALLGOALS Blast_tac);
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   119
qed "used_subset_append";
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   120
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   121
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   122
(*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
   123
  New events added by induction to "evs" are discarded.  Provided 
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   124
  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
   125
  it will omit complicated reasoning about analz.*)
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   126
val analz_mono_contra_tac = 
4266
dab1833cb26d analz_mono_contra_tac was wrong
paulson
parents: 4091
diff changeset
   127
  let val analz_impI = read_instantiate_sg (sign_of thy)
dab1833cb26d analz_mono_contra_tac was wrong
paulson
parents: 4091
diff changeset
   128
                [("P", "?Y ~: analz (spies ?evs)")] impI;
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   129
  in
4266
dab1833cb26d analz_mono_contra_tac was wrong
paulson
parents: 4091
diff changeset
   130
    rtac analz_impI THEN' 
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   131
    REPEAT1 o 
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   132
      (dresolve_tac 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   133
       [spies_subset_spies_Says  RS analz_mono RS contra_subsetD,
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3678
diff changeset
   134
	spies_subset_spies_Notes RS analz_mono RS contra_subsetD])
3512
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   135
    THEN'
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   136
    mp_tac
9dcb4daa15e8 Moving common declarations and proofs from theories "Shared"
paulson
parents:
diff changeset
   137
  end;