Steve Kremer

Robert Künnemann

Automated analysis of security protocols with global state (Full version)

Security APIs, key servers and protocols that need to keep the status of transactions, require to maintain a global, non-monotonic state, e.g., in the form of a database or register. However, most existing automated verification tools do not support the analysis of such stateful security protocols -sometimes because of fundamental reasons, such as the encoding of the protocol as Horn clauses, which are inherently monotonic. A notable exception is the recent tamarin prover which allows specifying protocols as multiset rewrite (msr) rules, a formalism expressive enough to encode state. As multiset rewriting is a "low-level" specification language with no direct support for concurrent message passing, encoding protocols correctly is a difficult and error-prone process.

We propose a process calculus which is a variant of the applied pi calculus with constructs for manipulation of a global state by processes running in parallel. We show that this language can be translated to msr rules whilst preserving all security properties expressible in a dedicated first-order logic for security properties. The translation has been implemented in a prototype tool which uses the tamarin prover as a backend. We apply the tool to several case studies among which a simplified fragment of PKCS#11, the Yubikey security token, and an optimistic contract signing protocol.

Introduction

Automated analysis of security protocols has been extremely successful. Using automated tools, flaws have been for instance discovered in the Google Single Sign On Protocol [START_REF] Armando | Formal analysis of saml 2.0 web browser single sign-on: Breaking the saml-based single sign-on for google apps[END_REF], in commercial security tokens implementing the PKCS#11 standard [START_REF] Bortolozzo | Attacking and fixing PKCS#11 security tokens[END_REF], and one may also recall Lowe's attack [START_REF] Lowe | Breaking and fixing the Needham-Schroeder public-key protocol using FDR[END_REF] on the Needham-Schroeder public key protocol 17 years after its publication. While efficient tools such as ProVerif [START_REF] Blanchet | An Efficient Cryptographic Protocol Verifier Based on Prolog Rules[END_REF], AVISPA [START_REF] Armando | The AVISPA tool for the automated validation of internet security protocols and applications[END_REF] or Maude-NPA [START_REF] Escobar | Maude-npa: Cryptographic protocol analysis modulo equational properties[END_REF] exist, these tools fail to analyze protocols that require non-monotonic global state, i.e., some database, register or memory location that can be read and altered by different parallel threads. In particular ProVerif, one of the most efficient and widely used protocol analysis tools, relies on an abstraction that encodes protocols in first-order Horn clauses. This abstraction is well suited for the monotonic knowledge of an attacker (who never forgets), makes the tool extremely efficient for verifying an unbounded number of protocol sessions and allows to build on existing techniques for Horn clause resolution. However, Horn clauses are inherently monotonic: once a fact is true it cannot be set to false anymore. As a result, even though ProVerif's input language, a variant of the applied pi calculus [START_REF] Abadi | Mobile values, new names, and secure communication[END_REF], allows a priori encodings of a global memory, the abstractions performed by ProVerif introduce false attacks. In the ProVerif user manual [START_REF] Blanchet | ProVerif 1.88: Automatic Cryptographic Protocol Verifier, User Manual and Tutorial[END_REF]Section 6.3.3] such an encoding of memory cells and its limitations are indeed explicitly discussed: "Due to the abstractions performed by ProVerif, such a cell is treated in an approximate way: all values written in the cell are considered as a set, and when one reads the cell, ProVerif just guarantees that the obtained value is one of the written values (not necessarily the last one, and not necessarily one written before the read)." Some work [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF][START_REF] Mödersheim | Abstraction by set-membership: verifying security protocols and web services with databases[END_REF][START_REF] Delaune | Formal analysis of protocols based on TPM state registers[END_REF] has nevertheless used ingenious encodings of mutable state in Horn clauses, but these encodings have limitations that we discuss below.

A prominent example where non-monotonic global state appears are security APIs, such as the RSA PKCS#11 standard [START_REF]PKCS #11: Cryptographic Token Interface Standard[END_REF], IBM's CCA [11] or the trusted platform module (TPM) [START_REF]TPM Specification version 1.2. Parts 1-3[END_REF]. They have been known to be vulnerable to logical attacks for some time [START_REF] Longley | An automatic search for security flaws in key management schemes[END_REF][START_REF] Bond | API level attacks on embedded systems[END_REF] and formal analysis has shown to be a valuable tool to identify attacks and find secure configurations. One promising paradigm for analyzing security APIs is to regard them as a participant in a protocol and use existing analysis tools. However, Herzog [START_REF] Herzog | Applying protocol analysis to security device interfaces[END_REF] already identified not accounting for mutable global state as a major barrier to the application of security protocol analysis tools to verify security APIs. Apart from security APIs many other protocols need to maintain databases: key servers need to store the status of keys, in optimistic contract signing protocols a trusted party maintains the status of a contract, RFID protocols maintain the status of tags and more generally websites may need to store the current status of transactions.

Our contributions We propose a tool for analyzing protocols that may involve non-monotonic global state, relying on Schmidt et al.'s tamarin tool [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF][START_REF] Schmidt | The tamarin prover for the symbolic analysis of security protocols[END_REF] as a backend. We designed a new process calculus that extends the applied pi calculus by defining, in addition to the usual constructs for specifying concurrent processes, constructs for explicitly manipulating global state. This calculus serves as the tool's input language. The heart of our tool is a translation from this extended applied pi calculus to a set of multiset rewrite rules that can then be analyzed by tamarin which we use as a backend. We prove the correctness of this translation and show that it preserves all properties expressible in a dedicated first order logic for expressing security properties. As a result, relying on the tamarin prover, we can analyze protocols without bounding the number of sessions, nor making any abstractions. Moreover it allows to model a wide range of cryptographic primitives by the means of equational theories. As the underlying verification problem is undecidable, tamarin may not terminate. However, it offers an interactive mode with a GUI which allows to manually guide the tool in its proof. Our specification language includes support for private channels, global state and locking mechanisms (which are crucial to write meaningful programs in which concurrent threads manipulate a common memory). The translation has been carefully engineered in order to favor termination by tamarin. We illustrate the tool on several case studies: a simple security API in the style of PKCS#11, a complex case study of the Yubikey security device, as well as several examples analyzed by other tools that aim at analyzing stateful protocols. In all of these case studies we were able to avoid restrictions that were necessary in previous works.

Related work

The most closely related work is the StatVerif tool by Arapinis et al. [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF]. They propose an extension of the applied pi calculus, similar to ours, which is translated to Horn clauses and analyzed by the ProVerif tool. Their translation is sound but allows for false attacks, limiting the scope of protocols that can be analyzed. Moreover, StatVerif can only handle a finite number of memory cells: when analyzing an optimistic contract signing protocol this appeared to be a limitation and only the status of a single contract was modeled, providing a manual proof to justify the correctness of this abstraction. Finally, StatVerif is limited to the verification of secrecy properties. As illustrated by the Yubikey case study, our work is more general and we are able to analyze complex injective correspondance properties.

Mödersheim [START_REF] Mödersheim | Abstraction by set-membership: verifying security protocols and web services with databases[END_REF] proposed a language with support for sets together with an abstraction where all objects that belong to the same sets are identified. His language, which is an extension of the low level AVISPA intermediate format, is compiled into Horn clauses that are then analyzed, e. g., using ProVerif. His approach is tightly linked to this particular abstraction limiting the scope of applicability. Mödersheim also discusses the need for a more high-level specification level which we provide in this work.

There has also been work tailored to particular applications. In [START_REF] Delaune | Formal analysis of PKCS#11 and proprietary extensions[END_REF], Delaune et al. show by a dedicated hand proof that for analyzing PKCS#11 one may bound the message size. Their analysis still requires to artificially bound the number of keys. Similarly in spirit, Delaune et al. [START_REF] Delaune | Formal analysis of protocols based on TPM state registers[END_REF] give a dedicated result for analyzing protocols based on the TPM and its registers. However, the number of reboots (which reinitialize registers) needs to be limited.

Guttman [START_REF] Guttman | State and progress in strand spaces: Proving fair exchange[END_REF] also extended the strand space model by adding support for state. While the protocol execution is modeled using the classical strand spaces model, state is modeled by a multiset of facts, and manipulated by multiset rewrite rules. The extended model has been used for analyzing by hand an optimistic contract signing protocol. As of now, protocol analysis in the strand space model with state has not been mechanized yet.

In the goal of relating different approaches for protocol analysis Bistarelli et al. [START_REF] Bistarelli | Relating multiset rewriting and process algebras for security protocol analysis[END_REF] also proposed a translation from a process algebra to multiset rewriting: they do however not consider private channels, have no support for global state and assume that processes have a particular structure. These limitations significantly simplify the translation and its correctness proof. Moreover their work does not include any tool support for automated verification.

Obviously any protocol that we are able to analyze can be directly analyzed by the tamarin prover [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF][START_REF] Schmidt | The tamarin prover for the symbolic analysis of security protocols[END_REF] as the rules produced by our translation could have been given directly as an input to tamarin. Indeed, tamarin has already been used for analyzing a model of the Yubikey device [START_REF] Künnemann | YubiSecure? Formal security analysis results for the Yubikey and YubiHSM[END_REF], the case studies presented with Mödersheim's abstraction, as well as those presented with StatVerif. It is furthermore able to reproduce the aforementioned results on PKCS#11 [START_REF] Delaune | Formal analysis of PKCS#11 and proprietary extensions[END_REF] and the TPM [START_REF] Delaune | Formal analysis of protocols based on TPM state registers[END_REF] moreover, it does so without bounding the number of keys, security devices, reboots, etc. Contrary to ProVerif, tamarin sometimes requires additional typing lemmas which are used to guide the proof. These lemmas need to be written by hand (but are proved automatically). In our case studies we also needed to provide a few such lemmas manually. In our opinion, an important disadvantage of tamarin is that protocols are modeled as a set of multiset rewrite rules. This representations is very low level and far away from actual protocol implementations, making it very difficult to model a protocol adequately. Encoding private channels, nested replications and locking mechanisms directly as multiset rewrite rules is a tricky and error prone task. As a result we observed that, in practice, the protocol models tend to be simplified. For instance, locking mechanisms are often omitted, modeling protocol steps as a single rule and making them effectively atomic. Such more abstract models may obscure issues in concurrent protocol steps and increase the risk of implicitly excluding attacks in the model that are well possible in a real implementation, e. g., race conditions. Using a more high-level specification language, such as our process calculus, arguably eases protocol specification and overcomes some of these risks.

Preliminaries

Terms and equational theories As usual in symbolic protocol analysis we model messages by abstract terms. Therefore we define an order-sorted term algebra with the sort msg and two incomparable subsorts pub and fresh. For each of these subsorts we assume a countably infinite set of names, FN for fresh names and PN for public names. Fresh names will be used to model cryptographic keys and nonces while public names model publicly known values. We furthermore assume a countably infinite set of variables for each sort s, V s and let V be the union of the set of variables for all sorts. We write u : s when the name or variable u is of sort s. Let Σ be a signature, i.e., a set of function symbols, each with an arity. We write f /n when function symbol f is of arity n. We denote by T Σ the set of well-sorted terms built over Σ, PN , FN and V. For a term t we denote by names(t), respectively vars(t) the set of names, respectively variables, appearing in t. The set of ground terms, i.e., terms without variables, is denoted by M Σ . When Σ is fixed or clear from the context we often omit it and simply write T for T Σ and M for M Σ .

We equip the term algebra with an equational theory E, that is a finite set of equations of the form M = N where M, N ∈ T . From the equational theory we define the binary relation = E on terms, which is the smallest equivalence relation containing equations in E that is closed under application of function symbols, bijective renaming of names and substitution of variables by terms of the same sort. Furthermore, we require E to distinguish different fresh names, i. e., ∀a, b ∈ FN : a = b ⇒ a = E b.

Example. Symmetric encryption can be modelled using a signature Σ = { senc/2, sdec/2, encCor /2, true/0 } and an equational theory defined by sdec(senc(m, k), k) = m encCor (senc(x, y), y) = true

The last equation allows to check whether a term can be correctly decrypted with a certain key.

For the rest of the paper we assume that E refers to some fixed equational theory and that the signature and equational theory always contain symbols and equations for pairing and projection, i.e., { ., . , fst, snd} ⊆ Σ and equations fst( x, y ) = x and snd( x, y ) = y are in E. We will sometimes use x 1 , x 2 , . . . , x n as a shortcut for x 1 , x 2 , . . . , x n-1 , x n . . . . We also use the usual notion of positions for terms. A position p is a sequence of positive integers and t| p denotes the subterm of t at position p.

Facts We also assume an unsorted signature Σ fact , disjoint from Σ. The set of facts is defined as

F := {F (t 1 , . . . , t k ) | t i ∈ T Σ , F ∈ Σ fact of arity k}.
Facts will be used both to annotate protocols, by the means of events, and for defining multiset rewrite rules. We partition the signature Σ fact into linear and persistent fact symbols. We suppose that Σ fact always contains a unary, persistent symbol !K and a linear, unary symbol Fr. Given a sequence or set of facts S we denote by lfacts(S) the multiset of all linear facts in S and pfacts(S) the set of all persistent facts in S. By notational convention facts whose identifier starts with ' !' will be persistent. G denotes the set of ground facts, i.e., the set of facts that does not contain variables. For a fact f we denote by ginsts(f ) the set of ground instances of f . This notation is also lifted to sequences and sets of facts as expected.

Substitutions A substitution σ is a partial function from variables to terms. We suppose that substitutions are well-typed, i.e., they only map variables of sort s to terms of sort s, or of a subsort of s. We denote by σ = { t 1 / x 1 , . . . , tn / xn } the substitution whose domain is D(σ) = {x 1 , . . . , x n } and which maps x i to t i . As usual we homomorphically extend σ to apply to terms and facts and use a postfix notation to denote its application, e.g., we write tσ for the application of σ to the term t. A substitution σ is grounding for a term t if tσ is ground. Given function g we let g(x) = ⊥ when x ∈ D(x). When g(x) = ⊥ we say that g is undefined for x. We define the function

f := g[a → b] with D(f ) = D(g) ∪ { a } as f (a) := b and f (x) := g(x) for x = a.
Sets, sequences and multisets We write N n for the set {1, . . . , n}. Given a set S we denote by S * the set of finite sequences of elements from S and by S # the set of finite multisets of elements from S. We use the superscript # to annotate usual multiset operation, e.g. S 1 ∪ # S 2 denotes the multiset union of multisets S 1 , S 2 . Given a multiset S we denote by set(S) the set of elements in S. The sequence consisting of elements e 1 , . . . , e n will be denoted by [e 1 , . . . , e n ] and the empty sequence is denoted by []. We denote by |S| the length, i.e., the number of elements of the sequence. We use • for the operation of adding an element either to the start or to the end, e.g., e 1 • [e 2 , e 3 ] = [e 1 , e 2 , e 3 ] = [e 1 , e 2 ] • e 3 . Given a sequence S, we denote by idx (S) the set of positions in S, i.e., N n when S has n elements, and for i ∈ idx (S) S i denotes the ith element of the sequence. Set membership modulo E is denoted by ∈ E and defined as e ∈ E S if ∃e ′ ∈ S. e ′ = E e. ⊂ E and = E are defined for sets in a similar way. Application of substitutions are lifted to sets, sequences and multisets as expected. By abuse of notation we sometimes interpret sequences as sets or multisets; the applied operators should make the implicit cast clear.

A cryptographic pi calculus with explicit state

Syntax and informal semantics

Our calculus is a variant of the applied pi calculus [START_REF] Abadi | Mobile values, new names, and secure communication[END_REF]. In addition to the usual operators for concurrency, replication, communication and name creation, it offers several constructs for reading and updating an explicit global state. The grammar for processes is described in Figure 1.

M,N ::= x, y, z ∈ V | p ∈ PN | n ∈ FN | f (M 1 ,. . . ,M n ) (f ∈ Σ of arity n) P ,Q ::= 0 | P | Q | ! P | νn; P | out(M, N ); P | in(M, N ); P | if M =N then P [else Q] | event F ; P (F ∈ F) | insert M ,N ; P | delete M ; P | lookup M as x in P [else Q] | lock M ; P | unlock M ; P | [L] -[A]→ [R]; P (L, R, A ∈ F * )
Figure 1: Syntax 0 denotes the terminal process. P | Q is the parallel execution of processes P and Q and !P the replication of P , allowing an unbounded number of sessions in protocol executions. The construct νn; P binds the name n in P and models the generation of a fresh, random value. Processes out(M, N ); P and in(M, N ); P represent the output, respectively input, of message N on channel M . Readers familiar with the applied pi calculus [START_REF] Abadi | Mobile values, new names, and secure communication[END_REF] may note that we opted for the possibility of pattern matching in the input construct, rather than merely binding the input to a variable x. The process if M =N then P else Q will execute P if M = E N and Q otherwise. The event construct is merely used for annotating processes and will be useful for stating security properties. For readability we sometimes omit to write else Q when Q is 0, as well as trailing 0 processes.

The remaining constructs are used for manipulating state and are new compared to the applied pi calculus. We offer two different mechanisms for state. The first construct is functional and allows to associate a value to a key. The construct insert M ,N binds the value N to a key M . Successive inserts allow to change this binding. The delete M operation simply "undefines" the mapping for the key M . The lookup M as x in P else Q allows to retrieve the value associated to M , binding it to the variable x in P . If the mapping is undefined for M the process behaves as Q. The lock and unlock constructs allow to gain exclusive access to a resource M . This is essential for writing protocols where parallel processes may read and update a common memory. We additionally offer another kind of global state in form of a multiset of ground facts, as opposed to the previously introduced functional store. This multiset can be altered using the construct [L] -[A]→ [R]; P , which tries to match each fact in the sequence L to facts in the current multiset and, if successful, adds the corresponding instance of facts R to the store. The facts A are used as annotations in a similar way to events. The purpose of this construct is to provide access to the underlying notion of state in tamarin, but we stress that it is distinct from the previously introduced functional state, and its use is only advised to expert users. We allow this "low-level" form of state manipulation in addition to the functional state, as it offers a great flexibility and has shown useful in one of our case studies. This style of state manipulation is similar to the state extension in the strand space model [START_REF] Guttman | State and progress in strand spaces: Proving fair exchange[END_REF] and the underlying specification language of the tamarin tool [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF][START_REF] Schmidt | The tamarin prover for the symbolic analysis of security protocols[END_REF]. Note that, even though those stores are distinct (which is a restriction imposed by our translation), data can be moved from one to another, for example as follows: lookup 'store1' as

x in [] -[ ]→ [store2(x)].
In the following example, which will serve as our running example, we model a security API that, even though much simplified, illustrates the most salient issues that occur in the analysis of security APIs such as PKCS#11 [START_REF] Delaune | Formal analysis of PKCS#11 and proprietary extensions[END_REF][START_REF] Bortolozzo | Attacking and fixing PKCS#11 security tokens[END_REF][START_REF] Fröschle | Reasoning with past to prove PKCS#11 keys secure[END_REF] .

Example. We consider a security device that allows the creation of keys in its secure memory. The user can access the device via an API. If he creates a key, he obtains a handle, which he can use to let the device perform operations on his behalf. For each handle the device also stores an attribute which defines what operations are permitted for this handle. The goal is that the user can never gain knowledge of the key, as the user's machine might be compromised. We model the device by the following process (we use out(m) as a shortcut for out(c, m) for a public channel c): In the first line, the device creates a new handle h and a key k and, by the means of the event NewKey(h, k), logs the creation of this key. It then stores the key that belongs to the handle by associating the pair 'key', h to the value of the key k. In the next line, 'att', h is associated to a public constant 'dec'. Intuitively, we use the public constants 'key' and 'att' to distinguish two databases. The process

!P new | !P set | !P dec | !P
P set := in(h); insert 'att',h , 'wrap'
allows the attacker to change the attribute of a key from the initial value 'dec' to another value 'wrap'.

If a handle has the 'dec' attribute set, it can be used for decryption:

P dec := in( h,c ); lookup 'att',h as a in if a='dec' then lookup 'key' ,h as k in if encCor(c,k)=true then event DecUsing(k,sdec(c,k)); out(sdec(c,k))
The first lookup stores the value associated to 'att', h in a. The value is compared against 'dec'. If the comparison and another lookup for the associated key value k succeeds, we check whether decryption succeeds and, if so, output the plaintext.

If a key has the 'wrap' attribute set, it might be used to encrypt the value of a second key:

P wrap := in( h 1 ,h 2 ); lookup 'att',h 1 as a 1 in if a 1 ='wrap' then lookup 'key' ,h 1 as k 1 in lookup 'key' , h 2 as k 2 in event Wrap(k 1 ,k 2 ); out(senc(k 2 ,k 1 ))
The bound names of a process are those that are bound by νn. We suppose that all names of sort fresh appearing in the process are under the scope of such a binder. Free names must be of sort pub. A variable x can be bound in three ways: (i) by the construct lookup M as x, or (ii) x ∈ vars(N ) in the construct in(M, N ) and x is not under the scope of a previous binder, (iii) x ∈ vars(L) in the construct [L] -[A]→ [R] and x is not under the scope of a previous binder. While the construct lookup M as x always acts as a binder, the input and [L] -[A]→ [R] constructs do not rebind an already bound variable but perform pattern matching. For instance in the process

P = in(c,f (x)); in(c,g(x))
x is bound by the first input and pattern matched in the second. It might seem odd that lookup acts as a binder, while input does not. We justify this decision as follows: as P dec and P wrap in the previous example show, lookups appear often after input was received. If lookup were to use pattern matching, the following process P = in(c, x); lookup 'store' as x in P ′ might unexpectedly perform a check if 'store' contains the message given by the adversary, instead of binding the content of 'store' to x, due to an undetected clash in the naming of variables.

a ∈ FN ∪ PN a / ∈ ñ ν ñ.σ ⊢ a Dname ν ñ.σ ⊢ t t = E t ′ ν ñ.σ ⊢ t ′ DEq x ∈ D(σ) ν ñ.σ ⊢ xσ DFrame ν ñ.σ ⊢ t 1 • • • ν ñ.σ ⊢ t n f ∈ Σ k ν ñ.σ ⊢ f (t 1 , . . . , t n ) DAppl Figure 2: Deduction rules. x 1 ∈ D(σ) ν ñ.σ ⊢ senc(k 2 , k 1 ) x 2 ∈ D(σ) ν ñ.σ ⊢ k 1 ν ñ.σ ⊢ sdec(senc(k 2 , k 1 ), k 1 ) sdec(senc(k 2 , k 1 ), k 1 ) = E k 2 ν ñ.σ ⊢ k 2
A process is ground if it does not contain any free variables. We denote by P σ the application of the homomorphic extension of the substitution σ to P . As usual we suppose that the substitution only applies to free variables. We sometimes interpret the syntax tree of a process as a term and write P | p to refer to the subprocess of P at position p (where |, if and lookup are interpreted as binary symbols, all other constructs as unary).

