Analyzing security protocols with secrecy types and logic programs