src/HOL/Quickcheck_Benchmark/Needham_Schroeder_No_Attacker_Example.thy
author wenzelm
Wed Apr 10 21:20:35 2013 +0200 (2013-04-10)
changeset 51692 ecd34f863242
parent 48618 1f7e068b4613
permissions -rw-r--r--
tuned pretty layout: avoid nested Pretty.string_of, which merely happens to work with Isabelle/jEdit since formatting is delegated to Scala side;
declare command "print_case_translations" where it is actually defined;
bulwahn@48224
     1
theory Needham_Schroeder_No_Attacker_Example
bulwahn@48618
     2
imports Needham_Schroeder_Base
bulwahn@48224
     3
begin
bulwahn@48224
     4
bulwahn@48224
     5
inductive_set ns_public :: "event list set"
bulwahn@48224
     6
  where
bulwahn@48224
     7
         (*Initial trace is empty*)
bulwahn@48224
     8
   Nil:  "[] \<in> ns_public"
bulwahn@48224
     9
         (*Alice initiates a protocol run, sending a nonce to Bob*)
bulwahn@48224
    10
 | NS1:  "\<lbrakk>evs1 \<in> ns_public;  Nonce NA \<notin> used evs1\<rbrakk>
bulwahn@48224
    11
          \<Longrightarrow> Says A B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>)
bulwahn@48224
    12
                # evs1  \<in>  ns_public"
bulwahn@48224
    13
         (*Bob responds to Alice's message with a further nonce*)
bulwahn@48224
    14
 | NS2:  "\<lbrakk>evs2 \<in> ns_public;  Nonce NB \<notin> used evs2;
bulwahn@48224
    15
           Says A' B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs2\<rbrakk>
bulwahn@48224
    16
          \<Longrightarrow> Says B A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB\<rbrace>)
bulwahn@48224
    17
                # evs2  \<in>  ns_public"
bulwahn@48224
    18
bulwahn@48224
    19
         (*Alice proves her existence by sending NB back to Bob.*)
bulwahn@48224
    20
 | NS3:  "\<lbrakk>evs3 \<in> ns_public;
bulwahn@48224
    21
           Says A  B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs3;
bulwahn@48224
    22
           Says B' A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB\<rbrace>) \<in> set evs3\<rbrakk>
bulwahn@48224
    23
          \<Longrightarrow> Says A B (Crypt (pubEK B) (Nonce NB)) # evs3 \<in> ns_public"
bulwahn@48224
    24
bulwahn@48224
    25
code_pred [skip_proof] ns_publicp .
bulwahn@48224
    26
thm ns_publicp.equation
bulwahn@48224
    27
bulwahn@48224
    28
code_pred [generator_cps] ns_publicp .
bulwahn@48224
    29
thm ns_publicp.generator_cps_equation
bulwahn@48224
    30
bulwahn@48224
    31
lemma "ns_publicp evs ==> \<not> (Says Alice Bob (Crypt (pubEK Bob) (Nonce NB))) : set evs"
bulwahn@48224
    32
(*quickcheck[random, iterations = 1000000, size = 20, timeout = 3600, verbose]
bulwahn@48224
    33
quickcheck[exhaustive, size = 8, timeout = 3600, verbose]
bulwahn@48224
    34
quickcheck[narrowing, size = 7, timeout = 3600, verbose]*)
bulwahn@48224
    35
quickcheck[smart_exhaustive, depth = 5, timeout = 30, expect = counterexample]
bulwahn@48224
    36
oops
bulwahn@48224
    37
bulwahn@48224
    38
lemma
bulwahn@48224
    39
  "\<lbrakk>ns_publicp evs\<rbrakk>            
bulwahn@48224
    40
       \<Longrightarrow> Says B A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB\<rbrace>) : set evs
bulwahn@48224
    41
       \<Longrightarrow> A \<noteq> Spy \<Longrightarrow> B \<noteq> Spy \<Longrightarrow> A \<noteq> B 
bulwahn@48224
    42
           \<Longrightarrow> Nonce NB \<notin> analz (spies evs)"
bulwahn@48224
    43
quickcheck[smart_exhaustive, depth = 6, timeout = 30]
bulwahn@48224
    44
quickcheck[narrowing, size = 6, timeout = 30, verbose]
bulwahn@48224
    45
oops
bulwahn@48224
    46
bulwahn@48618
    47
end