Semantics

Frames and deduction Before giving the formal semantics of our calculus we introduce the notions of frame and deduction. A frame consists of a set of fresh names ñ and a substitution σ and is written ν ñ.σ. Intuitively a frame represents the sequence of messages that have been observed by an adversary during a protocol execution and secrets ñ generated by the protocol, a priori unknown to the adversary. Deduction models the capacity of the adversary to compute new messages from the observed ones.

Definition 1 (Deduction). We define the deduction relation ν ñ.σ ⊢ t as the smallest relation between frames and terms defined by the deduction rules in Figure 2.

Example. If one key is used to wrap a second key, then, if the intruder learns the first key, he can deduce the second. For

ñ = k 1 , k 2 and σ = { senc(k 2 ,k 1 ) / x 1 , k 1 / x 2 }, ν ñ.σ ⊢ k 2 ,
as witnessed by the proof tree given in Figure 3.

Operational semantics

We can now define the operational semantics of our calculus. The semantics is defined by a labelled transition relation between process configurations. A process configuration is a 6-tuple (E, S, S MS , P, σ, L) where • E ⊆ FN is the set of fresh names generated by the processes;

• S : M Σ → M Σ is a partial function modeling the functional store;

• S MS ⊆ G # is a multiset of ground facts and models the multiset of stored facts;

• P is a multiset of ground processes representing the processes executed in parallel;

• σ is a ground substitution modeling the messages output to the environment;

