src/HOL/Auth/Event.thy
author paulson
Thu Sep 23 13:06:31 1999 +0200 (1999-09-23)
changeset 7584 5be4bb8e4e3f
parent 6399 4a9040b85e2e
child 11104 f2024fed9f0c
permissions -rw-r--r--
tidied; added lemma restrict_to_left
paulson@3512
     1
(*  Title:      HOL/Auth/Event
paulson@3512
     2
    ID:         $Id$
paulson@3512
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@3512
     4
    Copyright   1996  University of Cambridge
paulson@3512
     5
paulson@3512
     6
Theory of events for security protocols
paulson@3512
     7
paulson@3683
     8
Datatype of events; function "spies"; freshness
paulson@3678
     9
paulson@3683
    10
"bad" agents have been broken by the Spy; their private keys and internal
paulson@3678
    11
    stores are visible to him
paulson@3512
    12
*)
paulson@3512
    13
paulson@3512
    14
Event = Message + List + 
paulson@3512
    15
paulson@3512
    16
consts  (*Initial states of agents -- parameter of the construction*)
paulson@3519
    17
  initState :: agent => msg set
paulson@3512
    18
paulson@6399
    19
datatype
paulson@3512
    20
  event = Says  agent agent msg
paulson@6399
    21
        | Gets  agent       msg
paulson@3512
    22
        | Notes agent       msg
paulson@6308
    23
       
paulson@6308
    24
consts 
paulson@6308
    25
  bad    :: agent set        (*compromised agents*)
paulson@6308
    26
  knows  :: agent => event list => msg set
paulson@3512
    27
paulson@6308
    28
paulson@6308
    29
(*"spies" is retained for compability's sake*)
paulson@6308
    30
syntax
paulson@3683
    31
  spies  :: event list => msg set
paulson@3519
    32
paulson@6308
    33
translations
paulson@6308
    34
  "spies"   => "knows Spy"
paulson@6308
    35
paulson@6308
    36
paulson@3519
    37
rules
paulson@3519
    38
  (*Spy has access to his own key for spoof messages, but Server is secure*)
paulson@3683
    39
  Spy_in_bad     "Spy: bad"
paulson@3683
    40
  Server_not_bad "Server ~: bad"
paulson@3512
    41
berghofe@5183
    42
primrec
paulson@6308
    43
  knows_Nil   "knows A []         = initState A"
paulson@6399
    44
  knows_Cons
paulson@6399
    45
    "knows A (ev # evs) =
paulson@6399
    46
       (if A = Spy then 
paulson@6399
    47
	(case ev of
paulson@6399
    48
	   Says A' B X => insert X (knows Spy evs)
paulson@6399
    49
	 | Gets A' X => knows Spy evs
paulson@6399
    50
	 | Notes A' X  => 
paulson@6399
    51
	     if A' : bad then insert X (knows Spy evs) else knows Spy evs)
paulson@6399
    52
	else
paulson@6399
    53
	(case ev of
paulson@6399
    54
	   Says A' B X => 
paulson@6399
    55
	     if A'=A then insert X (knows A evs) else knows A evs
paulson@6399
    56
	 | Gets A' X    => 
paulson@6399
    57
	     if A'=A then insert X (knows A evs) else knows A evs
paulson@6399
    58
	 | Notes A' X    => 
paulson@6399
    59
	     if A'=A then insert X (knows A evs) else knows A evs))"
paulson@6308
    60
paulson@6308
    61
(*
paulson@6308
    62
  Case A=Spy on the Gets event
paulson@6308
    63
  enforces the fact that if a message is received then it must have been sent,
paulson@6308
    64
  therefore the oops case must use Notes
paulson@6308
    65
*)
paulson@3678
    66
paulson@3683
    67
consts
paulson@3683
    68
  (*Set of items that might be visible to somebody:
paulson@3683
    69
    complement of the set of fresh items*)
paulson@3683
    70
  used :: event list => msg set
paulson@3512
    71
berghofe@5183
    72
primrec
paulson@3683
    73
  used_Nil   "used []         = (UN B. parts (initState B))"
paulson@3683
    74
  used_Cons  "used (ev # evs) =
paulson@3683
    75
	         (case ev of
paulson@3683
    76
		    Says A B X => parts {X} Un (used evs)
paulson@6399
    77
		  | Gets A X   => used evs
paulson@6399
    78
		  | Notes A X  => parts {X} Un (used evs))"
paulson@6308
    79
paulson@6308
    80
paulson@3512
    81
paulson@3512
    82
end