Language-based Comparison of Petri Nets with Black Tokens, Pure Names and Ordered Data Fernando Rosa-Velardo1⋆ and Giorgio Delzanno2 1
Universidad Complutense de Madrid, Spain,
[email protected] 2 Universit` a di Genova, Italy,
[email protected]
Abstract. We apply language theory to compare the expressive power of models that extend Petri nets with features like colored tokens and/or whole place operations. Specifically, we consider extensions of Petri nets with transfer and reset operations defined for black indistinguishable tokens (Affine Well-Structured Nets), extensions in which tokens carry pure names dynamically generated with special ν-transitions (ν-APN), and extensions in which tokens carry data taken from a linearly ordered domain (Data nets and CMRS). These models are well-structured transitions systems. In order to compare these models we consider the families of languages they recognize, using coverability as accepting condition. With this criterion, we prove that ν-APNs are in between AWNs and Data Nets/CMRS. Moreover, we prove that the family of languages recognized by ν-APNs satisfies a good number of closure properties, being a semi-full AFL. These results extend the currently known classification of the expressive power of well-structured transition systems with new closure properties and new relations between extensions of Petri nets.
1
Introduction
Dynamic name generation has been thoroughly studied in the last decade, mainly in the field of security and mobility [9]. Paradigmatic examples of nominal calculi are the π-calculus and the Ambient Calculus [9]. In previous works we have studied a very simple extension of Petri Nets, that we called ν-APNs [14, 13]. Tokens in ν-APNs are pure names, that can be created fresh, moved along the net and used to restrict the firing of transitions with name matching. Since any fresh name can be created, we identify markings up to renaming of their names. The paper [10] proves that reachability is undecidable for ν-APNs. However, ν-APNs belong to the class of (strictly) Well Structured Transition Systems (WSTS) [14]. This means that the problems of boundedness (whether the set of reachable states is finite) and coverability (whether a marking which is greater than a given one is reachable) are both decidable. In this paper we compare ν-APNs with other models that are also WSTS. Among these models, we highlight Affine Well-structured Nets (AWN) [5], a wellstructured extension of Petri nets in which whole-place operations (as transfers ⋆
Author partially supported by the Spanish projects DESAFIOS10 TIN2009-14599C03-01, WEST TIN2006-15578-C02-01 and PROMETIDOS S2009/TIC-1465.
2
F. Rosa-Velardo and G. Delzanno
and resets) are allowed; Data nets [11], an extension of AWNs in which tokens are no longer indistinguishable, but taken from a linearly ordered domain; and CMRS [1], a fragment of Data nets without whole-place operations. All above mentioned models are well-structured transition systems in which the reachability problem is undecidable. To compare the expressive power of different models, it comes natural to study the class of languages generated by associating labels to transitions: a finite firing sequence defines a word. The standard notion of acceptance is based on reachability of a configuration. However, since reachability is undecidable for these models, the class of languages they recognize is the class of recursively enumerable languages. Therefore, we need finer grain criteria to distinguish Petri net extended with whole place operations and colored tokens. More specifically, we consider well-structured languages, in which the acceptance condition is defined using coverability of a given configuration. In [3] such comparison is done for Petri nets (PN), AWNs, and Data Nets, and the following is proved: L(PN) ⊂ L(AWN) ⊂ L(Data nets) Moreover, the authors proved that Data nets are equivalent (they generate the same family of languages) to the so called Petri Data nets, Data nets for which no whole-place operation is allowed, and equivalent to CMRS. We plan to put νAPNs in that picture, by studying the family of languages recognized by them. More precisely, we study the families recognized by ν-APNs and also by ν6= APNs, a variation of ν-APNs allowing to check for inequality of names. In particular, we prove that both are in between AWNs and Data nets. The rest of the paper is organized as follows: Section 2 defines some basic concepts that we use throughout the paper. In Section 3 we study the languages recognized by ν-APNs and ν6= -APNs with different accepting conditions, and prove some closure properties for them. Section 4 compares the languages recognized by AWNs and ν-APNs. Section 5 compares ν6= -APNs and Data Nets. Finally, Section 6 presents our conclusions and future work.
2
Preliminaries
Languages, AFLs. Given a (finite) alphabet Σ, any w = a1 · · · an with n ≥ 0 and ai ∈ Σ, for all i, is a (finite) word on Σ. We denote by Σ ∗ the set of words on Σ. If n = 0 then w is the empty word, which is denoted by ǫ. The length of w is |w| = n. A language on Σ is a set of words on Σ. If we denote by · the word concatenation, then L1 · L2 = {w1 · w2 | w1 ∈ L1 , w2 ∈ L2 } is the i
concatenation of L1 and L denote by Li the language L· · ·L, the iteration S2 . If we i + L of the language L is i>0 L . A function h : Σ ∗ → Σ ∗ is an homomorphism if h(w1 · w2 ) = h(w1 ) · h(w2 ). Given an homomorphism h and a language L, we can define h(L) = {h(w) | w ∈ L} and h−1 (L) = {w | h(w) ∈ L}. A semi-full abstract family of languages (semi-full AFL) [8] is a family of languages closed under union, intersection with regular languages, homomorphism
Comparison of Petri nets with Black Tokens, Pure Names and Ordered Data
3
and inverse homomorphism. A semi-full AFL is a full AFL if it is closed under concatenation and iteration. wqos. A quasi order ≤ is a reflexive and transitive binary relation on a set X. A quasi order ≤ is well founded if there are no infinite strictly decreasing sequences, and it is decidable if for every a, b ∈ X we can effectively decide if a ≤ b. A well founded quasi order is simply said well (wqo) [6], if for every infinite sequence a0 , a1 , . . . there are i and j with i < j such that ai ≤ aj . Equivalently, an order is a wqo if every sequence has an increasing subsequence. WSTS, WSL. A transition system is a pair N = (X, →) with set of states X and transition relation →⊆ X × X. We denote by →∗ the reflexive and transitive closure of →. A Well Structured Transition System (WSTS) is a tuple N = (X, →, ≤), where (X, →) is a transition system, and (X, ≤) is a decidable wqo, satisfying the following monotonicity condition3 : M1 ≤ M2 and M1 → M1′ implies the existence of M2′ such that M2 → M2′ and M1′ ≤ M2′ . In the classic theory of Petri net languages [12] three types of labelling functions are considered: injective, ǫ-free and arbitrary. In this work we concentrate on arbitrary labelling functions (generally having better closure properties). We consider a fixed finite alphabet Σ and a special symbol ǫ ∈ / Σ, and we assume that ǫ is such that ǫ · w = w · ǫ = w. A labelled WSTS S is aSWSTS a S = (X, →, ≤), where the transition relation is partitioned into →= →. a∈Σ∪{ǫ}
w
∗
′
′
For a word w ∈ Σ , we write M →M if M can be reached from M and the concatenation of the labels of the transitions used is the word w. Moreover, four acceptance conditions can be considered: reachability, coverability, deadlock and no condition. Definition 1. Given a labelled WSTS S and two states s0 and sf , we define:4 – – – –
w
LL (S) = {w ∈ Σ ∗ | s0 →sf }, w LG (S) = {w ∈ Σ ∗ | s0 →s, s ≥ sf }, w LT (S) = {w ∈ Σ ∗ | s0 →s, s 6→}, w LP (S) = {w ∈ Σ ∗ | s0 →s},
Notice that conditions T and P do not make use of the final state sf . For any of the models M we consider in this paper, we denote by LR (M) the class of languages {LR (S) | S ∈ M}, with R ∈ {L, G, T, P }. A Well Structured Language (WSL) is any language accepted by a WSTS, with G as accepting condition [7]. In [7] the following pumping lemma is proved. Lemma 1 (Lemma 6 (pg. 262) [7]). Let L be a WSL and (wk )∞ k=1 ⊆ L with wk = Bk · Ek for every k ≥ 1. Then, there exist i < j such that Bj · Ei ∈ L. Multisets. Given an arbitrary set A, we denote by MS(A) the set of finite multisets of A, that is, the mappings m : A → N. When needed, we identify each 3 4
Less restrictive monotonicy notions are considered in [6]. We use the classical notation for Petri Net Languages in [12].
4
F. Rosa-Velardo and G. Delzanno p1
a
x
p2
b
y
x
a q1
ν
b
a q2
→
p1
a
x
p2
b
y
x a ν
a
q1
(c fresh) c q2
Fig. 1. A simple ν-APN and the firing of its only transition
set with the multiset defined by its characteristic function, and use set notation for multisets when convenient. We denote by PS(m) the support of m, that is, the set {a ∈ A | m(a) > 0} and by |m| = m(a) the cardinality of m. We a∈S(m)
denote by m1 + m2 , m1 ⊆ m2 and m1 − m2 the multiset addition, inclusion, and substraction, respectively. If f : A → B is an injection and m ∈ MS(A) then we can define f (m) ∈ MS(B) by f (m)(b) = m(a) if f (a) = b for some a, and f (m)(b) = 0, otherwise.
3
Nets in which Tokens carry Pure Names
In this section we study the class of languages generated by an extension of Petri nets with pure names, called ν-APN [13]. ν-APNs The class of ν-APNs is an extension of Petri Nets in which tokens are not indistinguishable, but pure names, that can only be compared by the equality predicate. We consider a set Id of names, a set Var of variables and a disjoint set Υ of special variables. A ν-APN is a tuple N = (P, T, F ), where P and T are finite disjoint sets of elements called places and transitions, respectively, F : (P × T ) ∪ (T × P ) → MS(Var ) is such that for every t ∈ T , post (t) \ Υ ⊆ pre(t) and pre(t) ∩ Υ = ∅, where S S(F (p, t)), – pre(t) = p∈P S S(F (t, p)) and – post (t) = p∈P
– Var (t) = pre(t) ∪ post (t). The mapping F labels every pair (p, t) and (t, p) with a multiset of variables. These variables specify how tokens flow from preconditions to postconditions. Only variables in ν can appear in some postarc without appearing in some prearc. Variables in Υ can only be instantiated to names that do not occur in the current marking, so that they formalize fresh name creation. We are assuming that these variables only appear in post-arcs, that is, labelling pairs of the form (t, p). A marking M of a ν-APN assigns to each place a multiset of names. We denote by S(M ) the set S of names that occur in some place according to marking M , that is, S(M ) = p∈P S(M (p)). A transitions t can be fired with respect to a mode σ : Var (t) → Id that instantiates each variable to an identifier so that σ(ν1 ) 6= σ(ν2 ) for each different ν1 , ν2 ∈ Υ . We use σ, σ ′ , σ1 . . . to range over
Comparison of Petri nets with Black Tokens, Pure Names and Ordered Data k
x
x
k
y
x=y
x
x x
x=y l
x
k
y
l
l
5
k
x x y
x6=y
y
l
Fig. 2. Simulation of ν-APN (left) by means of a ν6= -APN (right)
modes. A transition t is enabled with mode σ for a marking M if for all p ∈ P , σ(F (p, t)) ⊆ M (p) and σ(ν) ∈ / S(M ) for all ν ∈ Υ . The reached state after the firing of t with mode σ is the marking M ′ (p) = (M (p) − σ(F (p, t))) + σ(F (t, p)) for all p ∈ P . t(σ)
τ
We write M → M ′ , M → M ′ and M →M ′ with τ = t1 (σ1 ) · · · tn (σn ), saying that τ is a transition sequence, with their obvious meanings. Figure 1 depicts a simple ν-APN with a single transition. When fired, it moves one token from p1 to q1 (because of variable x labelling both arcs), removes a token from p2 (variable y does not appear in any outgoing arc) and a new name is created in q2 (because of variable ν). In this example, had the token in p2 carried an a instead of a b, the transition could also have been fired (reaching the same marking), since modes can instantiate different variables with the same name. In other words, in ν-APNs we cannot check for inequality. We consider a variation of ν-APNs, that we call ν6= -APNs, in which we can check for inequality, which can be simply formalized by taking modes to be injections. We define M1 ⊑ M2 if there is an injection ι : S(M1 ) → S(M2 ) such that ι(M1 (p)) ⊆ M2 (p), for all p ∈ P . We take ≡ as ⊑ ∩ ⊒ and identify markings up to ≡. The relation ⊑ is a wqo and the transition system generated by ν-APNs and ν6= -APNs are WSTS with that order [14]. ν-APN languages In this section we study LR (ν-APN) and LR (ν6= -APN) for R ∈ {L, G, T, P }, that is, the families of languages recognized by ν-APNs and ν6= -APNs, with reachability, coverability, termination and no-condition, as accepting conditions. We can immediately obtain the following basic results. Proposition 1. LL (ν-APN), LL (ν6= -APN) and LT (ν6= -APN) are the class of recursively enumerable languages. Proposition 2. The following relations among languages hold: 1. LP (ν-APN) ⊂ LG (ν-APN) ⊂ LL (ν-APN) 2. LP (ν6= -APN) ⊂ LG (ν6= -APN) ⊂ LL (ν6= -APN) Proof. The proof is the same for ν-APNs and ν6= -APNs. For the first inclusions it is enough to consider the empty marking as acceptance. To see that they are strict, notice that languages in LP are always prefix-closed, and it is trivial to devise non prefix-closed languages in LG (ν-APN) and LG (ν6= -APN). The second inclusions follow from the previous proposition. Moreover, they are strict because there are recursively enumerable languages that are not WSL, such as {an bn | n > 0}, which can be easily seen using the pumping lemma for WSL.
6
F. Rosa-Velardo and G. Delzanno
In general, for all the languages considered, being able to check inequality gives us at least the same expressive power: Proposition 3. LR (ν-APN) ⊆ LR (ν6= -APN) for R ∈ {L, G, T, P } Proof. We have to simulate a ν-APN by means of a ν6= -APN. For a transition t and a partition X = X1 ⊔ · · · ⊔ Xk of Var(t), we choose k variables x1 , . . . , xk so that xi ∈ Xi . Then, for each t and each partition of Var (t), we consider a transition tX (with the same label as t) and an arc from p to tX labelled with xi iff F (p, t) ∈ Xi , and analogously for arcs (t, p) (see Fig. 2). The families of languages LG (ν-APN) and LG (ν6= -APN) satisfy a good number of closure properties, which are summarized in the following result. Proposition 4. LG (ν-APN) and LG (ν6= -APN) are semi-full AFLs closed under concatenation and intersection. Therefore, the families of languages recognized by ν-APNs and ν6= -APNs, with coverability as accepting condition, are semi-full AFLs, but we do not know if they are also full AFLs, since we have not proved whether they are closed under iteration. However, we can prove the following. Proposition 5. If L ∈ LG (Petri nets) then L+ ∈ LG (ν-APN). Proof. We represent each of the executions of the Petri net by a different identifier. Then we add a place that contains the identifier that represents the current execution, and a transition that can be fired when the final marking is covered (matching the current identifier) and creating the initial marking with a fresh identifier. The final marking is that with the same tokens as indicated by the final marking of the Petri net, which in turn must be the same token in the new place. Thanks to this result it is straightforward to see that, for instance, the language {an1 bm1 . . . ank bmk | ni ≥ mi f or i : 1, . . . , k} is in LG (ν-APN). It would be interesting to see what happens with iteration for LG (ν-APN). We conjecture that for an arbitrary L ∈ LG (ν-APN), L+ is not necessarily in LG (ν-APN). The intuitive reasoning is the same as for LG (Petri nets), namely the fact that by means of coverability we cannot distinguish between different “executions” within the same net (we cannot throw away arbitrary garbage). To conclude this section, let us see that if we forbid name matching in ν-APNs, then its expressive power boils down to that of Petri nets, since we are not considering whole-place operations. We simply call ν= -APNs the subclass of ν-APNs where for Peach transition t, variables in pre-arcs appear at most once, that is, such that p∈P F (p, t)(x) ≤ 1. The intuitive idea is that, without matching, the specific nature of named tokens, that is, the identifiers carried by tokens, does not play any role in the firing of transitions. Therefore, we could flatten the given ν= -APN to the Petri Net with the same places, transitions and flow relation (by removing variables
Comparison of Petri nets with Black Tokens, Pure Names and Ordered Data p aa
x
x a
q aa
p
aa
→
aa
x
x a
7
q aa
Fig. 3. ν= -APN with final marking M (p) = ∅ and M (q) = {a, b} p(a)
••
a
aa q(a)
aa
a
aa q(b)
p(other ) aa
a
aa q(other )
p(b)
aa
→
p(a) aa
a
••
q(a)
p(b) aa
a
aa
q(b)
p(other ) aa
a
aa
q(other )
Fig. 4. Simulation of the ν= -APN in Fig. 3 by means of a Petri Net net with final marking M ∗ (q(a)) = M ∗ (q(b)) = 1 and M ∗ (p(a)) = M ∗ (p(b)) = M ∗ (p(other )) = M ∗ (q(other )) = 0
in arcs). This would be enough if we were considering T or P as terminating conditions, but this is not the case for G. To see it, it is enough to consider the net depicted in Fig. 3, using M (p) = ∅ and M (q) = {a, b} as final marking. That net can fire its only transition twice, reaching a marking with the identifier a twice in place q, which does not cover M . Therefore, it generates the empty language, though the sketched construction would generate the language {aa}. In other words, the terminating condition does allow us to retrieve some information about the involved tokens, even though that information was not relevant in the enabling and firing of transitions. However, that information is finite (about tokens in the initial and the final marking), so that we can control it with some special places (see Fig. 4). Proposition 6. LR (Petri Nets) = LR (ν= -APN) for R ∈ {L, G, T, P }.
4
Pure Names vs Black Tokens
In this section we compare ν-APNs with AWNs, a well structured extension of Petri Nets that allows whole-place operations An AWN N is given by a set of n places and a set of transitions. Each transition comes equipped with two n-vectors, Ft and Ht , and a n × n-matrix Gt over N. A marking M of an AWN must specify how many (black) tokens are there in each place, so that it is also an n-vector. Then, a transition t can fire whenever Ft ≤ M , and the reached marking after the firing is M ′ = (M − Ft ) · Gt + Ht . The matrices Gt are responsible for the whole place operations. For instance, if the i-th column of Gt is null, then Gt resets the i-th place, that is, it empties its content. If Gt is the identity matrix for all t, then N is an ordinary Petri net. Now let us see that we can simulate the whole place operations allowed by AWNs thanks to the name creation mechanism in ν-APNs. We obtain lossy simulations of the AWNs, in which some whole-place operations can loose some tokens. However, we know [3] that a lossy version of any WSTS produces the same language, that is, that if N ′ is a lossy version of N then LG (N ) = LG (N ′ ).
8
F. Rosa-Velardo and G. Delzanno t1
t1 xp
•• q
p ••
p aa
c(p) a
b
ν t2
xq
xq
xp
xp
xq
c(q)
•• q
xq
t2
Fig. 5. Simulation of Reset Nets by means of ν-APNs
Proposition 7. LG (AWN) ⊆ LG (ν-APN). Proof (sketch). The idea is to have for each place p another place c(p) which at all times contains a single identifier token, which is the current valid token of p. All transitions use only valid tokens (matching their values with the values in the places c(p)). Transitions that reset a place p cause the replacement of the current valid token, by means of the ν variable (see Fig. 5). This has the effect of leaving some garbage tokens in the place that should have been reset, but these tokens cannot interfere with the execution of the net because of the previous comments. Notice that the simulation of resets is not lossy. A transfer from p to q is simulated as follows: 1. For each token in p matching the one in c(p), remove it, and add a token in q matching the one in c(q), 2. Replace the token in c(p) by a fresh token. Notice that the second step can be performed even if the first one can still be done, that is, when there are still tokens in p matching the one in c(p). In that case, the simulation is missing tokens. Moreover, the previous simulation must be done in a transactional way, so that after step 1 has been followed once, no other transition can fire until step 2 has happened, which can be achieved thanks to some new “control places”.
5
Pure Names vs Ordered Data
Now we compare ν-APNs with two extensions of Petri nets in which tokens carry data taken from an ordered domain, namely Data nets [11] and CMRS [1]. Data Nets Data nets [11] are an extension of AWN in which tokens are colored with data taken from an infinite domain D equipped with a linear and dense ordering ≺. A data net consists of a finite set of places P and of a finite set of transitions. A data net marking s is a multiset of tokens that carry data in D. Formally, a marking s is a finite sequence of vectors in NP \ {0}, where 0 is the vector that contains only 0’s. Each index i in the sequence s corresponds to some di ∈ D such that i ≤ j if and only if di ≺ dj . For each p ∈ P , s(i)(p) is the number of tokens with data di in place p.
Comparison of Petri nets with Black Tokens, Pure Names and Ordered Data
9
First of all, a data net transition t has an associated arity αt (a natural number greater than zero). The arity αt = k is used to non-deterministically select k distinct data d1 ≺ . . . ≺ dk from the current configuration s. Some of the selected data may not occur in s (they are fresh). This choice induces a finite and ordered partitioning R(αt ) of the data in s. A transition t operates on the regions in the partitioning R(αt ) in three steps defined resp. by three matrices Ft , Ht ∈ NR(αt )×P , and Gt ∈ NR(αt )×P ×R(αt )×P . As in AWN, Ft is responsible for the removal of tokens, Gt performs whole-place operations and Ht is responsible for the addition of tokens. The tokens involved in the firing are not just those carrying the k selected data, but potentially every token present in the marking, though those belonging to the same region are treated uniformly. As proved in [11], data nets are well-structured, so that their languages are in the class WSL. Though they can perform very general whole-place operations, from the point of view of the languages they accept, whole-place operations do not make any difference [3]. For that reason, we present CMRS, a more manageable formalism equivalent to Data nets from the language point of view. CMRS We assume a set V of variables which range over N, and a set P of unary predicate symbols. In CMRS we write multisets as lists, so [1, 5, 5, 1, 1] represents a multiset with three occurrences of 1 and two occurrences of 5; [ ] represents the empty multiset. We use the relations and operations such as ⊂ (inclusion), + (union), and − (difference) on multisets. For a set V ⊆ V, a valuation Val of V is a mapping from V to N. A condition is a finite conjunction of gap order formulas of the forms: x c, x = c, where x, y ∈ V and c ∈ N. Here x