K(M) ----→ (E, S, S MS , P ∪ # {P }, σ ∪ { N / x }, L) if
x is fresh and νE.σ ⊢ M (E, S, S MS , P ∪ # {in(M, N ); P }, σ, L)

K( M,N τ ) -------→ (E, S, S MS , P ∪ # {P τ }, σ, L) if ∃τ. τ is grounding for N, νE.σ ⊢ M, νE.σ ⊢ N τ (E, S, S MS , P ∪ # {out(M, N ); P, in(M ′ , N ′ ); Q}, σ, L) -→ (E, S, S MS , P ∪ {P, Qτ }, σ, L) if M = E M ′ and ∃τ. N = E N ′ τ and τ grounding for N ′ (E, S, S MS , P ∪ {if M = N then P else Q}, σ, L) -→ (E, S, S MS , P ∪ {P }, σ, L) if M = E N (E, S, S MS , P ∪ {if M = N then P else Q}, σ, L) -→ (E, S, S MS , P ∪ {Q}, σ, L) if M = E N (E, S, S MS , P ∪ {event(F ); P }, σ, L) F -→ (E, S, S MS , P ∪ {P }, σ, L)
Operations on global state: The transition relation is defined by the rules described in Figure 4. Transitions are labelled by sets of ground facts. For readability we omit empty sets and brackets around singletons, i.e., we write

(E, S, S MS , P ∪ # {insert M, N ; P }, σ, L) -→ (E, S[M → N ], S MS , P ∪ # {P }, σ, L) (E, S, S MS , P ∪ # {delete M ; P }, σ, L) -→ (E, S[M → ⊥], S MS , P ∪ # {P }, σ, L) (E, S, S MS , P ∪ # {lookup M as x in P else Q }, σ, L) -→ (E, S, S MS , P ∪ # {P {V /x}}, σ, L) if S(N ) = E V is defined and N = E M (E, S, S MS , P ∪ # {lookup M as x in P else Q }, σ, L) -→ (E, S, S MS , P ∪ # {Q}, σ, L) if S(N ) is undefined for all N = E M (E, S, S MS , P ∪ # {lock M ; P }, σ, L) -→ (E, S, S MS , P ∪ # {P }, σ, L ∪ { M }) if M ∈ E L (E, S, S MS , P ∪ # {unlock M ; P }, σ, L) -→ (E, S, S MS , P ∪ # {P }, σ, L \ { M ′ | M ′ = E M }) (E, S, S MS , P ∪ # {[l -[a]→ r]; P }, σ, L) a ′ -→ (E, S, S MS \ lfacts(l ′ ) ∪ # r ′ , P ∪ # { P τ }, σ, L) if ∃τ, l ′ , a ′ , r ′ . τ grounding for l -[a]→ r, l ′ -[a ′ ]→ r ′ = E (l -[a]→ r)τ, lfacts(l ′ ) ⊆ # S MS , pfacts(l ′ ) ⊂ S MS
→ for ∅ -→ and f -→ for { f } -→.
We write → * for the reflexive, transitive closure of → (the transitions that are labelled by the empty sets) and write f ⇒ for → * f →→ * . We can now define the set of traces, i.e., possible executions, that a process admits. Definition 2 (Traces of P ). Given a ground process P we define the set of traces of P as

traces pi (P ) = [F 1 , . . . , F n ] | (∅, ∅, ∅, {P }, ∅, ∅) F 1 =⇒ (E 1 , S 1 , S MS 1 , P 1 , σ 1 , L 1 ) F 2 =⇒ . . . Fn =⇒ (E n , S n , S MS n , P n , σ n , L n )
Example. In Figure 5 we display the transitions that illustrate how the first key is created on the security device in our running example and witness that [NewKey(h ′ , k ′ )] ∈ traces pi (P ).

(∅, ∅, ∅, { !P new , !P set |!P dec |!P wrap

=:P ′ } # , ∅, ∅) → (∅, ∅, ∅, { P new } # ∪ # P ′ , ∅, ∅) → (∅, ∅, ∅, { ν h; νk; event NewKey(h, k); . . . } # ∪ # P ′ , ∅, ∅) → * ({ h ′ , k ′ }, ∅, ∅, { event NewKey(h ′ , k ′ ); . . . } # ∪ # P ′ , ∅, ∅) NewKey(h ′ ,k ′ ) ---------→ ({ h ′ , k ′ }, ∅, ∅, { insert 'key', h ′ , k ′ ; . . . } # ∪ # P ′ , ∅, ∅) → * ({ h ′ , k ′ }, S, ∅, { out(h ′ ); 0 } # ∪ # P ′ , ∅, ∅) → * ({ h ′ , k ′ }, S, ∅, P ′ , { h ′ / x 1 }, ∅)
where S( 'key',h ′ ) = k ′ and S( 'att',h ′ ) = 'dec'. We now recall the syntax and semantics of labelled multiset rewriting rules, which constitute the input language of the tamarin tool [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF].

Definition 3 (Multiset rewrite rule). A labelled multiset rewrite rule ri is a triple (l, a, r), l, a, r ∈ F * , written l -[a]→ r. We call l = prems(ri ) the premises, a = actions(ri ) the actions, and r = conclusions(ri ) the conclusions of the rule.

Definition 4 (Labelled multiset rewriting system). A labelled multiset rewriting system is a set of labelled multiset rewrite rules R, such that each rule l -[a]→ r ∈ R satisfies the following conditions:

• l, a, r do not contain fresh names

• r does not contain Fr-facts A labelled multiset rewriting system is called well-formed, if additionally

• for each l ′ -[a ′ ]→ r ′ ∈ E ginsts(l -[a]→ r) we have that ∩ r ′′ = E r ′ names(r ′′ )∩FN ⊆ ∩ l ′′ = E l ′ names(l ′′ )∩ FN .
We define one distinguished rule Fresh which is the only rule allowed to have Fr-facts on the right-hand side Fresh

: [] -[]→ [Fr(x : fresh)]
The semantics of the rules is defined by a labelled transition relation.

Definition 5 (Labelled transition relation). Given a multiset rewriting system R we define the labeled transition relation

→ R ⊆ G # × P(G) × G # as S a -→ R ((S \ # lfacts(l)) ∪ # r)
if and only if l -[a]→ r ∈ E ginsts(R ∪ Fresh), lfacts(l) ⊆ # S and pfacts(l) ⊆ S.

Definition 6 (Executions). Given a multiset rewriting system R we define its set of executions as

exec msr (R) = ∅ A 1 -→ R . . . An -→ R S n | ∀a, i, j : 0 ≤ i = j < n. (S i+1 \ # S i ) = {Fr(a)} ⇒ (S j+1 \ # S j ) = {Fr(a)}
The set of executions consists of transition sequences that respect freshness, i. e., for a given name a the fact Fr(a) is only added once, or in other words the rule Fresh is at most fired once for each name. We define the set of traces in a similar way as for processes.

Definition 7 (Traces). The set of traces is defined as

traces msr (R) = [A 1 , . . . , A n ] | ∀ 0 ≤ i ≤ n. A i = ∅ and ∅ A 1 =⇒ R . . . An =⇒ R S n ∈ exec msr (R)
where

A =⇒ R is defined as ∅ -→ * R A -→ R ∅ -→ * R .
Note that both for processes and multiset rewrite rules the set of traces is a sequence of sets of facts.

Security Properties

In the tamarin tool [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF] security properties are described in an expressive two-sorted first-order logic. The sort temp is used for time points, V temp are the temporal variables.

Definition 8 (Trace formulas). A trace atom is either false ⊥, a term equality t 1 ≈ t 2 , a timepoint ordering i ⋖ j, a timepoint equality i . = j, or an action F @i for a fact F ∈ F and a timepoint i. A trace formula is a first-order formula over trace atoms.

As we will see in our case studies this logic is expressive enough to analyze a variety of security properties, including complex injective correspondence properties.

To define the semantics, let each sort s have a domain D(s). D(temp) = Q, D(msg ) = M, D(fresh) = FN , and D(pub) = PN . A function θ : V → M ∪ Q is a valuation if it respects sorts, that is, θ(V s ) ⊂ D(s) for all sorts s. If t is a term, tθ is the application of the homomorphic extension of θ to t. Definition 9 (Satisfaction relation). The satisfaction relation (tr , θ) ϕ between trace tr , valuation θ and trace formula ϕ is defined as follows:

(tr , θ) ⊥ never (tr , θ) F @i iff θ(i) ∈ idx (tr) and F θ ∈ E tr θ(i) (tr , θ) i ⋖ j iff θ(i) < θ(j) (tr , θ) i . = j iff θ(i) = θ(j) (tr , θ) t 1 ≈ t 2 iff t 1 θ = E t 2 θ (tr , θ) ¬ϕ iff not (tr , θ) ϕ (tr , θ) ϕ 1 ∧ ϕ 2 iff (tr , θ) ϕ 1 and (tr , θ) ϕ 2 (tr , θ) ∃x : s.ϕ iff there is u ∈ D(s) such that (tr , θ[x → u]) ϕ
When ϕ is a ground formula we sometimes simply write tr ϕ as the satisfaction of ϕ is independent of the valuation.

Definition 10 (Validity, satisfiability). Let Tr ⊆ (P(G)) * be a set of traces. A trace formula ϕ is said to be valid for Tr , written Tr ∀ ϕ, if for any trace tr ∈ Tr and any valuation θ we have that (tr , θ) ϕ.

A trace formula ϕ is said to be satisfiable for Tr , written Tr ∃ ϕ, if there exist a trace tr ∈ Tr and a valuation θ such that (tr , θ) ϕ.

Note that Tr ∀ ϕ iff Tr ∃ ¬ϕ. Given a multiset rewriting system R we say that ϕ is valid, written R ∀ ϕ, if traces msr (R) ∀ ϕ. We say that ϕ is satisfied in R, written R ∃ ϕ, if traces msr (R) ∃ ϕ. Similarly, given a ground process P we say that ϕ is valid, written P ∀ ϕ, if traces pi (P ) ∀ ϕ, and that ϕ is satisfied in P , written P ∃ ϕ, if traces pi (P ) ∃ ϕ.

Example. The following trace formula expresses secrecy of keys generated on the security API, which we introduced in Section 3.

¬(∃h, k : msg, i, j : temp. NewKey(h, k)@i ∧ K(k)@j) Out(x) -[ ]→ !K(x) (MDOut) !K(x) -[K(x)]→ In(x) (MDIn) -[ ]→ !K(x : pub) (MDPub) Fr(x : fresh) -[ ]→ !K(x : fresh) (MDFresh) !K(x 1 ), . . . , !K(x k ) -[ ]→ !K(f (x 1 , . . . , x k )) for f ∈ Σ k (MDAppl)

A translation from processes into multiset rewrite rules

In this section we define a translation from a process P into a set of multiset rewrite rules P and a translation on trace formulas such that P |= ∀ ϕ if and only if P |= ∀ ϕ . Note that the result also holds for satisfiability, as an immediate consequence. For a rather expressive subset of trace formulas (see [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF] for the exact definition of the fragment), checking whether P |= ∀ ϕ can then be discharged to the tamarin prover that we use as a backend.

Definition of the translation of processes

To model the adversary's message deduction capabilities, we introduce the set of rules MD defined in Figure 6.

In order for our translation to be correct, we need to make some assumptions on the set of processes we allow. These assumptions are however, as we will see, rather mild and most of them without loss of generality. First we define a set of reserved variables that will be used in our translation and whose use we therefore forbid in the processes.

Definition 11 (Reserved variables and facts). The set of reserved variables is defined as the set containing the elements n a for any a ∈ FN and lock l for any l ∈ N.

The set of reserved facts F res is defined as the set containing facts f (t 1 , . . . , t n ) where t 1 , . . . , t n ∈ T and f ∈ { Init, Insert, Delete, IsIn, IsNotSet, state, Lock, Unlock, Out, Fr, In, Msg, ProtoNonce, Eq, NotEq, Event, InEvent }.

Similar to [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF], for our translation to be sound, we require that for each process, there exists an injective mapping assigning to every unlock t in a process a lock t that precedes it in the process' syntax tree. Moreover, given a process lock t; P the corresponding unlock in P may not be under a parallel or replication. These conditions allow us to annotate each corresponding pair lock t, unlock t with a unique label l. The annotated version of a process P is denoted P . The formal definition of P is given in Appendix A. In case the annotation fails, i.e., P violates one of the above conditions, the process P contains ⊥.

Definition 12 (well-formed). A ground process P is well-formed if

• no reserved variable nor reserved fact appear in P ,

• any name and variable in P is bound at most once and • P does not contain ⊥.

• For each action l -[a]→ r that appears in the process, the following holds: for each l

′ -[a ′ ]→ r ′ ∈ E ginsts(l -[a]→ r) we have that ∩ r ′′ = E r ′ names(r ′′ ) ∩ FN ⊆ ∩ l ′′ = E l ′ names(l ′′ ) ∩ FN .
A trace formula ϕ is well-formed if no reserved variable nor reserved fact appear in ϕ.

The two first restrictions of well-formed processes are not a loss of generality as processes and formulas can be consistently renamed to avoid reserved variables and α-converted to avoid binding names or variables several times. Also note that the second condition is not necessarily preserved during an execution, e.g. when unfolding a replication, !P and P may bind the same names. We only require this condition to hold on the initial process for our translation to be correct.

The annotation of locks restricts the set of protocols we can translate, but allows us to obtain better verification results, since we can predict which unlock is "supposed" to close a given lock. This additional information is helpful for tamarin's backward reasoning. We think that our locking mechanism captures all practical use cases. Using our calculus' "low-level" multiset manipulation construct, the user is also free to implement locks himself, e.g., as

[NotLocked()] → []; code ; [] → [NotLocked()]
(In this case the user does not benefit from the optimisation we put into the translation of locks.) Obviously, locks can be modelled both in tamarin's multiset rewriting calculus (this is actually what the translation does) and Mödersheim's set rewriting calculus [START_REF] Mödersheim | Abstraction by set-membership: verifying security protocols and web services with databases[END_REF]. However, protocol steps typically consist of a single input, followed by several database lookups, and finally an output. In practice, they tend to be modelled as a single rule, and are therefore atomic. Real implementations are however different, as several entities might be involved, database lookups could be slow, etc. In this case, such simplified models could, e. g., miss race conditions. To the best of our knowledge, StatVerif is the only comparable tool that models locks explicitly and it has stronger restrictions.

Definition 13. Given a well-formed ground process P we define the labelled multiset rewriting system P as

MD ∪ {Init} ∪ P , [], []
• where the rule Init is defined as

Init : [] -[Init()]→ [state [] ()]
• P, p, x is defined inductively for process P , position p ∈ N * and sequence of variables x in Figure 7.

• For a position p of P we define state p to be persistent if P | p = !Q for some process Q; otherwise state p is linear.

In the definition of P, p, x we intuitively use the family of facts state p to indicate that the process is currently at position p in its syntax tree. A fact state p will indeed be true in an execution of these rules whenever some instance of P p (i.e. the process defined by the subtree at position p of the syntax tree of P ) is in the multiset P of the process configuration. The translation of the zero-process, parallel and replication operators merely use state p -facts. For instance P | Q, p, x defines the rule

[state p (x)] → [state p•1 (x), state p•2 (x)]
which intuitively states that when a process is at position p (modelled by the fact state p (x) being true) then the process is allowed to move both to P (putting state p•1 (x) to true) and Q (putting state p•2 (x) to true). The translation of P | Q, p, x also contains the set of rules P, p • 1, x ∪ Q, p • 2, x expressing that after this transition the process may behave as P and Q, i.e., the processes at positions p • 1, respectively p • 2, in the process tree. Also note that the translation of !P results in a persistent fact as !P always remains in P. The translation of the construct ν a translates the name a into a variable n a , as msr rules must not contain fresh names. Any instantiation of this rule will substitute n a by a fresh name, which the Fr-fact in the premise guarantees to be new. This step is annotated with a (reserved) action ProtoNonce, used in the proof of correctness to distinguish adversary and protocol nonces. Note that the fact state p•1 in the conclusion carries n a , so that the following protocol steps are bound to the fresh name used to instantiate n a . The first rules of the translation of out and in model the communication between the protocol and the adversary, and vice versa. In the case of out, the adversary must know the channel M , modelled by the fact In(M ) in the rule's premisse, and learns the output message, modelled by the fact Out(N ) in the conclusion. In the case of in, the knowledge of the message N is additionally required and the variables of the input message are added to the parameters of the state fact to reflect that these variables are bound. The second and third rules of the translations of out and in model an internal communication, which is synchronous. For this reason, when the second rule of the translation of out is fired, the state-fact is substituted by an intermediate, semi-state fact, state semi , reflecting that the sending process can only execute the next step if the message was successfully received. The fact Msg(M, N ) models that a message is present on the synchronous channel. Only with the acknowledgement fact Ack(M, N ), resulting from the second rule of the translation of in, is it possible to advance the execution of the sending process, using the third rule in the translation of out, which transforms the semi-state and the acknowledgement of receipt into state p•1 (. . .). Only now the next step in the execution of the sending process can be executed. The remaining rules essentially update the position in the state facts and add labels. Some of these labels are used to restrict the set of executions. For instance the label Eq(M ,N ) will be used to indicate that we only consider executions in which M = E N . As we will see in the next section these restrictions will be encoded in the trace formula.

0, p, x = {[state p (x)] → []} P | Q, p, x = {[state p (x)] → [state p•1 (x), state p•2 (x)]} ∪ P, p • 1, x ∪ Q, p • 2, x !P, p, x = {[!state p (x)] → [state p•1 (x)]} ∪ P, p • 1, x νa; P, p, x = {[state p (x), Fr(n a : fresh)] -[ProtoNonce (n a : fresh)]→ [state p•1 (x, n a : fresh)]} ∪ P, p • 1, (x, n a : fresh) Out(M, N ); P, p, x = {[state p (x), In(M )] -[InEvent(M )]→ [Out(N ), state p•1 (x)], [state p (x)] → [Msg(M, N ), state semi p (x)], [state semi p (x), Ack(M, N )] → [state p•1 (x)] } ∪ P, p • 1, x In(M, N ); P, p, x = {[state p (x), In( M, N )] -[InEvent( M, N )]→ [state p•1 (x ∪ vars(N ))], [state p (x), Msg(M, N )] → [state p•1 (x ∪ vars(N )), Ack(M, N )]} ∪ P, p • 1, x ∪ vars(N ) if M = N then P else Q, p, x = {[state p (x)] -[ Eq(M, N ) ]→ [state p•1 (x)], [state p (x)] -[NotEq(M, N )]→ [state p•2 (x)]} ∪ P, p • 1, x ∪ Q, p • 2, x event F ; P, p, x = {[state p (x)] -[Event(), F ]→ [state p•1 (x)]} ∪ P, p • 1, x insert s, t; P, p, x = {[state p (x)] -[Insert(s, t)]→ [state p•1 (x)]} ∪ P, p • 1, x delete s; P, p, x = {[state p (x)] -[Delete(s)]→ [state p•1 (x)]} ∪ P, p • 1, x lookup M as v in P else Q, p, x = {[state p (x)] -[IsIn(M, v)]→ [state p•1 ( M , v)], [state p (x)] -[IsNotSet(M )]→ [state p•2 (x)]} ∪ P, p • 1, (x, v) ∪ Q, p • 2, x lock l s; P, p, x = {[Fr(lock l ), state p (x)] -[Lock(lock l , s)]→ [state p•1 (x, lock l )]} ∪ P, p • 1, x unlock l s; P, p, x = {[state p (x)] -[Unlock(lock l , s)]→ [state p•1 (x)]} ∪ P, p • 1, x [l -[a]→ r]; P, p, x = {[state p (x), l] -[Event(), a]→ [r, state p•1 (x ∪ vars(l))]} ∪ P, p • 1, x ∪ vars(l)
-[Init()]→ [state [] ()] [state [] ()] -[ ]→ [!state [1] ()] [!state [1] (), Fr(h)] -[ ]→ [state [11] (h)] [state [11] (h), Fr(k)] -[ ]→ [state [111] (k, h)] [state [111] (k, h)] -[Event(), NewKey(h, k)]→ [state [1111] (k, h)] [state [1111] (k, h)] -[Insert( 'key', h , k)]→ [state [11111] (k, h)] [state [11111] (k, h)] -[Insert( 'att', h , 'dec')]→ [state [111111] (k, h)] [state [111111] (k, h)] -[ ]→ [Out(h), state [1111111] (k, h)]
Example. Figure 8 illustrates the above translation by presenting the set of msr rules !P new (omitting the rules in MD already shown in Figure 6). A graph representation of an example trace, generated by the tamarin tool, is depicted in Figure 9. Every box in this picture stands for the application of a multiset rewrite rule, where the premises are at the top, the conclusions at the bottom, and the actions (if any) in the middle. Every premise needs to have a matching conclusion, visualized by the arrows, to ensure the graph depicts a valid msr execution. (This is a simplification of the dependency graph representation tamarin uses to perform backwardinduction [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF][START_REF] Schmidt | The tamarin prover for the symbolic analysis of security protocols[END_REF].) Note that the machine notation for state p () predicates omits brackets [ ] in the position p and denotes the empty sequence by '0'. We also note that in the current example !state [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] () is persistent and can therefore be used multiple times as a premise. As Fr( ) facts are generated by the Fresh rule which has an empty premise and action, we omit instances of Fresh and leave those premises, but only those, disconnected.

Remark 1. One may note that, while for all other operators, the translation produces well-formed multiset rewriting rules (as long as the process is well-formed itself ), this is not the case for the translation of the lookup operator, i. e., it violates the well-formedness condition from Definition 4. Tamarin's constraint solving algorithm requires all rules, with the exception of Fresh, to be well-formed. We show however that, under these specific conditions, the solution procedure is still correct. See Appendix B for the proof.

Definition of the translation of trace formulas

We can now define the translation for formulas. Definition 14. Given a well-formed trace formula ϕ we define

ϕ ∀ := α ⇒ ϕ and ϕ ∃ := α ∧ ϕ
where α is defined in Figure 10.

The formula α uses the actions of the generated rules to filter out executions that we wish to discard: • α init ensures that the init rule is only fired once.

state_0111111( k, h ) Out( h ) state_01111111( k, h ) state_011111( k, h ) Insert( <'att', h>, 'dec' ) state_0111111( k, h ) state_01111( k, h ) Insert( <'key', h>, k ) state_011111( k, h ) state_0111( k, h ) Event( ),NewKey( h, k ) state_01111( k, h ) state_011( h ) Fr( k ) state_0111( k, h ) !state_01( ) Fr( h ) state_011( h ) state_0( ) !state_01( ) !state_01( ) Fr( h' ) state_011( h' ) 0[Init( )] state_0( ) state_0111111( k', h' ) Out( h' ) state_01111111( k', h' ) state_011111( k', h' ) Insert( <'att', h'>, 'dec' ) state_0111111( k', h' ) state_01111( k', h' ) Insert( <'key', h'>, k' ) state_011111( k', h' ) state_0111( k', h' ) Event( ),NewKey( h', k' ) state_01111( k', h' ) state_011( h' ) Fr( k' ) state_0111( k', h' )
• α eq and α noteq ensure that we only consider traces where all (dis)equalities hold.

• α in and α notin ensure that a successful lookup was preceded by an insert that was neither revoked nor overwritten while an unsuccessful lookup was either never inserted, or deleted and never reinserted.

• α lock checks that between each two matching locks there must be an unlock. Furthermore, between the first of these locks and the corresponding unlock, there is neither a lock nor an unlock.

• α inev ensures that whenever an instance of MDIn is required to generate an In-fact, it is generated as late as possible, i. e., there is no visible event between the action K(t) produced by MDIn, and a rule that requires In(t).

We also note that

Tr ∀ ϕ ∀ iff Tr ∃ ¬ϕ ∃ .
The axioms in the translation of the formula are designed to work hand in hand with the translation of the process into rules. They express the correctness of traces with respect to our calculus' semantics, but are also meant to guide tamarin's constraint solving algorithm. α in and α notin illustrate what kind of axioms work well: when a node with the action IsIn is created, by definition of the translation, this corresponds to a lookup command. The existential translates into a graph constraint that postulates an insert node for the value fetched by the lookup, and three formulas assuring that a) this insert node appears before the lookup, b) is uniquely defined, i. e., it is the last insert to the corresponding key, and c) there is no delete in between. Due to these conditions, α notin only adds one Insert node per IsIn node -the case where an axiom postulates a node, which itself allows for postulating yet another node needs to be avoided, as tamarin runs into loops otherwise. Similarly, a naïve way of implementing locks using an axiom would postulate that every lock is preceeded by an unlock and no lock or unlock

α := α init ∧ α eq ∧ α noteq ∧ α in ∧ α notin ∧ α lock ∧ α inev and α init :=∀i, j.
Init()@i ∧ Init()@j =⇒ i = j α eq :=∀x, y, i. Eq(x, y)@i =⇒ x ≈ y α noteq :=∀x, y, i. NotEq(x, y)@i =⇒ ¬(x ≈ y) in between, unless it is the first lock. This again would cause tamarin to loop, because an unlock is typically preceeded by yet another lock. The axiom α lock avoids this caveat because it only applies to pairs of locks carrying the same annotations. We will outline how α lock is applied during the constraint solving procedure:

α in :=∀x, y, t 3 . IsIn(x, y)@t 3 =⇒ ∃t 2 . Insert(x, y)@t 2 ∧ t 2 ⋖ t 3 ∧ ∀t 1 , y. Insert(x, y)@t 1 =⇒ (t 1 ⋖ t 2 ∨ t 1 . = t 2 ∨ t 3 ⋖ t 1 ) ∧ ∀t 1 . Delete(x)@t 1 =⇒ (t 1 ⋖ t 2 ∨ t 3 ⋖ t 1 ) α notin :=∀x, y, t 3 . IsNotSet(x)@t 3 =⇒ (∀t 1 , y. Insert(x, y)@t 1 =⇒ t 3 ⋖ t 1 )∨ (∃t 1 . Delete(x)@t 1 ∧ t 1 ⋖ t 3 ∧ ∀t 2 , y. (Insert(x, y)@t 2 ∧ t 2 ⋖ t 3 ) =⇒ t 2 ⋖ t 1 )
α lock :=∀x, l, l ′ , i, j. Lock(l, x)@i ∧ Lock(l ′ , x)@j ∧ i ⋖ j =⇒ ∃k. Unlock(l, x)@k ∧ i ⋖ k ∧ k ⋖ j ∧ (∀l ′ , m. Lock(l ′ , x)@m =⇒ ¬(i ⋖ m ∧ m ⋖ k)) ∧ (∀l ′ , m. Unlock(l ′ , x)@m =⇒ ¬(i ⋖ m ∧ m ⋖ k)) α inev :=∀t, i. InEvent(t)@i =⇒ ∃j. K(t)@j ∧ (∀k. Event()@k =⇒ (k ⋖ j ∨ i ⋖ k)) ∧ (∀k, t ′ . K(t ′ )@k =⇒ (k ⋖ j ∨ i ⋖ k ∨ k ≈ j))
1. If there are two locks for the same term and with possibly different annotations, an unlock for the first of those locks is postulated, more precisely, an unlock with the same term, the same annotation and no lock or unlock for the same term in-between. The axiom itself contains only one case, so the only case distinction that takes place is over which rule produces the matching Unlock-action. However, due to the annotation, all but one are refuted immediately in the next step. Note further that α lock postulates only a single node, namely the node with the action Unlock.

2. Due to the annotation, the fact state p (. . .) contains the fresh name that instantiates the annotation variable. Let a : fresh be this fresh name. Every fact state p ′ (. . .) for some position p ′ that is a prefix of p and a suffix of the position of the corresponding lock contains this fresh name. Furthermore, every rule instantiation that is an ancestor of a node in the dependency graph corresponds to the execution of a command that is an ancestor in the process tree. Therefore, the backward search eventually reaches the matching lock, including the annotation, which is determined to be a, and hence appears in the Fr-premise.

3. Because of the Fr-premise, any existing subgraph that already contains the first of the two original locks would be merged with the subgraph resulting from the backwards search that we described in the previous step, as otherwise Fr(a) would be added at two different points in the execution.

4. The result is a sequence of nodes from the first lock to the corresponding unlock, and graph constraints restricting the second lock to not take place between the first lock and the unlock. We note that the axiom α lock is only instantiated once per pair of locks, since it requires that i ⋖ j, thereby fixing their order.

In summary, the annotation helps distinguishing which unlock is expected between to locks, vastly improving the speed of the backward search. This optimisation, however, required us to put restrictions on the locks.

Correctness of the translation

The correctness of our translation is stated by the following theorem.

Theorem 1. Given a well-formed ground process P and a well-formed trace formula ϕ we have that traces pi (P ) ⋆ ϕ iff traces msr ( P ) ⋆ ϕ ⋆ where ⋆ is either ∀ or ∃.

We here give an overview of the main propositions and lemmas needed to prove Theorem 1. To show the result we need two additional definitions. We first define an operation that allows to restrict a set of traces to those that satisfy the trace formula α as defined in Definition 14. The following proposition states that if a set of traces satisfies the translated formula then the filtered traces satisfy the original formula.

Proposition 1. Let Tr be a set of traces and ϕ a trace formula. We have that

Tr ⋆ ϕ ⋆ iff filter (Tr ) ⋆ ϕ
where ⋆ is either ∀ or ∃.

The proof (detailed in Appendix) follows directly from the definitions. Next we define the hiding operation which removes all reserved facts from a trace. As expected well-formed formulas that do not contain reserved facts evaluate the same whether reserved facts are hidden or not. Proposition 2. Let Tr be a set of traces and ϕ a well-formed trace formula. We have that

Tr ⋆ ϕ iff hide(Tr ) ⋆ ϕ
where ⋆ is either ∀ or ∃.

We can now state our main lemma which is relating the set of traces of a process P and the set of traces of its translation into multiset rewrite rules (proven in the full version).

Lemma 1. Let P be a well-formed ground process. We have that traces pi (P ) = hide(filter (traces msr ( P ))).

Our main theorem can now be proven by applying Lemma 1, Proposition 3 and Proposition 1.

Proof of Theorem 1.

traces pi (P ) ⋆ ϕ ⇔ hide(filter (traces msr ( P ))) ⋆ ϕ by Lemma 1 ⇔ filter (traces msr ( P )) ⋆ ϕ by Proposition 3 ⇔ traces msr ( P ) ⋆ ϕ ⋆ by Proposition 1

Case studies

In this section we briefly overview some case studies we performed. These case studies include a simple security API similar to PKCS#11 [START_REF]PKCS #11: Cryptographic Token Interface Standard[END_REF], the Yubikey security token, the optimistic contract signing protocol by Garay, Jakobsson and MacKenzie (GJM) [START_REF] Garay | Abuse-free optimistic contract signing[END_REF] and a few other examples discussed in Arapinis et al. [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF] and Mödersheim [START_REF] Mödersheim | Abstraction by set-membership: verifying security protocols and web services with databases[END_REF]. The results are summarized in Figure 11. For each case study we provide the number of typing lemmas that were needed by the tamarin prover and whether manual guidance of the tool was required. In case no manual guidance is required we also give execution times. We do not detail all the formal models of the protocols and properties that we studied, and sometimes present slightly simplified versions. All files of our prototype implementation and our case studies are available at http://sapic.gforge.inria.fr/.

Example

Typing Lemmas Automated Run * Security API à la PKCS#11 1 yes (51s) Yubikey Protocol [START_REF] Künnemann | YubiSecure? Formal security analysis results for the Yubikey and YubiHSM[END_REF][START_REF] Yubico | The YubiKey Manual -Usage, configuration and introduction of basic concepts (Version 2.2)[END_REF] 3 no GJM protocol [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF][START_REF] Garay | Abuse-free optimistic contract signing[END_REF] 0 yes (36s) Mödersheim's example (locks/inserts) [START_REF] Mödersheim | Abstraction by set-membership: verifying security protocols and web services with databases[END_REF] 0 no * * Mödersheim's example (embedded msr rules) [START_REF] Mödersheim | Abstraction by set-membership: verifying security protocols and web services with databases[END_REF] 0 yes (1s) Security Device [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF] 1 yes (21s) Needham-Schroeder-Lowe [START_REF] Lowe | Breaking and fixing the Needham-Schroeder public-key protocol using FDR[END_REF] 1 yes (5s) * (Running times on Intel Core2 Duo 2.66Ghz with 4GB RAM) * * (little interaction: 7 manual rule selections)

Security API à la PKCS#11

This example illustrates how our modelling might be useful for the analysis of Security APIs in the style of the PKCS#11 standard [START_REF]PKCS #11: Cryptographic Token Interface Standard[END_REF]. We expect studying a complete model of PKCS#11, such as in [START_REF] Delaune | Formal analysis of PKCS#11 and proprietary extensions[END_REF], to be a straightforward extension of this example. In addition to the processes presented in the running example in Section 3 the actual case study models the following two operations: (i) encryption: given a handle and a plain-text, the user can request an encryption under the key the handle points to. (ii) unwrap given a ciphertext senc(k 2 , k 1 ), and a handle h 1 , the user can request the ciphertext to be unwrapped, i.e. decrypted, under the key pointed to by h 1 . If decryption is successful the result is stored on the device, and a handle pointing to k 2 is returned. Moreover, contrary to the running example, at creation time keys are assigned the attribute 'init', from which they can move to either 'wrap', or 'unwrap', see the following snippet:

in ( 'set_dec',h ) ; lock ' att ' ,h ; lookup ' att ' ,h as a in if a='init ' then insert ' att ' ,h , 'dec' ; unlock ' att ' ,h
Note that, in contrast to the running example, it is necessary to encapsulate the state changes between lock and unlock. Otherwise an adversary can stop the execution after line 3, set the attribute to 'wrap' in a concurrent process and produce a wrapping. After resuming operation at line 4, he can set the key's attribute to 'dec', even though the attribute is set to 'wrap'. Hence, the attacker is allowed to decrypt the wrapping he has produced and can obtain the key. Such subtleties can produce attacks that our modeling allows to detect. If locking is handled correctly, we show secrecy of keys produced on the device, proving the property introduced in Example 5. If locks are removed the attack described before is found.

Yubikey

The Yubikey [START_REF] Yubico | The YubiKey Manual -Usage, configuration and introduction of basic concepts (Version 2.2)[END_REF] is a small hardware device designed to authenticate a user against network-based services. Manufactured by Yubico, a Swedish company, the Yubikey itself is a low cost ($25), thumbsized USB device. In its typical configuration, it generates one-time passwords based on encryptions of a secret value, a running counter and some random values using a unique AES-128 key contained in the device. The Yubikey authentication server accepts a one-time password only if it decrypts under the correct AES key to a valid secret value containing a counter larger than the last counter accepted. The counter is thus used as a means to prevent replay attacks. To date, over a million Yubikeys have been shipped to more than 30,000 customers including governments, universities and enterprises, e.g. Google, Microsoft, Agfa and Symantec [START_REF] Yubico | Yubico customer list[END_REF].

Besides the counter values used in the one-time password, the Yubikey stores three additional pieces of information: the public id pid that is used to identify the Yubikey, a secret id secretid that is transmitted as part of the one-time password and only known to the server and the Yubikey, as well as the AES key k, which is also shared with the server. The following process P Yubikey models a single Yubikey, as well as its initial configuration, where an entry in the server's database for the public id pid is created. This entry contains a tuple consisting of the Yubikey's secret id, AES key, and an initial counter value.

P Yubikey = ν k; ν pid; ν secretid ; insert ' Server ' , pid , secretid , k, ' zero ' ; insert 'Yubikey', pid , ' zero '+'one'; out(pid) ; !P Plugin | !P ButtonPress
Here, the processes !P Plugin and !P ButtonPress model the Yubikey being unplugged and plugged in again (possibly on a different computer), and the emission of the one-time password. We will only discuss P ButtonPress here. When the user presses the button on the Yubikey, the device outputs a one-time password consisting of a counter tc, the secret id secretid and additional randomness npr encrypted using the AES key k. The one-time password senc( secretid, tc, npr , k) can be used to authenticate against a server that shares the same secret key, which we model in the process P Server . The process receives the encrypted one-time password along with the public id pid of a Yubikey and a nonce that is part of the protocol, but is irrelevant for the authentication of the Yubikey on the server.

The server looks up the secret id and the AES key associated to the public id, i. e., to the Yubikey sending the request, as well as the last recorded counter value otc. If the key and secret id used in the request match the values retrieved from the database, then the event Smaller(otc, tc) is logged along with the event Login(pid , k, tc), which marks a successful login of the Yubikey pid with key k for the counter value tc. Afterwards, the old tuple secretid , k, otc is replaced by secretid , k, tc , to update the latest counter value received. Note that, in our modelling, the server keeps one lock per public id, which means that it is possible to have several active instances of the server thread in parallel as long as all requests concern different Yubikeys.

P Server = ! in( pid,
An important part of the modelling of the protocol is to determine whether one counter value is smaller than another. To this end, our modelling employs a feature added to the development version of tamarin as of October 2012, a union operator ∪ # for multisets of message terms. The operator is denoted with a plus sign ("+"). We model the counter as a multiset only consisting of the symbols "one" and "zero". The multiplicity of 'one' in the multiset is the value of the counter. A counter value is considered smaller than another one, if the first multiset is included in the second. A test a < b is included by adding the event Smaller(a, b) and an axiom that requires that a is a subset of b:

α Smaller :=∀i : temp, a, b : msg. Smaller(a, b)@i ⇒ ∃z : msg . a + z = b
We incorporate this axiom into the security properties just like in Definition 14. Intuitively, we are only interested in traces where a is indeed smaller than b.

The process we analyse models a single authentication server (that may run arbitrary many threads) and an arbitrary number of Yubikeys, i. e., P Server | !P Yubikey . Among other properties, we show by the means of an injective correspondence property that an attacker that controls the network cannot perform replay attacks, and that each successful login was preceded by a user "pressing the button", formally:

∀ pid , k, x, t 2 .Login(pid, k , x )@t 2 ⇒ ∃sid, t 1 .YubiPress(pid, sid, k , x )@t 1 ∧ t 1 ⋖ t 2 ∧ ∀t 3 .Login(pid, k , x )@t 3 ⇒ t 3 = t 2
Besides injective correspondence, we show the absence of replay attacks and the property that a successful login invalidates previously emitted one-time passwords. All three properties follow more or less directly from a stronger invariant, which itself can be proven in 295 steps. To find theses steps, tamarin needs some additional human guidance, which can be provided using the interactive mode. This mode still allows the user to complement his manual efforts with automated backward search. The example files contain the modelling in our calculus, the complete proof, and the manual part of the proof which can be verified by tamarin without interaction.

Our analysis makes three simplifications: First, in P Server , we use pattern matching instead of decryption as demonstrated in the process P dec we introduced in Section 3. Second, we omit the CRC checksum and the time-stamp that are part of the one-time password in the actual protocol, since they do not add to the security of the protocol in the symbolic setting. Third, the Yubikey has actually two counters instead of one, a session counter, and a token counter. We treat the session and token counter on the Yubikey as a single value, which we justify by the fact that the Yubikey either increases the session counter and resets the token counter, or increases only the token counter, thereby implementing a complete lexicographical order on the pair (session counter , token counter ).

A similar analysis has already been performed by Künnemann and Steel, using tamarin's multiset rewriting calculus [START_REF] Künnemann | YubiSecure? Formal security analysis results for the Yubikey and YubiHSM[END_REF]. However, the model in our new calculus is more fine-grained and we believe more readable. Security-relevant operations like locking and tests on state are written out in detail, resulting in a model that is closer to the real-life operation of such a device. The modeling of the Yubikey takes approximately 38 lines in our calculus, which translates to 49 multiset rewrite rules. The model of [START_REF] Künnemann | YubiSecure? Formal security analysis results for the Yubikey and YubiHSM[END_REF] contains only four rules, but they are quite complicated, resulting in 23 lines of code. More importantly, the gap between their model and the actual Yubikey protocol is larger -in our calculus, it becomes clear that the server can treat multiple authentication requests in parallel, as long as they do not claim to stem from the same Yubikey. An implementation on the basis of the model from Künnemann and Steel would need to implement a global lock accessible to the authentication server and all Yubikeys. This is however unrealistic, since the Yubikeys may be used at different places around the world, making it unlikely that there exist means of direct communication between them. While a server-side global lock might be conceivable (albeit impractical for performance reasons), a real global lock could not be implemented for the Yubikey as deployed.

Further Case Studies

We also investigated the case study presented by Mödersheim [START_REF] Mödersheim | Abstraction by set-membership: verifying security protocols and web services with databases[END_REF], a key-server example. We encoded two models of this example, one using the insert construct, the other manipulating state using the embedded multiset rewrite rules. For this example the second model turned out to be more natural and more convenient allowing for a direct automated proof without any additional typing lemma.

We furthermore modeled the contract signing protocol by Garay et al. [START_REF] Garay | Abuse-free optimistic contract signing[END_REF] and a simple security device which both served as examples in [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF]. In the contract signing protocol a trusted party needs to maintain a database with the current status of all contracts (aborted, resolved, or no decision has been taken). In our calculus the status information is naturally modelled using our insert and lookup constructs. The use of locks is indispensable to avoid the status to be changed between a lookup and an insert. Arapinis et al. [START_REF] Arapinis | Statverif: Verification of stateful processes[END_REF] showed the crucial property that the same contract can never be both aborted and resolved. However, due to the fact that StatVerif only allows for a finite number of memory cells, they have shown this property for a single contract and provide a manual proof to lift the result to an unbounded number of contracts. We directly prove this property for an unbounded number of contracts. Finally we also illustrate the tool's ability to analyze classical security protocols, by analyzing the Needham Schroeder Lowe protocol [START_REF] Lowe | Breaking and fixing the Needham-Schroeder public-key protocol using FDR[END_REF].

Conclusion

We present a process calculus which extends the applied pi calculus with constructs for accessing a global, shared memory together with an encoding of this calculus in labelled msr rules which enables automated verification using the tamarin prover as a backend. Our prototype verification tool, automating this translation, has been successfully used to analyze several case studies. As future work we plan to increase the degree of automation of the tool by automatically generating helping lemmas. To achieve this goal we can exploit the fact that we generate the msr rules, and hence control their form. We also plan to use the tool for more complex case studies including a complete model of PKCS#11 and a study of the TPM 2.0 standard, currently in public review. Finally, we wish to investigate how our constructs for manipulating state can be used to encode loops, needed to model stream protocols such as TESLA.

A Definition of the process annotation

Definition 17 (Process annotation). Given a ground process P we define the annotated ground process P as follows:

0 := 0 The multiset rewrite system produced by our translation for a well-formed process P could actually contain rewrite rules that are not valid with respect to Definition 4, because they violate the third condition, which is:

P |Q := P |Q !P := !P if t 1 = t 2 then P else Q := if t 1 = t 2 then P else Q lookup M as x in P else Q := lookup M
for each l ′ -[a ′ ]→ r ′ ∈ R ∈ E ginsts(l -[a]→ r) we have that ∩ r ′′ = E r ′ names(r ′′ ) ∩ FN ⊆ ∩ l ′′ = E l ′ names(l ′′ ) ∩ FN .
This does not hold for rules in P =p where p is the position of the lookup-operator. The right hand-side of this rule can be instantiated such that, assuming the variable bound by the lookup is named v, this variable v is substituted by a names that does not appear on the left-hand side. In the following, we will show that the results from [START_REF] Schmidt | Automated analysis of Diffie-Hellman protocols and advanced security properties[END_REF] still hold. In practice, this means that the tamarinprover can be used for verification, despite the fact that it outputs well-formedness errors for each rule that is a translation of a lock.

We will introduce some notation first. We re-define P to contain the Init rule and P , [], [] , but not MD (which is different to Definition 13). We furthermore define a translation with dummy-facts, denoted P D , that contains Init and P , [], [] D , which is defined as follows: the exception of two cases, P = lookup M as v in P else Q and P = insert s, t; P , where it is defined as follows:

lookup M as v in P else Q, p, x D = {[state p (x), !Dum(v)] -[IsIn(M, v)]→ [state p•1 ( M , v)], [state p (x)] -[IsNotSet(M )]→ [state p•2 (x)]} ∪ P, p • 1, (x, v) D ∪ Q, p • 2, x D insert s, t; P, p, x D = { [state p (x)] -[Insert(s, t)]→ [state p•1 (x), !Dum(t)] } ∪ P, p • 1, x D
The only difference between P and P D is therefore, that P D produces a permanent fact !Dum for every value v that appears in an action insert(k, v), which is a premise to every rule instance with an action IsIn(k ′ , v). We see that P D contains now only valid multiset rewrite rules.

In the following, we would like to show that the tamarin-prover's solution algorithm is correct for P . To this end, we make use of the proof of correctness of tamarin as presented in Benedikt Schmidt's Ph.D. thesis [START_REF] Schmidt | Formal Analysis of Key-Exchange Protocols and Physical Protocols[END_REF]. We will refer to Lemmas, Theorems and Corollaries in this work by their numbers. We will use the notation of this work, to make it easier to the reader to compare our statements against the statements there. In particular, trace(execs(R)) is traces msr (R) in our notation. We have to show that: Lemma 2. For all well-formed process P and guarded trace properties φ, trace(execs( P ∪ MD) DH e ¬α in ∨ φ if and only if trace(ndgraphs ( P )) ACC ¬α in ∨ φ.

Proof. The proof proceeds similar to the proof to Theorem 3.27. We refer to results in [START_REF] Schmidt | Formal Analysis of Key-Exchange Protocols and Physical Protocols[END_REF], whenever their proofs apply despite the fact that the rules in P do not satisfy the third condition of multiset rewrite rules. It is only in Lemma A.12 where the third condition is used: The proof to this lemma applies Lemma A.14, which says that all factors (or their inverses) are known to the adversary. We will quote Lemma A.14 here: Lemma 3 (Lemma A.14 in [START_REF] Schmidt | Formal Analysis of Key-Exchange Protocols and Physical Protocols[END_REF]). For all ndg ∈ ndgraphs (P ), conclusions (i, u) in ndg with conclusion fact f and terms t ∈ afactors (f ), there is a conclusion (j, v) in ndg with j < i and conclusion fact

K d (m) such that m ∈ ACC { t, (t -1 ) ↓ RBP e }.
If there is ndg ∈ ndgraphs ( P ), such that trace(ndg ) ACC α in , then trace(ndgraphs ( P )) ACC ¬α in ∨ φ ⇔∀ndg ∈ ndgraphs ( P ) s. t. trace(ndg ) ACC α in trace(ndg ) ACC φ Since for the empty trace, [] ACC α in , we only have to show that Lemma A.14 holds for ndg ∈ ndgraphs ( P ), such that trace(ndg) ACC α in .

For every ndg ∈ ndgraphs ( P ), such that trace(ndg ) ACC α in , there is a trace equivalent ndg ′ ∈ ndgraphs ( P D ), since the only difference between P and P D lies in the dummy conclusion and premises, and α in requires that any v in an action IsIn(u, v) appeared previously in an action Insert(u, v) (equivalence modulo ACC ). Therefore, ndg ′ has the same K d -conclusions ndg has, and every conclusion in ndg is a conclusion in ndg ′ .

We have that Lemma A.14 holds for P D , since all rules generated in this translation are valid multiset rewrite rules. Therefore, Lemma A.14 holds for all ndg ∈ ndgraphs ( P ), such that trace (ndg) ACC α in , too, concluding the proof by showing the marked (*) step.

C Proofs of Section 6

Proposition 1. Let Tr be a set of traces and ϕ a trace formula. We have that

Tr ⋆ ϕ ⋆ iff filter (Tr ) ⋆ ϕ
where ⋆ is either ∀ or ∃.

Proof. We first show the two directions for the case ⋆ = ∀. We start by showing that Tr ∀ ϕ implies filter (Tr ) ϕ.

⇔ Tr ∀ α ⇒ ϕ ⇔ Tr ∀ ϕ ∀ (by definition of ϕ ∀ )
The case of ⋆ = ∃ now easily follows:

Tr ∃ ϕ ∃ iff Tr ∀ ¬ϕ ∀ iff filter (Tr ) ∀ ¬ϕ iff filter (Tr ) ∃ ϕ.
Proposition 3. Let Tr be a set of traces and ϕ a well-formed trace formula. We have that

Tr ⋆ ϕ iff hide(Tr ) ⋆ ϕ
where ⋆ is either ∀ or ∃.

Proof. We start with the case ⋆ = ∃ and show the stronger statement that for a trace tr We proceed by structural induction on ϕ.

• ϕ = ⊥, ϕ = i ⋖ j, ϕ = i . = j or t 1 ≈ t 2 .
In these cases we trivially conclude as the truth value of these formulas does not depend on the trace and for both statements we simply let θ ′ := θ.

• ϕ = f @i. We start with the first statement. Suppose that (tr , θ) f @i. If θ(i) < n then we have also that tr , θ f @i. By induction hypothesis, there exists θ ′ such that (tr , θ ′ ) f @i. Hence we also have that (tr , θ ′ ) f @i and letting θ ′ := θ ′ allows us to conclude. If θ(i) = n we know that f ∈ tr n . As ϕ is well-formed f ∈ F res and hence f ∈ hide(tr ) n ′ where n ′ = |hide(tr )|. The proof of the other statement is similar.

• ϕ = ¬ϕ ′ , ϕ = ϕ 1 ∧ ϕ 2 , or ϕ = ∃x : s.ϕ ′ . We directly conclude by induction hypotheses (on the structure of ϕ).

From the above statements we easily have that Tr ∃ ϕ iff hide(Tr ) ∃ ϕ.

The case of ⋆ = ∀ now easily follows:

Tr ∀ ϕ iff Tr ∃ ¬ϕ iff hide(Tr ) ∃ ¬ϕ iff hide(Tr ) ∀ ϕ
In order to prove Lemma 1, we need a few additional lemmas. We say that a set of traces Tr is prefix closed if for all tr ∈ Tr and for all tr ′ which is a prefix of tr we have that tr ′ ∈ Tr .

Lemma 4 (filter is prefix-closed). Let Tr be a set of traces. If Tr is prefix closed then filter (Tr ) is prefix closed as well.

Proof. It is sufficient to show that for any trace tr = tr ′ • a we have that if ∀θ. (tr , θ) α then ∀θ. (tr ′ , θ) α. This can be shown by inspecting each of the conjuncts of α.

We next show that the translation with dummy facts defined in Definition 18 produces the same traces as P , excluding traces not consistent with the axioms. For this we define the function d which removes any dummy fact from an execution, i.e.,

d(∅

F 1 -→ S 1 F 2 -→ . . . Fn -→ S n ) = ∅ F 1 -→ S ′ 1 F 2 -→ . . . Fn -→ S ′ n where S ′ i = S i \ # ∪ t∈T !Dum(t).
Lemma 5. Given a ground process P , we have that filter (exec msr ( P )) = filter (d(exec msr ( P D ∪ MD)))

Proof. The only rules in P D that differ from P are translations of insert and lookup. The first one only adds a permanent fact, which by the definition of d, is removed when applying d. The second one requires a fact !Dum(t), whenever the rule is instantiated such the actions equals IsIn(s, t) for some s.

Since the translation is otherwise the same, we have that filter (d(exec msr ( P D ∪ MD))) ⊆ filter (exec msr ( P ))

For any trace in filter (d(exec msr ( p ∪ MD))) and any action IsIn(s, t) in this trace, there is an earlier action Insert(s ′ , t ′ ) such that s = s ′ and t = t ′ , as otherwise α in would not hold. Therefore the same trace is part of filter (d(exec msr ( p D ∪ MD))), as this means that whenever !Dum(t) is in the premise, !Dum(t ′ ) for t = t ′ has previously appeared in the conclusion. Since it is a permanent fact, it has not disappeared and therefore filter (d(exec msr ( P D ∪ MD))) ⊆ filter (exec msr ( P ))

We slightly abuse notation by defining filter on executions to filter out all traces contradicting the axioms, see Definition 15. Lemma 6. Let P be a ground process and ∅

F 1 -→ S 1 F 2 -→ . . .

Fn

-→ S n ∈ filter (exec msr ( P )). For all 1 ≤ i ≤ n, if Fr(a) ∈ S i and F (t 1 , . . . , t k ) ∈ S i for any F ∈ Σ fact \ { Fr }, then a ∈ ∩ t= E t ′ names(t ′ ), for any t ∈ {t 1 , . . . , t k }.

Proof. The translation with the dummy fact introduced in Appendix B will make this proof easier as for P D ∪ MD, we have that the third condition of Definition 4 holds, namely,

∀l ′ -[a ′ ]→ r ′ ∈ E ginsts(l -[a]→ r) : ∩ r ′′ = E r ′ names(r ′′ ) ∩ FN ⊆ ∩ l ′′ = E l ′ names(l ′′ ) ∩ FN (1)
We will show that the statement holds for all ∅

F 1 -→ S 1 F 2 -→ . . .

Fn

-→ S n ∈ filter (exec msr ( P D ∪ MD)), which implies the claim by Lemma 5. We proceed by induction on n, the length of the execution.

• Base case, n = 0. We have that S 0 = ∅ and therefore the statement holds trivially.

• Inductive case, n ≥ 1. We distinguish two cases.

1. A rule that is not Fresh was applied and there is a fact F (t 1 , . . . , t k ) ∈ S n , such that F (t 1 , . . . , t k ) / ∈ S n-1 , and Fr(a) ∈ S n such that a ∈ ∩ t i = E t ′ names(t ′ ) for some t i . (If there are no such F (t 1 , . . . , t k ) and Fr(a) we immediately conclude by induction hypothesis.) By Equation 1, a ∈ t ′ j for some F ′ (t ′ 1 , . . . , t ′ l ) ∈ S n-1 . Since Fresh is the only rule that adds a Fr-fact and Fr(a) ∈ S n , it must be that Fr(a) ∈ S n-1 , contradicting the induction hypothesis. Therefore this case is not possible. 2. The rule Fresh was applied, i. e., Fr(a) ∈ S n and Fr(a) / ∈ S n-1 . If there is no a ∈ ∩ t i = E t ′ names(t ′ ) for some t i , and F (t 1 , . . . , t k ) ∈ S n , then we conclude by induction hypothesis. Otherwise, if there is such a F (t 1 , . . . , t k ) ∈ S n , then, by Equation 1, a ∈ t ′ j for some F ′ (t ′ 1 , . . . , t ′ l ) ∈ S i for i < n. We construct a contradiction to the induction hypothesis by taking the prefix of the execution up to i and appending the instantiation of the Fresh rule to its end. Since d(exec msr ( P D ∪ MD)) is prefix closed by Lemma 4 we have that

∅ F 1 -→ S ′ 1 F 2 -→ . . . F i -→ S i ∈ filter (d(exec msr ( P D ∪ MD))
). Moreover as rule Fresh was applied adding Fr(a) ∈ S n it is also possible to apply the same instance of Fresh to the prefix (by Definition 6) and therefore

∅ F 1 -→ S ′ 1 F 2 -→ . . . F i -→ S i -→ S i ∪ { Fr(a) } ∈ filter (d(exec msr ( P D ∪ MD)))
contradicting the induction hypothesis. Lemma 7. For any frame ν ñ.σ, t ∈ M and a ∈ FN , if a ∈ st(t), a ∈ st(σ) and ν ñ.σ ⊢ t, then ν ñ, a.σ ⊢ t.

Proof. In [1, Proposition 1] it is shown that ν ñ.σ ⊢ t if and only if ∃M.fn(M ) ∩ ñ = ∅ and M σ = E t. Define M ′ as M renaming a to some fresh name, i.e., not appearing in ñ, σ, t. As a ∈ st(σ, t) and the fact that equational theories are closed under bijective renaming of names we have that M ′ σ = E t and fn(M ′ ) ∩ (ñ, a) = ∅. Hence ν ñ, a.σ ⊢ t.

Lemma 8. Let P be a ground process and ∅

F 1 -→ S 1 F 2 -→ . . . Fn -→ S n ∈ filter (exec msr ( P )). Let ñ = {a : fresh | ProtoNonce(a) ∈ 1≤j≤n F j }, {t 1 , . . . , t m } = {t | Out(t) ∈ 1≤j≤n S j }. Let σ = { t 1 / x 1 , . . . , tm / xm }. We have that 1. if !K(t) ∈ S n then ν ñ.σ ⊢ t; 2. if ν ñ.σ ⊢ t then there exists S such that • ∅ F 1 -→ S 1 F 2 -→ . . . Fn -→ S n -→ * S ∈ filter (exec msr E ( P )), • !K(t) ∈ E S and • S n → *
R S for R = { MDOut, MDPub, MDFresh, MDAppl, Fresh }. Proof. We prove both items separately.

1. The proof proceeds by induction on n, the number of steps of the execution.

Base case: n=0. This case trivially holds as S n = ∅.

Inductive case: n>0. By induction we suppose that if !K(t) ∈ S n-1 then ν ñ′ .σ ′ ⊢ t where ñ′ , σ ′ are defined in a similar way as ñ, σ but for the execution of size n -1. We proceed by case analysis on the rule used to extend the execution.

• MDOut. Suppose that Out(u) -[ ]→!K(u) ∈ ginsts(MDOut) is the rule used to extend the execution. Hence Out(u) ∈ S n-1 and by definition of σ there exists x such that xσ = u. We can apply deduction rule DFrame and conclude that ν ñ.σ ⊢ u. If !K(t) ∈ S n and t = u we conclude by induction hypothesis as ñ = ñ′ , σ = σ ′ .

• MDPub. Suppose that -[ ]→ K(a : pub) ∈ ginsts(MDPub) is the rule used to extend the execution. As names of sort pub are never added to ñ we can apply deduction rule DName and conclude that ν ñ.σ ⊢ a. If K(t) ∈ S n and t = a we conclude by induction hypothesis as ñ = ñ′ , σ = σ ′ .

• MDFresh. Suppose that Fr(a : fresh) -[ ]→ K(a : fresh) ∈ ginsts(MDFresh) is the rule used to extend the execution. By definition of an execution we have that Fr(a : fresh) = (S j+1 \ S j ) for any j = n -1. Hence n ∈ ñ. We can apply deduction rule DName and conclude that ν ñ.σ ⊢ a. If !K(t) ∈ S n and t = a we conclude by induction hypothesis as ñ = ñ′ , σ = σ ′ .

• MDAppl. Suppose that !K(t 1 ), . . . , !K(t k ) -[ ]→!K(u) ∈ ginsts(MDAppl) is the rule used to extend the execution. We have that K(t 1 ), . . . , K(t k ) ∈ S n-1 and u = E f (t 1 , . . . , t k ). By induction hypothesis, ν ñ′ .σ ′ ⊢ t i for 1 ≤ i ≤ k. As ñ = ñ′ , σ = σ ′ we have that ν ñ.σ ⊢ t i for 1 ≤ i ≤ k. We can apply deduction rule DAppl and conclude that ν ñ.σ ⊢ f (t 1 , . . . , t k ).

Hence, ν ñ.σ ⊢ u by rule DEq. If K(t) ∈ S n and t = f (t 1 , . . . , t k ) we conclude by induction hypothesis as ñ = ñ′ , σ = σ ′ .

• If S n-1

ProtoNonce (a)

---------→S n we have that Fr(a) ∈ S n-1 . By Lemma 6, we obtain that if !K(t) ∈ S n-1 then there exist t ′ and σ ′′ such that t ′ = E t, σ ′′ = E σ ′ and a ∈ st(t ′ ) and a ∈ st(σ ′′ ). For each !K(u) ∈ S n there is !K(u) ∈ S n-1 , and by induction hypothesis, ν ñ′ .σ ′ ⊢ u. By Lemma 7 and the fact that σ ′′ = E σ ′ we have that ν ñ′ , a.σ ′ ⊢ u. As ñ′ , a = ñ and σ ′ = σ we conclude.

• All other rules do neither add !K( )-facts nor do they change ñ and may only extend σ.

Therefore we conclude by the induction hypothesis.

2. Suppose that ν ñ.σ ⊢ t. We proceed by induction on the proof tree witnessing ν ñ.σ ⊢ t.

Base case. The proof tree consists of a single node. In this case one of the deduction rules DName or DFrame has been applied. Inductive case. We proceed by case distinction on the last deduction rule which was applied.

• DAppl. In this case t = f (t 1 , . . . , t k ), such that f ∈ Σ k and ν ñr.σ ⊢ t i for every i ∈ {1, . . . , k}. Applying the induction hypothesis we obtain that there are k transition sequences S n → * R S i for 1 ≤ i ≤ k which extend the execution such that t i ∈ S i . All of them only add !K facts which are persistent facts. If any two of these extensions remove the same Out(t)-fact or the same Fr(a)-fact it also adds the persistent fact !K(t), respectively !K(a), and we simply remove the second occurrence of the transition. Therefore, applying the same rules as for the transitions S n → * S i (and removing duplicate rules) we have that S n → * S ′ and !K(t 1 ), . . . , !K(t k ) ∈ S ′ . Applying rule MDAppl we conclude.

• DEq. By induction hypothesis there exists S as required with !K(t ′ ) ∈ E S and t = E t ′ which allows us to immediately conclude that !K(t) ∈ E S.

Lemma 9. If ν ñ.σ ⊢ t, ñ = E ñ′ , σ = E σ ′ and t = E t ′ , then ν ñ′ .σ ′ ⊢ t ′ .
Proof. Assume ν ñ.σ ⊢ t. Since an application of DEq can be appended to the leafs of its proof tree, we have ν ñ.σ ′ ⊢ t. Since DEq can be applied to its root, we have ν ñ.σ ′ ⊢ t ′ . Since ñ, ñ′ consist only of names, ñ = ñ′ and thus ν ñ′ .σ ′ ⊢ t ′ .

To state our next lemma we need two additional definitions.

Definition 19. Let P be a well-formed ground process and p t a position in P . We define the set of multiset rewrite rules generated for position p t of P , denoted P =pt as follows:

P =pt := P, [], [] =pt
where •, •, • =pt is defined in Figure 12.

The next definition will be useful to state that for a process P every fact of the form state p ( t) in a multiset rewrite execution of P corresponds to an active process in the execution of P which is an instance of the subprocess P | p . Definition 20. Let P be a ground process, P be a multiset of processes and S a multiset of multiset rewrite rules. We write P ↔ P S if there exists a bijection between P and the multiset {state p ( t) | ∃p, t. state p ( t) ∈ # S} # such that whenever Q ∈ # P is mapped to state p ( t) ∈ # S we have that 1. P | p τ = Qρ, for some substitution τ and some bijective renaming ρ of fresh, but not bound names in Q, and 2. ∃ri ∈ E ginsts( P =p ). state p ( t) ∈ prems(ri).

When P ↔ P S, Q ∈ # P and state p ( t) ∈ # S we also write Q ↔ P state p ( t) if this bijection maps Q to state p ( t).

Remark 2. Note that ↔ P has the following properties (by the fact that it defines a bijection between multisets).

• If P 1 ↔ P S 1 and P 2 ↔ P S 2 then P 1 ∪ # P 2 ↔ P S 1 ∪ # S 2 .

• If P 1 ↔ P S 1 and Q ↔ P state p ( t) for Q ∈ P 1 and state p ( t) ∈ S 1 (i.e. Q and state p ( t) are related by the bijection defined by P 1 ↔ P S 1 ) then P 1 \ # {Q} ↔ P S 1 \ # {state p ( t)}.

Proposition 4. Let A be a finite set, < a strict total order on A and p a predicate on elements of A.

We have that

∀i ∈ A.p(i) ⇔ ∀i ∈ A. p(i) ∨ ∃j ∈ A. i < j ∧ ¬p(j) (⇔ ∀i ∈ A. ¬p(i) → ∃j ∈ A. i < j ∧ ¬p(j)) and ∃i ∈ A.p(i) ⇔ ∃i ∈ A.p(i) ∧ ∀j ∈ A. i < j → ¬p(j) 0, p, x =pt = { [state p (x)] → [] } p ? =pt P | Q, p, x =pt = { [state p (x)] → [state p•1 (x), state p•2 (x)] } p ? =pt ∪ P, p • 1, x =pt ∪ Q, p • 2, x =pt !P, p, x =pt = { [!state p (x)] → [state p•1 (x)] } p ? =pt ∪ P, p • 1, x =pt νa; P, p, x =pt = { [state p (x), Fr(n a : fresh)] -[ProtoNonce (n a : fresh)]→ [state p•1 (x, n a : fresh)] } p ? =pt ∪ P, p • 1, (x, n a : fresh) =pt Out(M, N ); P, p, x =pt = { [state p (x), In(M )] -[InEvent(M )]→ [Out(N ), state p•1 (x)], [state p (x)] → [Msg(M, N ), state semi p (x)], [state semi p (x), Ack(M, N )] → [state p•1 (x)] } p ? =pt ∪ P, p • 1, x =pt
In(M, N ); P, p, Lemma 10. Le P be a well-formed ground process. If

x =pt = { [state p (x), In( M, N )] -[InEvent( M, N )]→ [state p•1 (x ∪ vars(N ))], [state p (x), Msg(M, N )] → [state p•1 (x ∪ vars(N )), Ack(M, N )] } p ? =pt ∪ P, p • 1, x ∪ vars(N ) =pt if M = N then P else Q, p, x =pt = { [state p (x)] -[ Eq(M, N ) ]→ [state p•1 (x)], [state p (x)] -[NotEq(M, N )]→ [state p•2 (x)] } p ? =pt ∪ P, p • 1, x =pt ∪ Q, p • 2, x =pt event F ; P, p, x =pt = { [state p (x)] -[Event(), F ]→ [state p•1 (x)] } p ? =pt ∪ P, p • 1, x =pt insert s, t; P, p, x =pt = { [state p (x)] -[Insert(s, t)]→ [state p•1 (x)] } p ? =pt ∪ P, p • 1, x =pt delete s; P, p, x =pt = { [state p (x)] -[Delete(s)]→ [state p•1 (x)] } p ? =pt ∪ P, p • 1, x =pt lookup M as v in P else Q, p, x =pt = { [state p (x)] -[IsIn(M, v)]→ [state p•1 ( M , v)], [state p (x)] -[IsNotSet(M )]→ [state p•2 (x)] } p ? =pt ∪ P, p • 1, (x, v) =pt ∪ Q, p • 2, x =pt lock l s; P, p, x =pt = { [Fr(lock l ), state p (x)] -[Lock(lock l , s)]→ [state p•1 (x, lock l )] } p ? =pt ∪ P, p • 1, x =pt unlock l s; P, p, x =pt = { [state p (x)] -[Unlock(lock l , s)]→ [state p•1 (x)] } p ? =pt ∪ P, p • 1, x =pt [l -[a]→ r]; P, p, x =pt = { [state p (x), l] -[Event(), a]→ [r, state p•1 (x ∪ vars(l))] } p ? =pt ∪ P, p • 1, x ∪ vars(l)
(E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 ) E 1 -→ (E 1 , S 1 , S MS 1 , P 1 , σ 1 , L 1 ) E 2 -→ . . . En -→ (E n , S n , S MS n , P n , σ n , L n )
where (E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 ) = (∅, ∅, ∅, { P }, ∅, ∅) then there are (F 1 , S 1 ), . . . , (F n ′ , S n ′ ) such that

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ ∈ exec msr ( P )
and there exists a monotonic, strictly increasing function f :

N n → N n ′ such that f (n) = n ′ and for all i ∈ N n 1. E i = { a | ProtoNonce (a) ∈ 1≤j≤f (i) F j } 2. ∀t ∈ M. S i (t) =      u if ∃j ≤ f (i).Insert(t, u) ∈ F j ∧∀j ′ , u ′ .j < j ′ ≤ f (i) → Insert(t, u ′ ) ∈ E F j ′ ∧ Delete(t) ∈ E F j ′ ⊥ otherwise 3. S MS i = S f (i) \ # F res 4. P i ↔ P S f (i) 5. { xσ i | x ∈ D(σ i ) } # = {Out(t) ∈ ∪ k≤f (i) S k } # 6. L i = E { t | ∃j ≤ f (i), u. Lock(u, t) ∈ E F j ∧ ∀j < k ≤ f (i).Unlock(u, t) ∈ E F k } 7. [F 1 , . . . , F n ′ ]
α where α is defined as in Definition 14.

8. ∃k. f (i -1) < k ≤ f (i) and E i = F k and ∪ f (i-1)<j =k≤f (i) F j ⊆ F res
Proof. We proceed by induction over the number of transitions n.

Base Case. For n = 0, we let f (n) = 1 and S 1 be the multiset obtained by using the Rule Init: Inductive step. Assume the invariant holds for n -1 ≥ 0. We have to show that the lemma holds for n transitions

∅ Init -→ { state [] () } #
(E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 ) E 1 -→ (E 1 , S 1 , S MS 1 , P 1 , σ 1 , L 1 ) E 2 -→ . . . En -→ (E n , S n , S MS n , P n , σ n , L n )
By induction hypothesis, we have that there exists a monotonically increasing function from N n-1 → N n ′ and an execution ∅

F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ ∈ exec msr ( P )
such that Conditions 1 to 8 hold. Let f p be this function and note that n ′ = f p (n -1). Fix a bijection such that P n-1 ↔ P S fp(n-1) . We will abuse notation by writing P ↔ P state p ( t), if this bijection goes from P to state p ( t).

We now proceed by case distinction over the type of transition from

(E n-1 , S n-1 , S MS n-1 , P n-1 , σ n-1 , L n-1 ) to (E n , S n , S MS n , P n , σ n , L n ).
We will (unless stated otherwise) extend the previous execution by a number of steps, say s, from S n ′ to some S n ′ +s , and prove that Conditions 1 to 8 hold for n (since by induction hypothesis, they hold for all i < n) and a function f : N n → N n ′ +s that is defined as follows:

f (i) := f p (i) if i ∈ N n-1 n ′ + s if i = n Case: (E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ {0}, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ , σ n-1 , L n-1 )
. By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that 0 ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[ ]→ []. We can extend the previous execution by one step using ri , therefore: Case:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ -→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = { S f (n-1) \ {state p ( t) }.
= P n-1 \ # {0}, S f (n) = S f (n-1) \ # { state p ( t) } # ,
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ {Q|R}, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ {Q, R}, σ n-1 , L n-1
( t)] -[ ]→ [state p•1 ( t), state p•2 ( t)].
We can extend the previous execution by one step using ri , therefore: Case:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ -→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n-1) \ { state p ( t) } # ∪ { state p•1 ( t), state p•2 ( t) } # .
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ {!Q}, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ {!Q, Q}, σ n-1 , L n-1 )
. Let p and t such that ! i Q ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[ ]→ [state p ( t), state p•1 ( t)]. We can extend the previous execution by 1 step using ri , therefore: Case:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ (ri ) → P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n) ∪ # { state p•1 ( t) } # .
(E n-1 , S in-1 , S MS in-1 , P n-1 = P ′ ∪ { νa; Q }, σ n-1 , L n-1 ) → (E n-1 ∪ {a ′ }, S in-1 , S MS in-1 , P ′ ∪ {Q{ a ′ / a }}, σ n-1 , L n-1
) for a fresh a ′ . Let p and t be such that {νa; Q} ↔ P state p ( t). There is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , there is a ri ∈ ginsts( P =p ), ri = [state p ( t), Fr(a

′ : fresh)] -[ProtoNonce(a ′ : fresh)]→ [state p•1 ( t, a ′ : fresh)].
Assume there is an i < n ′ such that Fr(a ′ ) ∈ S i . If Fr(a ′ ) ∈ S n , then we can remove the application of the instance of Fresh that added Fr(a ′ ) while still preserving Conditions 1 to 8. If Fr(a ′ ) is consumned at some point, by the definition of P , the transition where it is consumned is annotated either ProtoNonce (a ′ ) or Lock (a ′ , t) for some t. In the last case, we can apply a substitution to the execution that substitutes a by a different fresh name that never appears in ∪ i ≤ n ′ S i . The conditions we have by induction hypothesis hold on this execution, too, since Lock ∈ F res , and therefore Condition 8 is not affected. The first case implies that a ′ ∈ E n-1 , contradicting the assumption that a ′ is fresh with respect to the process execution. Therefore, without loss of generality, the previous execution does not contain an i < n ′ such that Fr(a ′ ) ∈ S i , and we can extend the previous execution by two steps using the Fresh rule and ri , therefore:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ (Fresh) → P S n ′ +1 (ri) → P S n ′ +2 ∈ exec msr ( P ) with S n ′ +1 = S n ′ ∪ # { Fr(a ′ : fresh) } # and S n ′ +2 = S f (n) = S n ′ ∪ # { state p•1 ( t, a ′ : fresh) } # . We define f (i) := f p (i) for i < n and f (n) := f (n -1) + 2.
We now show that Condition 4 holds. As by induction hypothesis νa; Q ↔ P state p•1 ( t) we also have that P | p σ = νa; Qρ for some σ and ρ. Extending ρ with {a ′ → a} it is easy to see from definition of P =p that {Q{ a ′ / a }} ↔ P {state p•1 ( t, a ′ )}. As P n = P n-1 \ # {νa; Q} ∪ # { Q{ a ′ / a } } # , we also immediately obtain that P n ↔ P S f (n) . Since a ′ is fresh, and therefore { a ′ } = E n \ E n-1 , and F n = ProtoNonce (a ′ ), Condition 1 holds. Condition 2, Condition 3, Condition 5, Condition 6, Condition 7 and Condition 8 hold trivially.

Case:

(E n-1 , S n-1 , S MS n-1 , P n-1 , σ n-1 , L n-1 ) K(t) -→ (E n-1 , S n-1 , S MS n-1 , P n-1 , σ n-1 , L n-1
). This step requires that νE n-1 .σ n-1 ⊢ t. From Lemma 8 follows that there is an execution

∅ F 1 -→S 1 F 2 -→ . . . F n ′ --→S n ′ → * S ∈ exec msr E ( P ) such that !K(t) ∈ E S and S n ′ → * R S for R = { MDOut, MDPub, MDFresh, MDAppl }.
From S, we can go one further step using MDIn, since !K(t) ∈ S:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ --→ P S n ′ -→ * R⊂ P S = S n ′ +s-1 K(t) ---→ P S n ′ +s ∈ exec msr ( P )
where Case:

S n ′ +s = S ∪ {In(t)}. From the fact that S f (n-1) → * R S f (n) = S,
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { out(t, t ′ ); Q }, σ n-1 , L n-1 ) K(t) ---→(E n-1 , S n-1 , S MS n-1 , P ′ ∪ # { Q }, σ n-1 ∪{ t ′ / x }, L n-1
). This step requires that x is fresh and νE n-1 .σ ⊢ t. Using Lemma 8, we have that there is an execution

∅ F 1 -→S 1 F 2 -→ . . . F f (n) ---→S f (n-1) → * S ∈ exec msr E ( P ) such that !K(t) ∈ E S and S f (n-1) → * R S for R = { MDOut, MDPub, MDFresh, MDAppl }.
Let p and t such that {out(t, t ′ ); Q} ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. From the definition of P =p , we see that we can choose ri = [state p ( t),

In(t)] -[InEvent(t)]→ [Out(t ′ ), state p•1 ( t)].
To apply this rule, we need the fact In(t). Since νE n-1 .σ ⊢ t, as mentioned before, we can apply Lemma 8. It follows that there is an execution

∅ F 1 -→S 1 F 2 -→ . . . F n ′ --→S n ′ → * S ∈ exec msr E ( P ) such that !K(t) ∈ E S and S n ′ → * R S for R = { MDOut, MDPub, MDFresh, MDAppl }.
From S, we can now go two steps further, using MDIn and ri :

∅ F 1 -→ P S 1 . . . F n ′ -→ P S n ′ → * R⊂ P S = S n ′ +s-2 K(t) ---→ P S n ′ +s-1 InEvent(t)
------→ P S n ′ +s ∈ exec msr ( P )

where

S n ′ +s-1 = S ∪ # { In(t) } # and S f (n) = S \ # { state p ( t) } ∪ # { Out(t ′ ), state p•1 ( t) }.
Taking k = n ′ + s -1 we immediately obtain that Condition 8 holds. Note first that, since

S n ′ → R S, set(S n ′ ) \ { Fr(t), Out(t)|t ∈ M } ⊂ set(S) and set(S) \ { !K(t)|t ∈ M } ⊂ set(S n ′ ). Since P n = P n-1 \ {out(t, t ′ ); Q} ∪ {Q} and {Q} ↔ P {state p•1 ( t)
} (by definition of P =p ), we have that P n ↔ P S f (n) , i. e., Condition 4 holds. Condition 5 holds since t ′ was added to σ n-1 and Out(t) added to S f (n-1) . Condition 7 holds since K(t) appears right before InEvent(t). Condition 1, Condition 2, Condition 3 and Condition 6 hold trivially.

Case:

(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ {in(t, N ); Q}, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ # { Qθ }, σ n-1 , L n-1
). This step requires that θ is grounding for N and that νE n-1 .σ n-1 ⊢ t, N θ . Using Lemma 8, we have that there is an execution

∅ F 1 -→S 1 F 2 -→ . . . F f (n-1) -----→S f (n-1) → * S ∈ exec msr E ( P ) such that !K(t) ∈ E S and S f (n-1) → * R S for R = { MDOut, MDPub, MDFresh, MDAppl }.
The same holds for N θ. We can combine those executions, by removing duplicate instantiations of Fresh, MDFresh and MDOut. (This is possible since !K is persistent.) Let

∅ F 1 -→S 1 F 2 -→ . . . F f (n-1) -----→S f (n-1) → *
R S ∈ exec msr E ( P ) this combined execution, and !K(t), !K(N θ) ∈ E S. Let p and t be such that, in(t, N ); Q ↔ P state p ( t). By Definition 20 there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. From the definition of P =p and the fact that θ is grounding for N θ, we have state p ( t) in their premise, namely,

ri = [state p ( t), In( t, N θ )] -[InEvent( t, N θ )]→ [state p•1 ( t ∪ (vars(N )θ)].
From S n ′ , we can first apply the above transition S n ′ → * R S, and then, (since !K(t), !K(N θ), state p (x) ∈ S), MDAppl for the pair constructer, MDIn and ri :

∅ F 1 -→ P S 1 . . . F n ′ -→ P S n ′ → * R⊂ P S = S n ′ +s-3 (MdAppl)
------→ P S n ′ +s-2

K( t,N θ ) ------→ P S n ′ +s-1 InEvent( t,N θ )
----------→ P S n ′ +s ∈ exec msr ( P ), where

• since S n ′ → R S, S is such that set(S n ′ ) \ { Fr(t), Out(t)|t ∈ M } ⊆ set(S), set(S) \ { !K(t)|t ∈ M } ⊆ set(S n ′ ), and !K(t), !K(N θ) ∈ S • S n ′ +s-2 = S ∪ # { !K( t, N θ ) } # , • S n ′ +s-1 = S ∪ # { In( t, N θ ) } # , • S n ′ +s = S \ # { state p ( t) } ∪ # { state p•1 ( t ∪ (vars(N )θ)) }.
Letting k = n ′ + s -1 we immediately have that Condition 8 holds. We now show that Condition 4 holds. Since by induction hypothesis, in(t, N ); Q ↔ P state p ( t), we have that P | p τ = in(t, N ); Qρ for some τ and ρ. Therefore we also have that P | p•1 τ ∪ (θρ) = Qρ(θρ) and it is easy to see from definition of P =p that {Qθ} ↔ P {state p•1 ( t, (vars(N )θ))}. Since Case: (E, S, S MS , P ∪{out(c, m); Q}∪{in(c ′ , N ); R}, σ, L) → (E, S, S MS , P ∪{ Q, Rθ }, σ, L). This step requires that θ grounding for N , t = E N θ and c = E c ′ . Let p, p ′ and t, Ñ such that {out(c, m); P } ↔ P state p ( t), {in(c ′ , N ); Q} ↔ P state p ′ ( t′ ), and there are ri ∈ ginsts( P =p ) and ri ′ ∈ ginsts( P =p ′ ) such that state p ( t) and state p ′ ( t′ ) are part of their respective premise. From the definition of P =p and the fact that θ is grounding for N , we have:

P n = P n-1 \ # {in(t, N ); Q} ∪ # {Q}, we have that P n ↔ P S f (n) , i.
ri 1 = [state p ( t)] → [Msg(t, N θ), state semi p•1 ( t)] ri 2 = [state p ′ ( t′ ), Msg(t, N θ)] → [state p ′ •1 ( t′ ∪ (vars(N )θ)), Ack(t, N θ)] ri 3 = [state semi p ( t), Ack(t, N θ)] → [state p•1 ( t)].
This allows to extend the previous execution by 3 steps:

∅ F 1 -→ P S 1 . . . F n ′ -→ P S n ′ (ri 1 ) → P S n ′ +s-2 (ri 2 ) → P S n ′ +s-1 (ri 2 ) → P S n ′ +s ∈ exec msr ( P )
where:

• S n ′ +s-2 = S n ′ \ # { state p ( t) } ∪ # { Msg(t, N θ), state semi p•1 ( t) } # , • S n ′ +s-1 = S n ′ \ # { state p ( t), state p ′ ( t′ ) } ∪ # { state semi p•1 ( t), state p ′ •1 ( t′ ∪ (vars(N )θ)), Ack(t, N θ) } # , • S n ′ +s = S n ′ \ # { state p ( t), state p ′ ( t′ ) } ∪ # { state p•1 ( t), state p ′ •1 ( t′ ∪ (vars(N )θ)) }.
We have that Case:

P n = P n-1 \ # { out(c, m); Q, in(c ′ , t ′ ); R } ∪ # { Q, Rθ } # .
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { if t = t ′ then Q else Q ′ }, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ { Q }, σ n-1 , L n-1
). This step requires that t = E t ′ . By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that if t = t ′ then Q else Q ′ ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[Eq(t, t ′ )]→ [state p•1 ( t)]. We can extend the previous execution by one step using ri , therefore:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ Eq(t,t ′ ) ----→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = { S n ′ \ # { state p ( t) } # ∪ # { state p•1 ( t) } # }.
It is left to show that Conditions 1 to 8 hold for n. The last step is labelled F f (n) = { Eq(t, t ′ ) } # . As t = E t ′ , Condition 7 holds, in particular, α eq is not violated. Since Eq is reserved, Condition 8 holds as well.

As before, since Case:

P n = P n-1 \ # { if t = t ′ then Q else Q ′ } ∪ # {Q} and {Q} ↔ {state p•1 ( t,
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { if t = t ′ then Q ′ else Q }, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪{ Q ′ }, σ n-1 , L n-1
). This step requires that t = E t ′ . This proof step is similar to the previous case, except ri is chosen to be

[state p ( t)] -[NotEq(t, t ′ )]→ [state p•2 ( t)].
The condition in α noteq holds since t = E t ′ .

Case:

(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { event(F );Q }, σ n-1 , L n-1 ) F -→(E n-1 , S n-1 , S MS n-1 , P ′ ∪{ Q }, σ n-1 , L n-1 )
. By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that event(F );Q ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[F, Event()]→ [state p•1 ( t)]. We can extend the previous execution by one step using ri , therefore: Case:

∅ F 1 -→ P S 1
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { insert t, t ′ ; Q }, σ n-1 , L n-1 ) → (E n-1 , S n = S n-1 [t → t ′ ], S MS n-1 , P ′ ∪ { Q }, σ n-1 , L n-1
( t)] -[Insert(t, t ′ )]→ [state p•1 ( t)].
We can extend the previous execution by one step using ri , therefore:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ Insert(t,t ′ ) ------→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n-1) \ # { state p ( t) } # ∪ # { state p•1 ( t) } # . It is left to show that Conditions 1 to 8 hold for n.
This step is labelled F f (n) = Insert(t, t ′ ), hence Condition 8 holds. To see that Condition 2 holds we let j = f (n) for which both conjuncts trivially hold. Since, by induction hypothesis, Condition 7 holds, i.e., [F 1 , . . . F n ′ ] α, it holds for this step too. In particular, if [F 1 , . . . F n ′ ] α in and [F 1 , . . . F n ′ ] α notin , we also have that [F 1 , . . . F n ′ , F f (n) ] α in and [F 1 , . . . F n ′ , F f (n) ] α notin : as the Insert-action was added at the last position of the trace, it appears after any InIn or IsNotSet-action and by the semantics of the logic the formula holds.

