src/HOL/Quickcheck_Benchmark/Needham_Schroeder_Base.thy
changeset 61984 cdea44c775fa
parent 61952 546958347e05
equal deleted inserted replaced
61983:8fb53badad99 61984:cdea44c775fa
    25          | Nonce  nat
    25          | Nonce  nat
    26          | MPair  msg msg
    26          | MPair  msg msg
    27          | Crypt  key msg
    27          | Crypt  key msg
    28 
    28 
    29 syntax
    29 syntax
    30   "_MTuple"      :: "['a, args] => 'a * 'b"       ("(2{|_,/ _|})")
       
    31 
       
    32 syntax (xsymbols)
       
    33   "_MTuple"      :: "['a, args] => 'a * 'b"       ("(2\<lbrace>_,/ _\<rbrace>)")
    30   "_MTuple"      :: "['a, args] => 'a * 'b"       ("(2\<lbrace>_,/ _\<rbrace>)")
    34 
       
    35 translations
    31 translations
    36   "{|x, y, z|}"   == "{|x, {|y, z|}|}"
    32   "\<lbrace>x, y, z\<rbrace>"   == "\<lbrace>x, \<lbrace>y, z\<rbrace>\<rbrace>"
    37   "{|x, y|}"      == "CONST MPair x y"
    33   "\<lbrace>x, y\<rbrace>"      == "CONST MPair x y"
    38 
    34 
    39 inductive_set
    35 inductive_set
    40   parts :: "msg set => msg set"
    36   parts :: "msg set => msg set"
    41   for H :: "msg set"
    37   for H :: "msg set"
    42   where
    38   where
    43     Inj [intro]:               "X \<in> H ==> X \<in> parts H"
    39     Inj [intro]:               "X \<in> H ==> X \<in> parts H"
    44   | Fst:         "{|X,Y|}   \<in> parts H ==> X \<in> parts H"
    40   | Fst:         "\<lbrace>X,Y\<rbrace>   \<in> parts H ==> X \<in> parts H"
    45   | Snd:         "{|X,Y|}   \<in> parts H ==> Y \<in> parts H"
    41   | Snd:         "\<lbrace>X,Y\<rbrace>   \<in> parts H ==> Y \<in> parts H"
    46   | Body:        "Crypt K X \<in> parts H ==> X \<in> parts H"
    42   | Body:        "Crypt K X \<in> parts H ==> X \<in> parts H"
    47 
    43 
    48 inductive_set
    44 inductive_set
    49   analz :: "msg set => msg set"
    45   analz :: "msg set => msg set"
    50   for H :: "msg set"
    46   for H :: "msg set"
    51   where
    47   where
    52     Inj [intro,simp] :    "X \<in> H ==> X \<in> analz H"
    48     Inj [intro,simp] :    "X \<in> H ==> X \<in> analz H"
    53   | Fst:     "{|X,Y|} \<in> analz H ==> X \<in> analz H"
    49   | Fst:     "\<lbrace>X,Y\<rbrace> \<in> analz H ==> X \<in> analz H"
    54   | Snd:     "{|X,Y|} \<in> analz H ==> Y \<in> analz H"
    50   | Snd:     "\<lbrace>X,Y\<rbrace> \<in> analz H ==> Y \<in> analz H"
    55   | Decrypt [dest]: 
    51   | Decrypt [dest]: 
    56              "[|Crypt K X \<in> analz H; Key(invKey K): analz H|] ==> X \<in> analz H"
    52              "[|Crypt K X \<in> analz H; Key(invKey K): analz H|] ==> X \<in> analz H"
    57 
    53 
    58 inductive_set
    54 inductive_set
    59   synth :: "msg set => msg set"
    55   synth :: "msg set => msg set"
    60   for H :: "msg set"
    56   for H :: "msg set"
    61   where
    57   where
    62     Inj    [intro]:   "X \<in> H ==> X \<in> synth H"
    58     Inj    [intro]:   "X \<in> H ==> X \<in> synth H"
    63   | Agent  [intro]:   "Agent agt \<in> synth H"
    59   | Agent  [intro]:   "Agent agt \<in> synth H"
    64   | MPair  [intro]:   "[|X \<in> synth H;  Y \<in> synth H|] ==> {|X,Y|} \<in> synth H"
    60   | MPair  [intro]:   "[|X \<in> synth H;  Y \<in> synth H|] ==> \<lbrace>X,Y\<rbrace> \<in> synth H"
    65   | Crypt  [intro]:   "[|X \<in> synth H;  Key(K) \<in> H|] ==> Crypt K X \<in> synth H"
    61   | Crypt  [intro]:   "[|X \<in> synth H;  Key(K) \<in> H|] ==> Crypt K X \<in> synth H"
    66 
    62 
    67 primrec initState
    63 primrec initState
    68 where
    64 where
    69   initState_Alice:
    65   initState_Alice:
   170 
   166 
   171 subsection {* Derived equations for analz, parts and synth *}
   167 subsection {* Derived equations for analz, parts and synth *}
   172 
   168 
   173 lemma [code]:
   169 lemma [code]:
   174   "analz H = (let
   170   "analz H = (let
   175      H' = H \<union> (\<Union>((%m. case m of {|X, Y|} => {X, Y} | Crypt K X => if Key (invKey K) : H then {X} else {} | _ => {}) ` H))
   171      H' = H \<union> (\<Union>((%m. case m of \<lbrace>X, Y\<rbrace> => {X, Y} | Crypt K X => if Key (invKey K) : H then {X} else {} | _ => {}) ` H))
   176    in if H' = H then H else analz H')"
   172    in if H' = H then H else analz H')"
   177 sorry
   173 sorry
   178 
   174 
   179 lemma [code]:
   175 lemma [code]:
   180   "parts H = (let
   176   "parts H = (let
   181      H' = H \<union> (\<Union>((%m. case m of {|X, Y|} => {X, Y} | Crypt K X => {X} | _ => {}) ` H))
   177      H' = H \<union> (\<Union>((%m. case m of \<lbrace>X, Y\<rbrace> => {X, Y} | Crypt K X => {X} | _ => {}) ` H))
   182    in if H' = H then H else parts H')"
   178    in if H' = H then H else parts H')"
   183 sorry
   179 sorry
   184 
   180 
   185 definition synth' :: "msg set => msg => bool"
   181 definition synth' :: "msg set => msg => bool"
   186 where
   182 where