src/HOL/Auth/Guard/Proto.thy
changeset 20768 1d478c2d621f
parent 16417 9bc16273c2d4
child 21404 eb85850d3eb7
equal deleted inserted replaced
20767:9bc632ae588f 20768:1d478c2d621f
    15 
    15 
    16 subsection{*protocols*}
    16 subsection{*protocols*}
    17 
    17 
    18 types rule = "event set * event"
    18 types rule = "event set * event"
    19 
    19 
    20 syntax msg' :: "rule => msg"
    20 abbreviation
    21 
    21   msg' :: "rule => msg"
    22 translations "msg' R" == "msg (snd R)"
    22   "msg' R == msg (snd R)"
    23 
    23 
    24 types proto = "rule set"
    24 types proto = "rule set"
    25 
    25 
    26 constdefs wdef :: "proto => bool"
    26 constdefs wdef :: "proto => bool"
    27 "wdef p == ALL R k. R:p --> Number k:parts {msg' R}
    27 "wdef p == ALL R k. R:p --> Number k:parts {msg' R}
    74 primrec
    74 primrec
    75 "ap s (Says A B X) = Says (agent s A) (agent s B) (apm s X)"
    75 "ap s (Says A B X) = Says (agent s A) (agent s B) (apm s X)"
    76 "ap s (Gets A X) = Gets (agent s A) (apm s X)"
    76 "ap s (Gets A X) = Gets (agent s A) (apm s X)"
    77 "ap s (Notes A X) = Notes (agent s A) (apm s X)"
    77 "ap s (Notes A X) = Notes (agent s A) (apm s X)"
    78 
    78 
    79 syntax
    79 abbreviation
    80 ap' :: "rule => msg"
    80   ap' :: "subs => rule => event"
    81 apm' :: "rule => msg"
    81   "ap' s R == ap s (snd R)"
    82 priK' :: "subs => agent => key"
    82 
    83 pubK' :: "subs => agent => key"
    83   apm' :: "subs => rule => msg"
    84 
    84   "apm' s R == apm s (msg' R)"
    85 translations
    85 
    86 "ap' s R" == "ap s (snd R)"
    86   priK' :: "subs => agent => key"
    87 "apm' s R" == "apm s (msg' R)"
    87   "priK' s A == priK (agent s A)"
    88 "priK' s A" == "priK (agent s A)"
    88 
    89 "pubK' s A" == "pubK (agent s A)"
    89   pubK' :: "subs => agent => key"
       
    90   "pubK' s A == pubK (agent s A)"
    90 
    91 
    91 subsection{*nonces generated by a rule*}
    92 subsection{*nonces generated by a rule*}
    92 
    93 
    93 constdefs newn :: "rule => nat set"
    94 constdefs newn :: "rule => nat set"
    94 "newn R == {n. Nonce n:parts {msg (snd R)} & Nonce n ~:parts (msg`(fst R))}"
    95 "newn R == {n. Nonce n:parts {msg (snd R)} & Nonce n ~:parts (msg`(fst R))}"
   375 Na :: nat "Na == 0"
   376 Na :: nat "Na == 0"
   376 Nb :: nat "Nb == 1"
   377 Nb :: nat "Nb == 1"
   377 
   378 
   378 consts
   379 consts
   379 ns :: proto
   380 ns :: proto
   380 ns1 :: rule
   381 
   381 ns2 :: rule
   382 abbreviation
   382 ns3 :: rule
   383   ns1 :: rule
   383 
   384   "ns1 == ({}, Says a b (Crypt (pubK b) {|Nonce Na, Agent a|}))"
   384 translations
   385 
   385 "ns1" == "({}, Says a b (Crypt (pubK b) {|Nonce Na, Agent a|}))"
   386   ns2 :: rule
   386 
   387   "ns2 == ({Says a' b (Crypt (pubK b) {|Nonce Na, Agent a|})},
   387 "ns2" == "({Says a' b (Crypt (pubK b) {|Nonce Na, Agent a|})},
   388     Says b a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|}))"
   388 Says b a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|}))"
   389 
   389 
   390   ns3 :: rule
   390 "ns3" == "({Says a b (Crypt (pubK b) {|Nonce Na, Agent a|}),
   391   "ns3 == ({Says a b (Crypt (pubK b) {|Nonce Na, Agent a|}),
   391 Says b' a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|})},
   392     Says b' a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|})},
   392 Says a b (Crypt (pubK b) (Nonce Nb)))"
   393     Says a b (Crypt (pubK b) (Nonce Nb)))"
   393 
   394 
   394 inductive ns intros
   395 inductive ns intros
   395 [iff]: "ns1:ns"
   396 [iff]: "ns1:ns"
   396 [iff]: "ns2:ns"
   397 [iff]: "ns2:ns"
   397 [iff]: "ns3:ns"
   398 [iff]: "ns3:ns"
   398 
   399 
   399 syntax
   400 abbreviation (input)
   400 ns3a :: msg
   401   ns3a :: event
   401 ns3b :: msg
   402   "ns3a == Says a b (Crypt (pubK b) {|Nonce Na, Agent a|})"
   402 
   403 
   403 translations
   404   ns3b :: event
   404 "ns3a" => "Says a b (Crypt (pubK b) {|Nonce Na, Agent a|})"
   405   "ns3b == Says b' a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|})"
   405 "ns3b" => "Says b' a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|})"
       
   406 
   406 
   407 constdefs keys :: "keyfun"
   407 constdefs keys :: "keyfun"
   408 "keys R' s' n evs == {priK' s' a, priK' s' b}"
   408 "keys R' s' n evs == {priK' s' a, priK' s' b}"
   409 
   409 
   410 lemma "monoton ns keys"
   410 lemma "monoton ns keys"