Since Case:

P n = P n-1 \ # { insert t, t ′ ; Q } ∪ # { Q } and
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { delete t; Q }, σ n-1 , L n-1 ) → (E n-1 , S n = S n-1 [t → ⊥], S MS n-1 , P ′ ∪ { Q }, σ n-1 , L n-1 )
. By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that delete t; Q ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[Delete(t)]→ [state p•1 ( t)]. We can extend the previous execution by one step using ri , therefore:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ Delete(t) -----→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n-1) \ # {state p ( t)} ∪ # {state p•1 ( t)}.
It is left to show that Conditions 1 to 8 hold for n.

This step is labelled F f (n) = Delete(t), hence Condition 8 holds. Since, by induction hypothesis, Condition 7 holds, i.e., [F 1 , . . . F n ′ ] α, it holds for this step too. In particular, if [F 1 , . . .

F n ′ ] α in and [F 1 , . . . F n ′ ] α notin , we also have that [F 1 , . . . F n ′ , F f (n) ] α in and [F 1 , . . . F n ′ , F f (n)
] α notin : as the Insert-action was added at the last position of the trace, it appears after any InIn or IsNotSet-actions and by the semantics of the logic the formula holds.

We now show that Condition 2 holds. We have that S n = S n-1 [t → ⊥] and therefore, for all t ′ = E T t, S n (x) = S n-1 (x). Hence for all such t ′ we have by induction hypothesis that for some u,

∃j ≤ n ′ .Insert(t ′ , u) ∈ F j ∧ ∀j ′ , u ′ .j < j ′ ≤ n ′ → Insert(t ′ , u ′ ) ∈ E F j ′ ∧ Delete(t ′ ) ∈ E F j ′
As, F n ′ +1 = E Delete(x, u) and, for all u ′ ∈ M, F n ′ +1 = E Insert(x, u ′ ) we also have that

∃j ≤ n ′ + 1.Insert(t ′ , u) ∈ F j ∧ ∀j ′ , u ′ .j < j ′ ≤ n ′ + 1 → Insert(t ′ , u ′ ) ∈ E F j ′ ∧ Delete(t ′ ) ∈ E F j ′ .
For t ′ = E t, the above condition can never be true, because F n ′ +1 = Delete(t) which allows us to conclude that Condition 2 holds.

Since Case:

P n = P n-1 \ # { delete t; Q } ∪ # { Q } and {P } ↔ {state p•1 ( t)} (
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { lookup t as x in Q else Q ′ }, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ { Q{v/x} }, σ n-1 , L n-1
). This step requires that S n-1 (t ′ ) = E v for some t ′ = E t. By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that lookup t as v in Q else Q ′ ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[IsIn(t, v)]→ [state p•1 ( t, v)]. We can extend the previous execution by one step using ri , therefore:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ IsIn(t,v) -----→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n-1) \ # {state p ( t)} ∪ # {state p•1 ( t)}.
It is left to show that Conditions 1 to 8 hold for n.

This step is labelled F f (n) = IsIn(t, v), hence Condition 8 holds.

From the induction hypothesis, Condition 2, we have that there is a j such that Insert(t,

t ′ ) ∈ E F j , j ≤ n ′ and ∀j ′ , u ′ . j < j ′ ≤ n ′ → Insert(t, u ′ ) ∈ E F j ′ ∧ Delete(t) ∈ E F j ′
This can be strengthened, since

F f (n) = { IsIn(t, v) }: ∀j ′ , u ′ . j < j ′ ≤ f (n) → Insert(t, u ′ ) ∈ E F j ′ ∧ Delete(t) ∈ E F j ′
This allows to conclude that Condition 2 holds. From Condition 2 it also follows that Condition 7, in particular α in , holds. We now show that Condition 4 holds. By induction hypothesis we have that lookup t as x in Q else Q ′ ↔ P state p ( t), and hence P | p τ = (lookup t as x in Q else Q ′ )ρ for some τ and ρ. Therefore we also have that P | p•1 τ ∪ ({ vρ / x }) = Qρ{ vρ / x }) and it is easy to see from definition of Case:

P =p that {Q{ v / x }} ↔ P {state p•1 ( t, v)}. Since P n = P n-1 \ # { lookup t as x in Q else Q ′ } ∪ # { Q{ v / x } } we have that P n ↔ P S f (n) , i.
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { lookup t as x in Q else Q ′ }, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ { Q ′ }, σ n-1 , L n-1
). This step requires that S(t ′ ) is undefined for all t ′ = E t. By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that lookup t as x in Q else Q ′ ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[IsNotSet(t)]→ [state p•1 ( t)]. We can extend the previous execution by one step using ri , therefore:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ IsNotSet(t)
-------→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n-1) \ # state p ( t) ∪ # state p•1 ( t). It is left to show that Conditions 1 to 8 hold for n.

This step is labelled F f (n) = IsNotSet(t), hence Condition 8 holds. Condition 2 also holds trivially and will be used to show Condition 7. Since this step requires that S(t ′ ) is undefined for all t ′ = E t, we have by Condition 2 that

∀j ≤ f (n), u. Insert(t, u) ∈ E F j → ∃j ′ , u ′ .j < j ′ ≤ f (n) ∧ (Insert(t, u ′ ) ∈ E F j ′ ∨ Delete(t) ∈ E F j ′ ) Now suppose that ∃i ≤ f (n), y.Insert(t, y) ∈ E F i )
As there exists an insert, there is a last insert and hence we also have

∃i ≤ f (n), y.Insert(t, y) ∈ E F i ∧ ∀i ′ , y ′ .i < i ′ ≤ f (n) → Insert(t, y ′ ) / ∈ E F i ′ Applying Condition 2 (cf above) we obtain that ∃i ≤ f (n), y.Insert(t, y) ∈ E F i ∧ ∀i ′ , y ′ . i < i ′ ≤ f (n) → Insert(t, y ′ ) / ∈ E F i ′ ∧ ∃j ′ , u ′ . i < j ′ ≤ f (n) ∧ (Insert(t, u ′ ) ∈ E F j ′ ∨ Delete(t) ∈ E F j ′ ) which simplifies to ∃i ≤ f (n), y.Insert(t, y) ∈ E F i ∧ ∀i ′ , y ′ . i < i ′ ≤ f (n) → Insert(t ′ , y ′ ) / ∈ F i ′ ∧ ∃j ′ . i < j ′ ≤ f (n) ∧ Delete(t) ∈ E F j ′
Now we weaken the statement by dropping the first conjunct and restricting the quantification ∀i

′ .i < i ′ ≤ f (n) to ∀i ′ .j ′ < i ′ ≤ f (n), since i < j ′ . ∃i ≤ f (n). ∃j ′ . i < j ′ ≤ f (n) ∧ ∀i ′ . j ′ < i ′ ≤ f (n) → Insert(t ′ , y ′ ) / ∈ F i ′ ∧ Delete(t) ∈ E F j ′
We further weaken the statement by weakening the scope of the existential quantification ∃j

′ . i < j ′ ≤ f (n) to ∃j ′ . j ′ ≤ f (n). Afterwards, i is not needed anymore. ∃j ′ . j ′ ≤ f (n) ∧ ∀i ′ . j ′ < i ′ ≤ f (n) → Insert(t ′ , y ′ ) / ∈ F i ′ ∧ Delete(t) ∈ E F j ′
This statement was obtained under the hypothesis that ∃i ≤ f (n), y.Insert(t, y) ∈ E F i ). Hence we have that

∀i ≤ f (n), y.Insert(t, y) ∈ E F i ∨∃j ′ ≤ f (n). Delete(t) ∈ E F j ′ ∧ ∀i ′ . j ′ < i ′ ≤ f (n) → Insert(t ′ , y ′ ) / ∈ F i ′
This shows that Condition 7, in particular α notin , holds.

Since Case:

P n = P n-1 \ # { lookup t as x in Q else Q ′ } ∪ # { Q ′ }
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { lock t; Q }, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ # { Q ′ }, σ n-1 , L n-1 ∪{ t })
. This step requires that for all t ′ = E t, t ′ / ∈ L n-1 . Let p and t such that lock t; Q ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [Fr(l), state p ( t)] -[Lock(l, t)]→ [state p•1 ( t, l)] for a fresh name l, that never appeared in a Fr-fact in ∪ j≤f (n-1) S j . We can extend the previous execution by s = 2 steps using an instance of Fresh for l and ri :

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ -→ { fresh } S n ′ +s-1 Lock(l,t) -----→ P S n ′ +s ∈ exec msr ( P ) with S n ′ +s-1 = S f (n-1) \ # { state p ( t) } # ∪ # { Fr(l) } and S n ′ +s = S f (n-1) \ # { state p ( t) } # ∪ # { state p•1 ( t) } # .
It is left to show that Conditions 1 to 8 hold for n.

The step from S f (n)-1 to S f (n) is labelled F f (n) = Lock(l, t), hence Condition 8 and Condition 2 hold.

F f (n) also preserves Condition 6 for the new set of active locks

L f (n) = L f (n-1) ∪ { t }.
In the following we show by contradiction that α lock , and therefore Condition 7 holds. α lock held in the previous step, and F f (n-1)+1 is empty, so we assume (by contradiction), that F f (n) = Lock(l, t) violates α lock . If this was the case, then:

∃i < f (n), l 1 . Lock(l 1 , t) ∈ E F i ∧ ∧ ∀j. i < j < f (n) → Unlock(l 1 , t) ∈ E F j ∨ ∃l 2 , k. i < k < j ∧ (Lock(l 2 , t) ∈ E F k ∨ Unlock(l 2 , t) ∈ E F k ) (2)
Since the semantics of the calculus requires that for all t ′ = E t, t ′ / ∈ L n-1 , by induction hypothesis, Condition 6, we have that

∀i < f (n -1), l 1 . Lock(l 1 , t) ∈ E F i → ∃j. i < j < f (n -1) ∧ Unlock(l 1 , t) ∈ E F j Since F f (n-1)+1 = ∅ and f (n) = f (n -1) + 2, we have: ∀i < f (n), l 1 .Lock(l 1 , t) ∈ E F i → ∃j. i < j < f (n) ∧ Unlock(l 1 , t) ∈ E F j
We apply Proposition 4 for the total order > on the integer interval i + 1..f (n) -1:

∀i < f (n), l 1 . Lock(l 1 , t) ∈ E F i → ∃j. i < j < f (n) ∧ Unlock(l 1 , t) ∈ E F j ∧ ∀k. i < k < j → Unlock(l 1 , t) ∈ E F k Combining this with (2) we obtain that ∃i < f (n), l 1 . Lock(l 1 , t) ∈ E F i ∧ ∃j. i < j < f (n) ∧ Unlock(l 1 , t) ∈ E F j ∧ ∃l 2 , k. i < k < j ∧ (Lock(l 2 , t) ∈ E F k ∨ (Unlock(l 2 , t) ∈ E F k ∧ l 2 = E l 1 ))
Fix i < f (n), j such that i < j < f (n), and l 1 such that Lock(l 1 , t) ∈ E F i and Unlock(l 1 , t) ∈ E F j . Then, there are l 2 and k such that i < k < j and either Lock(l 2 , t) ∈ E F k or Unlock(l 2 , t) ∈ E F k , but l 2 = E l 1 . We proceed by case distinction. Case 1: there is no unlock in between i and j, i. e., for all m, i < m < j, Unlock(l ′ , t) ∈ F m . Then there is a k and l 2 such that Lock(l 2 , t) ∈ E F k . In this case, α lock is already invalid at the trace produced by the k-prefix of the execution, contradicting the induction hypothesis. Case 2: there are l ′ and m, i < m < j such that Unlock(l ′ , t) ∈ F m (see Figure 17).

We first observe that for any l, u, i 1 , i 2 , if Unlock(l, u) ∈ E F i 1 and Unlock(l, u) ∈ E F i 2 , then i 1 = i 2 . We proceed by contradiction. By definition of P and well-formedness of P , the steps from i 1 - and from i 2 -1 to i 2 must be ground instances of rules P =q and P =q ′ such that P | q and P | q ′ start with unlock commands that are labelled the same and have the same parameter, since every variable lock l in P appears in a Fr-fact in the translation for the corresponding lock command. By definition of P , this means q and q ′ have a common prefix q l that starts with a lock with this label.

1 to i 1 i Lock(l 1 , t) m Unlock(l ′ , t) j Unlock(l 1 , t)
Let q l ≤ q denote that q l is a prefix of q. Since P gives ⊥ if there is a replication or a parallel between q l and q or q ′ , and since P is well-formed (does not contain ⊥), we have that every state fact state r for q l ≤ r ≤ q or q l ≤ r ≤ q ′ appearing in P is a linear fact, since no replication is allowed between q l and q or q ′ . This implies that q ′ = q. Furthermore, every rule in ∪ q l ≤r≤q∨q l ≤r≤q ′ P =r adds at most one fact state r and if it adds one fact, it either removes a fact state r ′ where r = r ′ • 1 or r ′ • 2, or removes a fact state semi r ′ where r = r ′ • 1, which in turn requires removing state r ′ (see translation of out). Therefore, either q ≤ q ′ or q ′ ≤ q. But this implies that both have different labels, and since P =q l requires Fr(l), and E distinguishes fresh names, we have a contradiction. (A similiar observation is possible for locks: For any l, u, i 1 , i 2 , if Lock(l, u) ∈ E F i 1 and Lock(l, u) ∈ E F i 2 , then i 1 = i 2 , since by definition of the translation, the transition from i 1 -1 to i 1 or i -2 -1 to i 2 removes fact Fr(l).)

From the first observation we learn that , l ′ = E l 1 for any l ′ and m, i < m < j such that Unlock(l ′ , t) ∈ F m . We now choose the smallest such m. By definition of P , the step from S m-1 to S m must be ground instance of a rule from P =q for P | q starting with unlock. Since P is well-formed, there is a q l such that P | q l starts with lock, with the same label and parameter as the unlock. As before, since P is well-formed, and therefore there are no replications and parallels between q l and q, there must be n such that Lock(l ′ , t) ∈ F n and n < m. We proceed again by case distinction. Case 2a: n < i (see Figure 14). By the fact that m > i we have that there is no o such that n < o < i and Unlock(l ′ , t) ∈ E F o (see first observation). Therefore, the trace produced by the i-prefix of this execution does already not satisfy α lock , i. e., [F 1 , . . . , Case 2b: i < n (see Figure 15). Again, α lock is not satisfied, i.e., [F 1 , . . . , F n ] α lock , since there is no o such that i < o < n and Unlock(l Since we could, under the assumption that Condition 1 to Condition 8 hold for i ≤ n ′ , reduce every case in which [F 1 , . . . , F n ′ +1 ] α lock to a contradiction, we can conclude that Condition 7 holds for n ′ + 1.

F i ] α lock . n Lock(l ′ , t) i Lock(l 1 , t) m Unlock(l ′ , t) j Unlock(l 1 , t)
1 , t) ∈ E F o . i Lock(l 1 , t) n Lock(l ′ , t) m Unlock(l ′ , t) j Unlock(l 1 , t)
Since Case: We can extend the previous execution by one step using ri , therefore:

P n = P n-1 \ # { lock t; Q }∪ # { Q } and {Q} ↔ {state p•1 ( t)} (
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { unlock t; Q }, σ n-1 , L n-1 ) → (E n-1 , S n-1 , S MS n-1 , P ′ ∪ # { Q ′ }, σ n-1 , L n-1 \ { t ′ : t ′ = E t }).
∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ Unlock(l,t) ------→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n-1) \ # {state p ( t)} ∪ # {state p•1 ( t)}.
It is left to show that Conditions 1 to 8 hold for n.

The step from S f (n-1) to S f (n) is labelled F f (n) = Unlock(l, t), hence Condition 8 and Condition 2 hold.

In order to show that Condition 6 holds, we perform a case distinction. Assume t ∈ E ∈ L n-1 . Then, L f (n-1) = L f (n) . In this case, Condition 6 holds by induction hypothesis. In the following, we assume t ∈ E L n-1 . Thus, there is j ∈ n ′ , l ′ such that Lock(l ′ , t) ∈ E F j and for all k such that j < k ≤ n ′ , Unlock(l ′ , t) ∈ E F k .

Since P | p is an unlock node and P is well-formed, there is a prefix q of p, such that P | q is a lock with the same parameter and annotation. By definition of P , there is no parallel and no replication between q and p. Note that any rule in P that produces a state named state p for a non-empty p is such that it requires a fact with name state p ′ for p = p ′ • 1 or p = p ′ • 2 (in case of the translation of out, it might require state semi p ′ , which in turn requires state p ′ ). This means that, since state p ( t) ∈ S n ′ , there is an i such that state q ( t′ ) ∈ S i and state q ( t′ ) ∈ S i-1 for t′ a prefix to t. This rule is an instance of P =q and thus labelled F i = Lock(l, t). We proceed by case distinction. Case 1: j < i (see Figure 16). By induction hypothesis, Condition 7 holds for the trace up to n ′ . But, [F 1 , . . . , F i ] α lock , since we assumed that for all k such that j Case 2: i < j (see Figure 17). As shown in the lock case, any k such that Unlock(l, t) ∈ E F k is k = n ′ + 1. This contradicts Condition 7 for the trace up to j, since [F 1 , . . . , F j ] α lock , because there is not k such that i < k < j such that Unlock(l, t) ∈ E F k . This concludes the proof that Condition 6 holds for n + 1.

j Lock(l ′ , t) i Lock(l, t) n ′ + 1 Unlock(l, t)
< k ≤ n ′ , Unlock(l ′ , t) ∈ E F k . i Lock(l, t) j Lock(l ′ , t) n ′ + 1 Unlock(l, t)
Condition 7 holds, since none of the axioms, in particular not α lock , become unsatisfied if they were satisfied for the trace up to f (n -1) and an Unlock is added.

Since Case:

P n = P n-1 \ # { unlock t; Q } ∪ # { Q } and {Q} ↔ {state p•1 ( t)} (
(E n-1 , S n-1 , S MS n-1 , P n-1 = P ′ ∪ { l -[a]→ r; Q }, σ n-1 , L n-1 ) a -→ (E n-1 , S n-1 , S MS n-1 \ lfacts(l ′ ) ∪ # mset(r), P ′ ∪ # { Q }, σ n-1 , L n-1 ). This step requires that l ′ -[a ′ ]→ r ′ ∈ E ginsts(l -[a]→ r) and lfacts(l ′ ) ⊂ # S MS n-1 , pfacts(l ′ ) ⊂ mset(S MS n-1 ). Let θ be a substitution such that (l -[a]→ r)θ = (l ′ -[a ′ ]→ r ′ ). Since,

by induction hypothesis, S MS

n-1 = S n ′ \ # F res , we therefore have lfacts(l ′ ) ⊂ # S n ′ , pfacts(l ′ ) ⊂ mset(S n ′ ). By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that l -[a]→ r; Q ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t), l ′ ] -[a ′ , Event()]→ [r ′ , state p•1 ( t ∪ (vars(l)θ))]. We can extend the previous execution by one step using ri , therefore:

∅ F 1 -→ P S 1 F 2 -→ P . . . F n ′ -→ P S n ′ a ′ ,Event() ------→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S f (n-1) \ # { state p ( t) } # \ # lfacts(l ′ ) ∪ # { state p•1 ( t ∪ (vars(l)θ)) } # ∪ # mset(r ′ ).
It is left to show that Conditions 1 to 8 hold for n.

Condition 3 holds since

S MS n = S MS n-1 \ # lfacts(l ′ ) ∪ # mset(r) = (S n ′ \ # F res ) \ lfacts(l ′ ) ∪ # mset(r) (induction hypothesis) = (S n ′ \ # lfacts(l ′ ) ∪ # mset (r) \ # { state p ( t) } # ∪ # { state p•1 ( t ∪ (vars(l)θ)) } # ) \ # F res (since state p ( t), state p•1 ( t ∪ (vars(l)θ)) ∈ F res ) = S f (n) \ # F res
The step from S f (n-1) to S f (n) is labelled F f (n) = a, and does not contain actions in F res , since P is well-formed. Hence Condition 2, Condition 6, Condition 7 and Condition 8 hold.

Since 3. if for some i and t 1 , t 2 ∈ M, Ack(t 1 , t 2 ) ∈ (S i-1 \ # S i ), then there are p and q such that:

P n = P n-1 \ # { l -[a]→ r; Q } ∪ # { Q } and
S i-3 -→ R 1 S i-2 -→ R 2 S i-1 -→ R 3 S i , where: • R 1 = [state p (x)] → [Msg(t 1 , t 2 ), state semi p (x)] • R 2 = [state q (ỹ), Msg(t 1 , t 2 )] → [state q•1 (ỹ ∪ ỹ′ ), Ack(t 1 , t 2 )] • R 3 = [state semi p (x), Ack(t 1 , t 2 )] → [state p•1 (x)]. 4. S n-1 En --→ P,[],[] ,MDIn,Init S n 5. if In(t) ∈ (S i-1 \ # S i ) for some i and t ∈ M, then S i-2 K(t) ---→ MDIn S i-1 6. if n ≥ 2 and no Ack-fact in (S i-1 \ # S i ), then there exists m < n such that S m → * R S n-1 for R = { MDOut, MDPub, MDFresh, MDAppl } ∪ Fresh and ∅ E 1 -→ P • • • Em --→ P S m ∈ exec msr ( P ) is normal. 7. if for some t 1 , t 2 ∈ M, Ack(t 1 , t 2 ) ∈ (S n-1 \ # S n ), then there exists m ≤ n -3 such that S m → * R S n-3 for R = { MDOut, MDPub, MDFresh, MDAppl } ∪ Fresh and ∅ E 1 -→ P • • • Em --→ P S m ∈ exec msr ( P ) is normal.
Lemma 11 (Normalisation). Le P be a well-formed ground process. If

S 0 = ∅ E 1 -→ P S 1 E 2 -→ P . . . En -→ P S n ∈ exec msr ( P )
and [E 1 , . . . , E n ] α, then there exists a normal msr execution

T 0 = ∅ F 1 -→ P T 1 F 2 -→ P . . . F n ′ -→ P T n ′ ∈ exec msr ( P ) such that hide([E 1 , . . . , E n ]) = hide(F 1 , . . . , F n ′ ) and [F 1 , . . . , F n ′ ] α.
Proof. We will modify S 0 E 1 -→ P . . .

En

-→ P S n by applying one transformation after the other, each resulting in an msr execution that still fulfills the conditions on its trace. m > 1, and therefore 1. 3 holds for all parts of the trace, and therefore also for the m prefix. Similar for 5.

Since we can literally apply the same argument for the largest m < m such that

S (5) m-1 E (5) m ---→ P,[],[] ,
Init,MDIn S (5) m or, in case that there is an Ack-fact in S m , for the largest m < m -2, can show that 6 and 7 hold for the trace up to m or m ′ , concluding it is normal.

Definition 22. Let P be a ground process, P be a multiset of processes and S a multiset of multiset rewrite rules. We write P P S if there exists a bijection between P and the multiset {state p ( t) | ∃p, t. state p ( t) ∈ # S} # such that whenever Q ∈ # P is mapped to state p ( t) ∈ # S, then:

1. state p ( t) ∈ E prems(R) for R ∈ ginsts( P =p ).

2. Let θ be a grounding substitution for state(x) ∈ prems( P =p ) such that t = xθ. Then

(P | p τ )ρ = E Q
for a substitution τ , and a bijective renaming ρ of fresh, but not bound names in Q, defined as follows: Definition 14), then there are (E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 ), . . . , (E n ′ , S n ′ , S MS n ′ , P n ′ , σ n ′ , L n ′ ) and F 1 , . . . , F n ′ such that:

τ (x) :=θ(x) if x not a reserved variable ρ(a) :=a ′ if θ(n a ) = a ′ When P P S, Q ∈ # P
(E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 )

F 1 -→ (E 1 , S 1 , S MS 1 , P 1 , σ 1 , L 1 ) F 2 -→ . . . F n ′ -→ (E n ′ , S n ′ , S MS n ′ , P n ′ , σ n ′ , L n ′ )
where (E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 ) = (∅, ∅, ∅, { P }, ∅, ∅) and there exists a monotonically increasing, surjective function f : N n \ { 0 } → N n ′ such that f (n) = n ′ and for all i ∈ N n Proof. We proceed by induction over the number of transitions n.

1. E f (i) = { a ∈ FN | ProtoNonce(a) ∈ E 1≤j≤i E j } 2. ∀ t ∈ M. S f (i) (t) =      u if ∃j ≤ i.Insert(t, u) ∈ E E j ∧∀j ′ , u ′ .j < j ′ ≤ i → Insert(t, u ′ ) ∈ E E j ′ ∧ Delete(t) ∈ E E j ′ ⊥ otherwise 3. S MS f (i) = E S i \ # F res 4. P f (i) P S i 5. { xσ f (i) | x ∈ D(σ f (i) ) } # = E { Out(t) ∈ ∪ k≤i S k } # 6. L f (i) = E { t |
Base Case. A normal msr execution contains at least an application of the init rule, thereby the shortest normal msr execution is

∅-→ P S 1 = { state [] () } #
We chose n ′ = 0 and thus (E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 ) = (∅, ∅, ∅, { P } # , ∅, ∅).

We define f : { 1 } → { 0 } such that f (1) = 0.

To show that Condition 4 holds, we have to show that P 0 P { state [] (s : fresh) } # . Note that P 0 = { P } # . We choose the bijection such that P

F ′ n -→ (E n ′ , S n ′ , S MS n ′ , P n ′ , σ n ′ , L n ′ )
fulfilling Conditions 1 to 8. Assume now for the following argument, that there is not fact with the symbol Ack in S n-1 \ # S n . This is the case for all cases except for the case where rule instance applied from S n-1 to S n has the form ri = [state semi p (s), Ack(t 1 , t 2 )] -[]→ [state p•1 (s)]. This case will require a similiar, but different argument, which we will present when we come to this case.

Since ∅ --→ P S m ∈ exec msr ( P ). Hence there is a monotonically increasing function from N m → N n ′ and an execution such that Conditions 1 to 8 hold. Let f p be this function and note that n ′ = f p (m).

In the following case distinction, we will (unless stated otherwise) extend the previous execution by one step from (E n ′ , S n ′ , S MS n ′ , P n ′ , σ n ′ , L n ′ ) to (E n ′ +1 , S n ′ +1 , S MS n ′ +1 , P n ′ +1 , σ n ′ +1 , L n ′ +1 ), and prove that Conditions 1 to 7 hold for n ′ + 1. By induction hypothesis, they hold for all i ≤ n ′ . We define a function f : N n → N n ′ +1 as follows:

f (i) :=      f p (i) if i ∈ N m n ′ if m < i < n n ′ + 1 if i = n with E n ′ +1 = E n ′ ∪ a ′ , S n ′ +1 = S n ′ , S MS n ′ +1 = S MS n ′ , P n ′ +1 = P n ′ \ # { ν a; Q ′ } # ∪ # { Q ′ { a / a ′ } } # , σ n ′ +1 = σ n ′ and L n ′ +1 = L n ′ .
We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P , state p•1 (x, a) ∈ prems(R ′ ) for an R ′ ∈ P =p•1 . We can choose θ ′ := θ[n a → a ′ ] and have state p•1 ( t, a ′ ) = state p•1 (x, a)θ ′ . Since Q = P | p τ ρ for τ and ρ induced by θ, Q ′ { a ′ / a } = P | p τ ′ ρ ′ for τ ′ and ρ ′ induced by θ ′ , i. e., τ ′ = τ and ρ ′ = ρ[a → a ′ ]. Therefore, Q ′ { a ′ / a } P state p•1 ( t, a ′ ). Condition 4 holds, since furthermore ν a ′ ; Q' ↔ state p ( t), P n ′ +1 = P n ′ \ # { ν a ′ ; Q' } # ∪ # { Q ′ { a ′ / a } } # , and S n = S n-1 \ # { Fr(a), state p ( t) } # ∪ # state p•1 ( t, a : fresh).

Condition 1, holds since E n ′ +1 = E n ′ ∪ a ′ , and E n = ProtoNonce (a ′ ). Condition 7 holds since ProtoNonce (a) ∈ F res .

Conditions 2, 3 and 5 hold trivially.

Case: ri = [state p ( t), In(t Let θ be a grounding substitution for state(x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since Q = P | p τ ρ, we can deduce that Q = out (t 1 , t 2 ); Q ′ for a process Q ′ = P | p•1 τ ρ.

From the induction hypothesis, and since E m+1 , . . . , E n-2 = ∅, we have that

E n ′ = { a ∈ FN | ProtoNonce (a) ∈ E 1≤j≤n-2 E j }.
From the induction hypothesis, and since no rule producing Out-facts is applied between step m and step n -2, we have that

{ xσ n ′ | x ∈ D(σ n ′ ) } # = E { Out(t) ∈ ∪ k≤n-2 S k } # . (3)
Let r = { a : fresh | RepNonce(a) ∈ 1≤j≤n-2 F j }. Since !K(t 1 ) ∈ prems(MDInσ) for σ(x) = t 1 , we have !K(t) ∈ E S n-2 . By Lemma 8 and Lemma 9, we have νE n ′ , r.σ n ′ ⊢ t. Therefore, νE n ′ .σ n ′ ⊢ t. We chose the following transition:

• • • F ′ n --→(E n ′ , S n ′ , S MS n ′ , P n ′ , σ n ′ , L n ′ ) K(t 1 ) ---→(E n ′ +1 , S n ′ +1 , S MS n ′ +1 , P n ′ +1 , σ n ′ +1 , L n ′ +1 ) with E n ′ +1 = E n ′ , S n ′ +1 = S n ′ , S MS n ′ +1 = S MS n ′ , P n ′ +1 = P n ′ \ # { out (t 1 , t 2 ); Q ′ } # ∪ # { Q ′ } # , σ n ′ +1 = σ n ′ ∪ { t 2 / x } and L n ′ +1 = L n ′ for a fresh x.
We define f as follows: Condition 5 holds since σ n ′ +1 = σ n ′ ∪ { t 2 / x }, and therefore: Definition 22). From the form of the rule R, and since Q = P | p τ ρ, we can deduce that Q = in (t 1 , N ); Q ′ , for N a term that is not necessarily ground, and a process Q ′ = P | p•1 τ ρ. Since ri ∈ E ginsts(R), we have that there is a substitution τ ′ such that N τ ′ = E t 2 .

f (i) :=      f p (i) if i ∈ N m n ′ if m < i < n -1 n ′ + 1 if i = n
{ xσ n ′ +1 | x ∈ D(σ n ′ +1 ) } # ={ xσ n ′ | x ∈ D(σ n ′ ) } # ∪ # { t 2 } # = E { Out(t) ∈ ∪ k≤n-2 S k } # ∪ # {
From the induction hypothesis, and since E m+1 , . . . , E n-2 = ∅, we have that

E n ′ = { a | ProtoNonce(a) ∈ 1≤j≤n-2 E j }.
From the induction hypothesis, and since no rule producing Out-facts is applied between step m and step n -2, we have that

{ xσ n ′ | x ∈ D(σ n ′ ) } # = { Out(t) ∈ ∪ k≤n-2 S k } # . (4)
Let r = { a : fresh | RepNonce(a) ∈ 1≤j≤n-2 F j }. Since !K(< t 1 , t 2 >) ∈ prems(MDInσ) for σ(x) =< t 1 , t 2 >, we have !K(< t 1 , t 2 >) E ∈ S n-2 . By Lemma 8 and Lemma 9, we have νE n ′ , r.σ n ′ ⊢< t 1 , t 2 >. Therefore, νE n ′ .σ n ′ ⊢< t 1 , t2 >. Using DEq and DAppl with the function symbols fst and snd , we have νE n ′ .σ n ′ ⊢ t 1 and νE n ′ .σ n ′ ⊢ t2. Therefore, we chose the following transition:

• • • F ′ n --→(E n ′ , S n ′ , S MS n ′ , P n ′ , σ n ′ , L n ′ ) K(t 1 )
---→(E n ′ +1 , S n ′ +1 , S MS n ′ +1 , P n ′ +1 , σ n ′ +1 , L n ′ +1 )

with

E n ′ +1 = E n ′ , S n ′ +1 = S n ′ , S MS n ′ +1 = S MS n ′ , P n ′ +1 = P n ′ \ # { in (t 1 , N ); Q ′ } # ∪ # { Q ′ τ ′ } # , σ n ′ +1 = σ n ′ and L n ′ +1 = L n ′ .
We define f as follows: Let θ ′ such that ri = θ ′ R. As established before, we have τ ′ such that N τ ′ = E t 2 . By definition of P =p , we have that state p•1 ( t, t′ ) ∈ E ginsts(P =p•1 ), and that θ ′ = θ • τ ′ . Since τ and ρ are induced by θ, θ ′ induces τ • τ ′ and the same ρ. We have that Q ′ τ ′ = (P | p•1 τ ρ)τ ′ = P | p τ τ ′ ρ and therefore Q ′ τ P state p•1 ( t, t′ ). Thus, and since in (t 1 , N ); Q ′ P state p ( t), P n ′ +1 = P n ′ \ # { in (t 1 , N ); Q ′ } # ∪ # { Q ′ τ ′ } # and S n = S n-1 \ # { In(< t 1 , t 2 >), state p ( t) } # ∪ # { state p•1 ( t, t′ ) } # , Condition 4 holds.

f (i) :=      f p (i) if i ∈ N m n ′ if m < i < n -1 n ′ + 1 if i = n
Conditions Condition 1, 2, 3 and 5 hold trivially.

Case: ri = [state semi p (s), Ack(t 1 , t 2 )] -[]→ [state p•1 (s)] (for some p, t and t 1 , t 2 ∈ M). Since the msr execution is normal, we have that there p,q,x, ỹ, ỹ′ such that:

S n-3 -→ R 1 S n-2 -→ R 2 S n-1 -→ R 3 S n
, where:

Figure 3 :

 3 Figure 3: Proof tree witnessing that ν ñ.σ ⊢ k 2

Figure 4 :

 4 Figure 4: Operational semantics

Figure 5 :

 5 Figure 5: Example of transitions modelling the creation of a key on a PKCS#11-like device

Figure 6 :

 6 Figure 6: The set of rules MD.

Figure 7 :

 7 Figure 7: Translation of processes: definition of P, p, x

Figure 8 :

 8 Figure 8: The set of multiset rewrite rules !P new (omitting the rules in MD)

Figure 9 :

 9 Figure 9: Example trace for the translation of !P new .

Figure 10 :

 10 Figure 10: Definition of α.

Definition 15 .

 15 Let α be the trace formula as defined in Definition 14 and Tr a set of traces. We define filter (Tr ) := {tr ∈ Tr | ∀θ.(tr, θ) α}

Definition 16 (

 16 hide). Given a trace tr and a set of facts F we inductively define hide([]) = [] and hide(F • tr ) := hide(tr ) if F ⊆ F res (F \ F res ) • hide(tr ) otherwise Given a set of traces Tr we define hide(Tr ) = {hide(t) | t ∈ Tr }.

Figure 11 :

 11 Figure 11: Case studies.

Definition 18 .

 18 We define P D := Init ∪ P , [], [] D , where P , [], [] D is defined just as P , [], [] , with

  trace (execs( P ∪ MD) DH e ¬α in ∨ ψ ⇔ trace (execs( P ∪ MD) DHe ¬α in ∨ φ (Lemma 3.7 (unaltered)) ⇔ trace (execs( P ∪ MD)) ↓ RDH e DH e ¬α in ∨ φ (Definition of DH e ) ⇔ trace (dgraphs DHe ( P ∪ MD)) ↓ RDHe DHe ¬α in ∨ φ (Lemma 3.10 (unaltered)) ⇔ trace ({dg | dg ∈ dgraphs ACC (⌈ P ∪ MD⌉ RDHe insts ) ∧dg ↓ RDH e -normal}) DH e ¬α in ∨ φ (Lemma 3.11 (unaltered)) ⇔ trace (ndgraphs ( P )) DHe ¬α in ∨ φ (Lemma A.12 (*)) ⇔ trace (ndgraphs ( P )) ACC ¬α in ∨ φ (Lemma 3.7 and A.20(both unaltered))

Tr

  ∀ ϕ ∀ ⇒ filter (Tr ) ∀ ϕ ∀ (since filter (Tr ) ⊆ Tr ) ⇔ filter (Tr ) ∀ α ⇒ ϕ (by definition of ϕ ∀ ) ⇔ filter (Tr ) ∀ ϕ (since filter (Tr ) ∀ α) We next show that filter (Tr ) ∀ ϕ implies Tr ∀ ϕ ∀ . filter (Tr ) ∀ ϕ ⇒ filter (Tr ) ∀ α ∧ ϕ (since filter (Tr ) ∀ α) ⇔ Tr ∀ ¬α ∨ (α ∧ ϕ) (since filter (Tr ) ⊆ Tr and (Tr \ filter (Tr )) ∀ α)

  ∀θ.∃θ ′ . if (tr , θ) ϕ then (hide(tr ), θ ′ ) ϕ and ∀θ.∃θ ′ . if (hide(tr ), θ) ϕ then (tr , θ ′ ) ϕ We will show both statements by a nested induction on |tr | and the structure of the formula. (The underlying well-founded order is the lexicographic ordering of the pairs consisting of the length of the trace and the size of the formula) If |tr | = 0 then tr = [] and tr = hide(tr ) which allows us to directly conclude letting θ ′ := θ. If |tr | = n, we define tr and F such that tr = tr • F . By induction hypothesis we have that ∀θ.∃θ ′ . if (tr , θ) ϕ then (hide(tr ), θ ′ ) ϕ and ∀θ.∃θ ′ . if (hide(tr ), θ) ϕ then (tr , θ ′ ) ϕ

Figure 12 :

 12 Figure 12: Definition of P, p, x =pt where {•} a ? =b = { • } if a = b and ∅ otherwise.

Condition 1 ,

 1 Condition 2, Condition 3, Condition 5, Condition 6, Condition 7 and Condition 8 hold trivially. To show that Condition 4 holds, we have to show that P 0 ↔ P { state [] () } # . Note that P 0 = { P } # . We choose the bijection such that P ↔ P state [] (). For τ = ∅ and ρ = ∅ we have that P | [] τ = P τ = P ρ. By Definition 19, P =[] = P, [], [] =[] . We see from Figure 12 that for every P we have that state [] () ∈ prems( P, [], [] =[] ). Hence, we conclude that there is a ground instance ri ∈ E ginsts( P =[] ) with state [] () ∈ prems(ri ).

  Condition 4 holds because P n = P n-1 ∪ # {Q} and {Q} ↔ P {state p•1 ( t)} (by definition of P =p ). Condition 1, Condition 2, Condition 3, Condition 5, Condition 6, Condition 7 and Condition 8 hold trivially.

  and the induction hypothesis, we can conclude that Condition 8 holds. Condition 4 holds since P n = P n-1 and no state-facts where neither removed nor added. Condition 1, Condition 2, Condition 3, Condition 5, Condition 6 and Condition 7 hold trivially.

  e., Condition 4 holds. Condition 7 holds since K t, N θ ) appears right before InEvent t, N θ ). Condition 1, Condition 2, Condition 3, Condition 5 and Condition 7 hold trivially.

  a)} (by definition of the translation), we have that P n ↔ P S f (n) , and therefore Condition 4 holds. Condition 1, Condition 2, Condition 3, Condition 5 and Condition 6 hold trivially.

F 2 -

 2 → P . . .

F

  n ′ -→ P S n ′ F,Event() ------→ P S n ′ +1 ∈ exec msr ( P ) with S n ′ +1 = S n ′ ) \ # {state p ( t)} ∪ # {state p•1 ( t)}. It is left to show that Conditions 1 to 8 hold for n. Condition 4 holds because P n = P n-1 \ # { event(F );Q }∪ # { Q } and {Q} ↔ {state p•1 ( t)} (by definition of P =p ). Taking k = f (n) Condition 8 holds. Condition 1, Condition 2, Condition 3, Condition 5, Condition 6 and Condition 7 hold trivially.

  {Q} ↔ {state p•1 ( t)} (by definition of P =p ), we have that Condition 4 holds. Condition 1, Condition 3, Condition 5 and Condition 6 hold trivially.

  by definition of P =p ), we have that Condition 4 holds. Condition 1, Condition 3, Condition 5 and Condition 6 hold trivially.

  e., Condition 4 holds. Condition 1, Condition 3, Condition 5 and Condition 6 hold trivially.

  and {Q ′ } ↔ {state p•1 ( t)} (by definition of P =p ), we have that Condition 4 holds. Condition 1, Condition 3, Condition 5 and Condition 6 hold trivially.

Figure 13 :

 13 Figure 13: Visualisation of Case 2.

Figure 14 :

 14 Figure 14: Visualisation of Case 2a.

Figure 15 :

 15 Figure 15: Visualisation of Case 2b.

  by definition of the translation), we have that Condition 4 holds. Condition 1, Condition 3 and Condition 5 hold trivially.

Figure 16 :

 16 Figure 16: Visualisation of Case 1.

Figure 17 :

 17 Figure 17: Visualisation of Case 2.

  by definition of the translation), we have that Condition 4 holds. Condition 1, Condition 3 and Condition 5 hold trivially.

1 -→ P S 1 E 2 - 1 -→ (E 1 ,F 2 -

 112112 P state [] (s : fresh). By Definition 19, P =[] = P, [], [] =[] . We see from Figure 12 that for every P we have that state [] (s : fresh) ∈ prems(Rθ), for R ∈ P, [], [] =[] and θ = ∅. This induces τ = ∅ and ρ = ∅. Since P | [] τ ρ = P , we have P P state [] (), and therefore P 0 P S 1 . Condition 1, Condition 2, Condition 3, Condition 5, Condition 6, and Condition 7 hold trivially.Inductive step. Assume the invariant holds for n -1 ≥ 1. We have to show that the lemma holds for n transitions, i. e., we assume that ∅ E → P . . .En-→ P S n ∈ exec msr ( P ) is normal and [E 1 , . . . , E n ] α. Then it is to show that there is (E 0 , S 0 , S MS 0 , P 0 , σ 0 , L 0 )F S 1 , S MS 1 , P 1 , σ 1 , L 1 ) → . . .

E 1 - 1 - 1 -

 111 → P • • • En --→ P S n ∈ exec msr ( P ) is normal and n ≥ 2, there exists m < n such that S m → * R S n for R = { MDOut, MDPub, MDFresh, MDAppl, Fresh } and ∅ E → P • • • Em --→ P S m ∈exec msr ( P ) is normal, too. This allows us to apply the induction hypothesis on ∅E → P • • • Em

Therefore, Conditions 1

 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.Condition 7 holds since hide([E 1 , . . . , E m ]) = E [F 1 , . . . , n ′ ], and [E m+1 , . . . , E n-1 ] = E [F n ′ +1 ], since E n-1 = K(t 1 ).

Therefore, Conditions 1

 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.Condition 7 holds since hide([E 1 , . . . , E m ]) = [F 1 , . . . , n ′ ], and [E m+1 , . . . , E n-1 ] = [F n ′ +1 ], since E n-1 = K(t 1 ).

  ⊥ au(if t 1 = t 2 then P else Q, t, l) := if t 1 = t 2 then au(P, t, l)

			else au(Q, t, l)
	au(lookup M as x in P else Q, t, l)	:=	lookup M as x in au(P, t, l) else au(Q, t, l)
	au(α; P , t, l) := α; au(P, t, l)
			where α = unlock t
	au(unlock t; P , t, l) := unlock l t; P
	au(0, t, l) := 0
	B Correctness of tamarin's solution procedure for translated rules

as x in P else Q α; P := α; P where α / ∈ { lock t, unlock t : t ∈ T } lock t; P := lock l t; au(P, t, l) where l ∈ N is a fresh label unlock l t; P := unlock l t; P unlock t; P := ⊥ where au(P, t, l) annotates the first unlock that has parameter t with the label l, i. e.: au(P |Q, t, l) := ⊥ au(!P , t, l) :=

  Fr(t) ∈ S n and applying rule MDFresh we have that S n → S = S n ∪ {!K(t)}, (iii) Fr(t) ∈ S n . By inspection of the rules we see that Fr(t) ∈ S i for any 1 ≤ i ≤ n: the only rules that could remove Fr(t) are MDFresh which would have created the persistent fact !K(t), or the ProtoNonce rules which would however have added t to ñ. Hence, applying successively rules Fresh and MDFresh yields a valid extension of the execution S n → S n ∪ {Fr(t)} → S = S n ∪ {!K(t)}.

• DName. We have that t ∈ ñ. If t ∈ PN we use rule MDPub and we have that

S n → S = S n ∪ {!K(t)}.

In case t ∈ FN we need to consider 3 different cases: (i) !K(t) ∈ S n and we immediately conclude (by letting S = S n ), (ii) • DFrame. We have that xσ = t for some x ∈ D(σ), that is, t ∈ {t 1 , . . . , t m }. By definition of {t 1 , . . . , t m }, Out(t) ∈ S i for some i ≤ n. If Out(t) ∈ S n we have that S n → S = (S n \ {Out(t)}) ∪ {!K(t)} applying rule MDOut. If Out(u) ∈ S n , the fact that the only rule in P that allows to remove an Out-fact is MDOut, suggests that it was applied before, and thus !K(u) ∈ S.

  It is left to show that Conditions 1 to 8 hold for n.

	Condition 1, Condition 2, Condition 3, Condition 5, Condition 6, Condition 7, and Condition 8
	hold trivially.
	Condition 4 holds because P ′

  and 0 ↔ P state p ( t) (see Remark 2).

  ). By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that Q|R ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p

  It is left to show that Conditions 1 to 8 hold for n. Condition 1, Condition 2, Condition 3, Condition 5, Condition 6, Condition 7 and Condition 8 hold trivially. We now show that Condition 4 holds. Condition 4 holds because P n = P n-1 \ # {Q|R} ∪ # {Q, R}, {Q} ↔ P {state p•1 (x)} and {R} ↔ P {state p•2 (x)} (by definition of the translation) (see Remark 2).

  ). By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that insert t, t ′ ; Q ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p

  By induction hypothesis P n-1 ↔ P S n ′ . Let p and t be such that unlock t; Q ↔ P state p ( t). By Definition 20, there is a ri ∈ ginsts( P =p ) such that state p ( t) is part of its premise. By definition of P =p , we can choose ri = [state p ( t)] -[Unlock(l, t)]→ [state p•1 ( t)].

  {Q} ↔ {state p•1 ( t ∪ (vars(l)θ))} (by definition of P =p ), we have that Condition 4 holds. Condition 1, and Condition 5 hold trivially. P S n ∈ exec msr ( P ) for the multiset rewrite system P defined by a ground process P is normal if:1. The first transition is an instance of the Init rule, i. e., S 1 = state [] () and there is at least this transition.

	Definition 21 (normal msr execution). A msr execution ∅ -→ P • • • E 1

En

--→ 2. S n neither contains any fact with the symbol state semi p for any p, nor any fact with symbol Ack.

  Note that P has the following properties (by the fact that it defines a bijection between multisets). • If P 1 P S 1 and P 2 P S 2 then P 1 ∪ # P 2 P S 1 ∪ # S 2 . • If P 1 P S 1 and Q P state p ( t) for Q ∈ P 1 and state p ( t) ∈ S 1 (i.e. Q and state p ( t) are related by the bijection defined by P 1 P S 1 ) then P 1 \ # {Q} P S 1 \ # {state p ( t)}. Lemma 12. Le P be a well-formed ground process. If S 0 = ∅ P S n ∈ exec msr ( P ) is normal (see Definition 21) and [E 1 , . . . , E n ] α (see

	Remark 3. E 1 -→ P S 1	E 2 -→ P . . .

and state p ( t) ∈ # S we also write Q P state p ( t) if this bijection maps Q to state p ( t). En -→

  ∃j ≤ i, u. Lock(u, t) ∈ E E j ∧ ∀j < k ≤ i.Unlock(u, t) ∈ E E k }. hide([E 1 , . . . , E n ]) = E [F 1 , . . . , F ′ n ].

	Furthermore,
	7.

  1 )] -[InEvent(t 1 )]→ [state p•1 ( t), Out(t 2 )] (for some p, t and t 1 , t 2 ∈ M).Since the msr execution is normal, we have that S n-2K(t 1 ) ---→ MDIn S n-1 . Since S 0 E 1 -→ P . . . ---→ P S n-2 .Hence there is an m < n -2 such S 0 P S m is a normal trace and S m → * R S n-1 for R = { MDOut, MDPub, MDFresh, MDAppl, Fresh }. By induction hypothesis, we have P n ′ P S m , and thus, since { MDOut, MDPub, MDFresh, MDAppl }and Fresh do not add or remove state-facts, P n ′ P S n-2 . Let Q ∈ # P n ′ such that Q P state p ( t).

					En --→ P S n
	is normal, so is S 0	E 1 -→ P . . .	E n-1 ---→ P S n-1 , and therefore S 0	E 1 -→ P . . .	E n-2
		E 1

-→ P . . . Em --→

  By definition of P and P =p , we have that Q ′ P state p•1 ( t). Therefore, and since out (t 1 , t 2 );Q ′ P state p ( t), P n ′ +1 = P n ′ \ # { out (t 1 , t 2 ); Q ′ } # ∪ # { Q ′ } # , and S n = E S n-1 \ # { In(a), state p ( t) } # ∪ # { state p•1 ( t), Out(t 2 ) }, Condition 4 holds. Conditions Condition 1, 2 and 3 hold trivially. Case: ri = [state p ( t), In(< t 1 , t 2 >)] -[InEvent( t 1 , t 2 )]→ [state p•1 ( t, t′ )] (for some p, t, t′ and t 1 , t 2 ∈ M). Since the msr execution is normal, we have that S n-2 K(t 1 ) ---→ MDIn S n-1 . Since S 0 E 1 -→ P . . . P S m is a normal trace and S m → * R S n-1 for R = { MDOut, MDPub, MDFresh, MDAppl, Fresh }. By induction hypothesis, we have P n ′ P S m . Since { MDOut, MDPub, MDFresh, MDAppl }, Fresh and MDIn do not add or remove state-facts, P n ′ P S n-2 . Let Q ∈ # P n ′ such that Q P state p ( t). Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = E xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see

						En --→ P S n
	is normal, so is S 0	E 1 -→ P . . .	E n-1 ---→ P S n-1 , and therefore S 0	E 1 -→ P . . .	E n-2 ---→ P S n-2 . Hence there is an
	m < n-2 such S 0	E 1 -→ P . . .

t 2 } # (by (4)) ={ Out(t) ∈ ∪ k≤n S k } # Em --→

Acknowledgements

The research leading to these results has received funding from the European Research Council under the European Union's Seventh Framework Programme (FP7/2007-2013) / ERC grant agreement no 258865, project ProSecure and was supported by CASED (http://www.cased.de).

1. If an application of the Init rule appears in S 0 E 1 -→ P . . .

En

-→ P S n , we move it to the front. Therefore, S 1 = state [] (). This is possible since the left-hand side of the Init rule is empty. If the rule is never instantiated, we prepend it to the trace. Since Init() ∈ F res , the resulting msr execution S (1) 0

n (1) is such that hide([E 1 , . . . , E n ]) = hide([E [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] 1 , . . . , E

n (1) ]). Since Init() is only added if it was not present before, [E (1) 1 , . . . , E

n [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] ] α, especially α init .

2. For each fact Ack(t 1 , t 2 ) contained in S [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] n (1 , it also contains a fact state semi p ( t) for some p and t such that there exists a rule of type R 3 that consumes both of them, since Ack(t 1 , t 2 ) can only be produced by a rule of type R 2 which consumes Msg(t 1 , t 2 ) which in turn can only be produced along with a fact state semi p ( t), and by definition of P , there exists a rule in P =p of form R 3 that consumes Ack(t 1 , t 2 ) and state semi p ( t). We append as many applications of rules of type R 3 as there are facts Ack(t 1 , t 2 ) ∈ S [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] n [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] , and repeat this for all t 1 , t 2 such that Ack(t 1 , t 2 ) ∈ S [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] n [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] . Then, S

n (1) -→ P S [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] n ′ and S [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] n ′ does not contain Ack-facts anymore. If S [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] n ′ contains a fact state semi p ( t), we remove the last transition that produced this fact, i. e., for i such that S i = S i-1 \ # { state p ( t) } # ∪ # { Msg(t 1 , t 2 ), state semi p ( t) } # , we define

The resulting execution is valid, since state semi

n ′ and since Msg(t 1 , t 2 ) ∈ S

n ′ . The latter is the case because if Msg(t 1 , t 2 ) would be consumned at a later point, say j, j + 1 would contain Ack(t 1 , t 2 ), but since S (1) ′ n ′ -1 does not contain Ack-facts, they can only be consumned by a rule of type R 3 , which would have consumned state semi p ( t). We repeat this procedure for every remaining state semi p ( t) ∈ S (2) n (2) Since no rule added or removed or removed has an action, hide([E 1 , . . . ,

n (2) ] α.

We transform S

(1) 0

n [START_REF] Abadi | Deciding knowledge in security protocols under equational theories[END_REF] as follows (all equalities are modulo E): Let us call instances of R 1 , R 2 or R 3 that appear outside a chain

for some i t 1 , t 2 ∈ M "unmarked". Do the following for the smallest i that is an unmarked instance of R 3 ( we will call the instance of R 3 ri 3 and suppose it is applied from S i-1 to S i ): Apply ri 3 after j < i such that S j-1 to S j is the first unmarked instance of R 2 , for some q and ỹ,i. e., this instance produces a fact state q•1 (ỹ, ỹ′ ) and a fact Ack(t 1 , t 2 ). Since there is no rule between j and i that might consume Ack(t 1 , t 2 ) (only rules of form R 3 do, and ri 3 is the first unmarked instance of such a rule) and since ri 3 does not consume state q•1 (ỹ, ỹ′ ), we can move ri 3 between j and j + 1, adding the conclusions of ri 3 and removing the premises of ri 3 from every S j+1 , . . . , S i . Note that unmarked instances of R 2 and R 3 are guaranteed to be preceeded by a marked R 1 , and therefore only remove facts of form Ack(. . .) or Msg(. . .) that have been added in that preceeding step. Since the transition at step j requires a fact Msg(t 1 , t 2 ), there is an instance of R 1 prior to j, say at k < j, since only rules of form R 1 produces facts labelled Msg(t 1 , t 2 ). Since ri 3 is now applied from Sj to S j+1 , we have that an instance ri 1 of a rule of form R 1 that produces state semi p ( t) must appear before j, i. e., ri 1 ∈ ginsts( P =p ). Therefore, it produces a fact Msg(t 1 , t 2 ) indeed. We choose the largest k that has an unmarked R 1 that produces Msg(t 1 , t 2 ) and state semi p ( t) and move it right before j, resulting in the following msr execution:

We apply this procedure until it reaches a fixpoint and call the resulting trace

(3) n (3) Since no rule moved during the procedure has an action, hide

Repeat until fixpoint is reached and call the resulting trace S

-→ P . . .

Since no rule removed during the procedure has an action, hide

n (4) ] α.

If there is

n (4) -1 , then there is a transition where In(t) is produced and never consumned until n (4) -1. The only rule producing In(t) is MDIn. We can move this transition to just before n (4) -1 and call the resulting trace

(5) n (5) Since [E

n (4) ] α, especially α inev , there is no action that is not in F res between the abovementioned instance of MDIn, therefore, hide

n (5) ]) holds. Since α inev is the only part of α that mentions K, and since the tranformation preserved α inev , we have that [E

n (5) ] α. 6. We will show that 6 and 7 hold for

(5) n (5) in one step.

If n (5) ≥ 2 and there is no Ack-fact in S

n [START_REF] Armando | Formal analysis of saml 2.0 web browser single sign-on: Breaking the saml-based single sign-on for google apps[END_REF] and S

(5)

n (5)-3 , since otherwise there would be a larger m or m ′ . This also implies 2, as none of the rules in R = { MDOut, MDPub, MDFresh, MDAppl, Fresh } remove Ack-or state semi -facts, and the chain of rules R 1 , R 2 , R 3 consumes as many as it produces. Thus, if they where in S [START_REF] Armando | Formal analysis of saml 2.0 web browser single sign-on: Breaking the saml-based single sign-on for google apps[END_REF] m , they would be in S ( 5)

Since, S m → * R S n for R = { MDOut, MDPub, MDFresh, MDAppl, Fresh }, only S n \ # S m contains only Fr-facts and !K-facts, and S m \ # S n contains only Fr-facts and Out-facts. Therefore, Condition 3,4 and 5 hold for all i ≤ n -1. Since E m+1 , . . . , E n-1 = ∅, Condition 1, 2,6 and 7 hold for all i ≤ n -1.

Fix a bijection such that P n ′ P S m . We will abuse notation by writing P P state p ( t), if this bijection maps P to state p ( t).

We now proceed by case distinction over the last type of transition from S n-1 to S n . Let l linear = E S n-1 \ S n and r = E S n \ S n-1 . l linear can only contain linear facts, while r can contain linear as well as persistent facts. The rule instance ri used to go from S n-1 to S n has the following form:

for some l persistent ⊂ # E S n-1 . Note that l linear , E n and r uniquely identify which rule in P, [], [] ri is an instance of -with exactly one exception: [] -[a]→ []; P, p, x = event a; P , p, x . Luckily, we can treat the last as a special case of the first.

If R is uniquely determined, we fix some ri ∈ ginsts(R).

Case: R = Init or R ∈ MD \ { MDIn }. In this case, ∅ E 1 -→ . . .

En

--→S n is not a well-formed msr execution.

From the induction hypothesis, and since E m+1 , . . . , E n = ∅, we have that

From the induction hypothesis, and since no rule producing Out-facts is applied between step m and step n, we have that

Then, by Lemma 8 and Lemma 9, we have that νE n ′ , r.σ n ′ ⊢ t. Therefore, νE n ′ .σ n ′ ⊢ t. This allows us to chose the following transition:

for some p and t). By induction hypothesis, we have P n ′ P S m , and thus, as previously established,

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since Q = P | p τ ρ, we can deduce that Q = 0. We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

Condition 4 holds since Q ↔ state p ( t),

Conditions 1, 2, 3, 5 and 7 hold trivially.

] (for some p and t). By induction hypothesis, we have P n ′ P S m , and thus, as previously established,

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that

Conditions 1, 2, 3, 5 and 7 hold trivially.

] (for some p, t). By induction hypothesis, we have P n ′ P S m , and thus, as previously established,

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that Q ′ P state p•1 ( t). Therefore, and since

Conditions 1, 2, 3, 5 and 7 hold trivially.

Case: ri = [state p ( t), Fr(a ′ : fresh)] -[ProtoNonce (a ′ : fresh)]→ [state p•1 ( t, a ′ : fresh)] (for some p, t and a ′ ∈ F N ). By induction hypothesis, we have P n ′ P S m , and thus, as previously established,

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

By definition of exec msr , the fact Fr(a ′ ) can only be produced once. Since this fact is linear it can only be consumed once. Every rule in P that produces a label ProtoNonce(x) for some x consumes a fact Fr(x). Therefore,

The induction hypothesis allows us to conclude that a ′ / ∈ E n ′ ,i. e., a ′ is fresh. We therefore chose the following transition:

. Since in this case, there is a fact with symbol Ack removed from S n-1 to S n , we have to apply a different argument to apply the induction hypothesis.

Since

Hence there is a monotonically increasing function from N m → N n ′ and an execution such that Conditions 1 to 8 hold. Let f p be this function and note that n ′ = f p (m).

In the following case distinction, we extend the previous execution by one step from

), and prove that Conditions 1 to 7 hold for n ′ + 1. By induction hypothesis, they hold for all i ≤ n ′ . We define a function f : N n → N n ′ +1 as follows: Fix a bijection such that P n ′ P S m . We will abuse notation by writing P P state p ( t), if this bijection maps P to state p ( t). Since { MDOut, MDPub, MDFresh, MDAppl } and Fresh do not add or remove state-facts, P n ′ P S n-3 . Let P ∈ # P n ′ such that P P state p (s). Let Q ∈ # P n ′ such that Q P state q ( t). Let θ ′ be a grounding substitution for state q (ỹ) ∈ prems( P =q ) such that t = E ỹθ ′ . Then θ ′ induces a substitution τ ′ and a bijective renaming ρ ′ for fresh, but not bound names (in Q) such that P | q τ ′ ρ ′ = Q (see Definition 22).

From the form of the rules R 1 and R 3 , and since P = E P | p τ ρ, for τ and ρ induced by the grounding substitution for state p (x), we can deduce that P = E out t 1 , t 2 ; P ′ for a process P ′ = P | p•1 τ ρ. Similarly, from the form of R 2 , we can deduce Q = E in (t 1 , N ); Q ′ , for N a term that is not necessarily ground, and a process

Therefore, we chose the following transition:

It is left to show that Conditions 1 to 8 hold for n. As established before, we have τ * such that N τ ′ ρ ′ τ * = E t 2 . Let state q ( t, t′ ) be the state variable added to S n-1 . Then, ((ỹ ∪ vars(N )) \ ỹ)τ * = t′ . By definition of P =q , we have that state q•1 ( t, t′ ) ∈ prems(ginsts(P =p•1 )) for a grounding substitution θ q•1 = θ ′ • τ * . Since τ ′ and ρ ′ are induced by θ ′ , θ q•1 induces τ • τ ′ and the same ρ. We have that Q ′ τ ′ = (P | q•1 τ ′ ρ ′ )τ * = P | q•1 τ τ ′ ρ and therefore Q ′ τ * P state q•1 ( t, t′ ). Similarly, we have P ′ P state q•1 (s). We conclude that Condition 4 holds. Conditions Condition 1, 2, 3, 5, 6 and 7 hold trivially.

Case: ri = [state p ( t)] -[Eq(t 1 , t 2 )]→ [state p•1 ( t)] (for some p, t and t 1 , t 2 ∈ M). By induction hypothesis, we have P n ′ P S m , and thus, as previously established, P n ′ P S n-1 . Let Q ∈ # P n ′ such that Q P state p ( t). Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

Since, [E 1 , . . . , E n α, and thus [E 1 , . . . , E m α eq , we have that t 1 = E t 2 . We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that Q 1 ↔ state p•1 ( t). Therefore, and since if Case: ri = [state p ( t)] -[NotEq(t 1 , t 2 )]→ [state p•1 ( t)] (for some p, t and t 1 , t 2 ∈ M). In this case, the proof is almost the same as in the previous case, except that α noteq is the relevant axiom, Q 2 is chosen instead of Q 1 and and

] (for some p, t). This is a special case of the case where ri = [state p ( t), l] -[a]→ [state p•1 ( t), r] for l = r = ∅ and a = F .

Case: ri = [state p ( t)] -[Insert(t 1 , t 2 )]→ [state p•1 ( t)] (for some p, t and t 1 , t 2 ∈ M). By induction hypothesis, we have P n ′ P S m , and thus, as previously established, P n ′ P S n-1 . Let Q ∈ # P n ′ such that Q P state p ( t). Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that Q ′ ↔ state p•1 ( t). Therefore, and since insert t 1 , t 2 ;

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that Q ′ ↔ state p•1 ( t). Therefore, and since delete t 1 ;

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

Since [E 1 , . . . , E n ] α in , there is an i < n such that Insert(t 1 , t 2 ) ∈ E E i and there is no j such that i < j < n and Delete(t 1 ) ∈ E E j or and Insert (t 1 , t 2 ) ∈ E T E j . Since E m , . . . , E n = ∅, we know that i < m. Hence, by induction hypothesis, S n ′ (t 1 ) = t 2 . We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that

] and ρ ′ = ρ). Therefore, and since lookup t

Conditions 1, 2, 3, 5, 6 and 7 hold trivially.

] (for some p, t and t 1 ∈ M). By induction hypothesis, we have P n ′ P S m , and thus, as previously established,

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

Since [E 1 , . . . , E n ] α notin , there is no i < n such that Insert(t 1 , t 2 ) ∈ E E i and there is no j such that i < j < n and Delete(t 1 ) ∈ E E j or and Insert(t 1 , t 2 ) ∈ E T E j . Since E m , . . . , E n = ∅, we know that holds j < m. Hence, by induction hypothesis, S n ′ (t 1 ) is undefined. We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that Q 2 ↔ state p•2 ( t). Therefore, and since lookup Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

Since [E 1 , . . . , E n ] α lock , for every i < n such that Lock (l p , t) ∈ E E i , there a j such that i < j < n and Unlock (l p , t) ∈ E E j , and in between i and j, there is no lock or unlock, i. e., for all k such that i < k < j, and all l i , Lock (l i , t) /

∈ E E k and Unlock (l i , t) / ∈ E E k . Since E m , . . . , E n = ∅, we know that this holds for i < m and j < m as well. By induction hypothesis, Condition 6, this implies that t ∈ E L n ′ . We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that Q ′ ↔ state p•1 ( t). Therefore, and since lock l t; Q ′ ↔ state p ( t),

Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since

We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

By definition of P and P =p , we have that Q ′ ↔ state p•1 ( t). Therefore, and since unlock l t; Q ′ ↔ state p ( t),

We show that Condition 6 holds for

a contradiction to Condition 6 would constitute of j and u = E n l such that Lock(u, t) ∈ E E j and ∀j < k ≤ n.Unlock(u, t) ∈ E E k .

We will show that this leads to a contradiction with [E 1 , . . . , E n ] α. Fix j and u. By definition of P and well-formedness of P , there is a p l that is a prefix of p such that P | q l = lock l t; Q ′′ for the same annotation l and parameter t. The form of the translation guarantees that if state p ( t) ∈ S n , then for some t′ there is i ≤ n such that state p ′ ( t′ ) ∈ S i , if p ′ is a prefix of p. We therefore have that there is i < n such that E i = E { Lock(n l , t) } # . We proceed by case distinction: Case 1: j < i (see Figure 18). Since ∀j < k ≤ n.Unlock(u, t) Case 2: i < j (see Figure 19). By definition of P , there is no parallel and no replication between p l and p. Note that any rule in P that produces a state named state q for a non-empty q is such that it requires a fact with name state q ′ for q = q ′ • 1 or q = q ′ • 2 (in case of the translation of out, it might require state semi q ′ , which in turn requires state q ′ ). Therefore, there cannot be a second k = n such that Unlock(n l , t) ∈ E E k (since n l was added in a Fr-fact in to S i ). This means in particular that there is not k such that i < k < n and Unlock(n l , t) Case: ri = [state p ( t), l ′ ] -[a ′ , Event()]→ [state p•1 ( t, t′ ), r ′ ] (for some p, t, t′ and l ′ , r ′ , a ′ ∈ G * ). By induction hypothesis, we have P n ′ P S m , and thus, as previously established, P n ′ P S n-1 . Let Q ∈ # P n ′ such that Q P state p ( t). Let θ be a grounding substitution for state p (x) ∈ prems( P =p ) such that t = xθ. Then θ induces a substitution τ and a bijective renaming ρ for fresh, but not bound names (in Q) such that P | p τ ρ = Q (see Definition 22).

From the form of the rule R, and since Q = P | p τ ρ, we can deduce that Q = l -[a]→ r; Q ′ for a process Q ′ = P | p•1 τ ρ.

Since ri ∈ E ginsts(R), we have that there is a substitution τ * such that (l -[a]→ r)τ * = l ′ -[a]→ ′ r ′ , lfacts(l ′ ) ⊂ # S n-1 , pfacts(l ′ ) ⊂ E S n-1 and, from the definition of P for embedded msr rules, vars(l)τ * = t′ . Since P is well-formed, no fact in F res appears in neither l nor r, so from Condition 3 in the induction hypothesis, we have that lfacts(l ′ ) ⊂ # S MS m = S MS n ′ and pfacts(l ′ ) ⊂ S MS m = S MS n ′ . We therefore chose the following transition:

We define f as on page 51. Therefore, Conditions 1 to 8 hold for i < n -1. It is left to show that Conditions 1 to 8 hold for n.

Condition 7 holds since hide([E 1 , . . . , E m ]) = [F 1 , . . . , n ′ ], and E m+1 , . . . , E n-1 = ∅, while E n = F ′ n \ Event() = a ′ (note that Event() ∈ F res ).

As established before, we have τ * such that (l -[a]→ r)τ * = E l -[a]→ r. By the definition of P =p , we have that state p•1 ( t, t′ ) ∈ E ginsts(P =p•1 ), and a θ ′ = θ • τ * that is grounding for state p•1 ( t, t′ ). Since τ and ρ are induced by θ, θ ′ induces τ •τ * and the same ρ. We have that Q ′ τ * = (P | p•1 τ ρ)τ * = P | p τ τ * ρ and therefore Q ′ τ P state p•1 ( t, t′ ). Thus, and since l -[a]→ r; Q ′ P state p ( t), P n ′ +1 = P n ′ \ # { l -[a]→ r; Q ′ } # ∪ # { Q ′ τ * } # and S n = S n-1 \ # lfacts(l ′ ) ∪ # r ′ \ # { state p ( t) } # ∪ # { state p•1 ( t, t′ ) } # , Condition 4 holds. Condition 3, holds since

Conditions 1, 2, 5, 6 and 7 hold trivially.

Lemma 1. Let P be a well-formed ground process. We have that traces pi (P ) = hide(filter (traces msr ( P ))).

Proof. From Lemma 10, we can conclude that traces pi (P ) ⊆ { hide(t)|tr ∈ traces msr ( P ) and tr α } = hide(filter (traces msr ( P ))).

From Lemma 11, we have that hide(filter (traces msr ( P ))) = { tr ∈ hide(filter (traces msr ( P ))) | tr is normal }.

From Lemma 12, we can conclude that { tr ∈ hide(filter (traces msr ( P ))) | tr is normal } ⊆ traces pi (P ).

Hence

hide(filter (traces msr ( P ))) ⊆ traces pi (P ).