**4. Arbitrary Petri net controlled grammars**

In this section we consider a generalization of regularly controlled grammars: instead of a finite automaton we associate a Petri net with a context-free grammar and require that the sequence of applied rules corresponds to an occurrence sequence of the Petri net, i.e., to sequences of transitions which can be fired in succession. However, one has to decide what type of correspondence is used and what concept is taken as an equivalent of acceptance. Since the sets of occurrence sequences form the language of a Petri net, we choose the correspondence and the equivalent for acceptance according to the variations which are used in the theory of Petri net languages.

Therefore as correspondence we choose a bijection (between transitions and rules) or a coding (any transition is mapped to a rule) or a weak coding (any transition is mapped to a rule or the empty word) which agree with the classical three variants of Petri net languages (see e.g. [34, 57, 58]).

We consider two types of acceptance from the theory of Petri net languages: only those occurrence sequences belonging to the languages which transform the initial marking into a marking from a given finite set of markings or all occurrence sequences are taken (independent of the obtained marking). If we use only the occurrence sequence leading to a marking in a given finite set of markings we say that the Petri net controlled grammar is of *t*-type; if we consider all occurrence sequences, then the grammar is of *r*-type. We add a further type which can be considered as a complement of the *t*-type. Obviously, if we choose a finite set *M* of markings and require that the marking obtained after the application of the occurrence sequence is smaller than at least one marking of *M* (the order is componentwise), then we can choose another finite set *M* of markings and require that the obtained marking belongs to *M* . The complementary approach requires that the obtained marking is larger than at least one marking of the given set *M*. The corresponding class of Petri net controlled grammars is called of *g*-type. Therefore, we obtain nine classes of Petri net controlled grammars since we have three different types of correspondence and three types of the set of admitted occurrence sequences. These types of control are generalizations of those types of control considered in the previous chapter, too, where instead of arbitrary Petri nets only such Petri nets have been considered where the places and transitions correspond in a one-to-one manner to nonterminals and rules, respectively.

We now introduce the concept of control by an arbitrary Petri net.

**Definition 5.** An *arbitrary Petri net controlled grammar* is a tuple *G* = (*V*, Σ, *S*, *R*, *N*, *γ*, *M*) where *V*, Σ, *S*, *R* are defined as for a context-free grammar and *N* = (*P*, *T*, *F*, *ϕ*, *ι*) is a (marked) Petri net, *γ* : *T* → *R* ∪ {*λ*} is a transition labeling function and *M* is a set of final markings.

**Definition 6.** The *language* generated by a Petri net controlled grammar *G*, denoted by *<sup>L</sup>*(*G*), consists of all strings *<sup>w</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> such that there is a derivation *<sup>S</sup> <sup>r</sup>*1*r*2···*rk* ====<sup>⇒</sup> *<sup>w</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> and an occurrence sequence *ν* = *t*1*t*<sup>2</sup> ··· *ts* which is successful for *M* such that *r*1*r*<sup>2</sup> ···*rk* = *γ*(*t*1*t*<sup>2</sup> ··· *ts*).

*Example* 3*.* Let *G*<sup>3</sup> = ({*S*, *A*, *B*, *C*}, {*a*, *b*, *c*}, *S*, *R*, *N*3, *γ*, *M*) be a Petri net controlled grammar where *R* consists of

$$\begin{aligned} S &\rightarrow ABC\_\prime\\ A &\rightarrow aA\_\prime \\ A &\rightarrow a\_\prime \end{aligned} \qquad B \to bB\_\prime \qquad \begin{aligned} \mathbf{C} &\rightarrow c\mathbf{C}\_\prime\\ \mathbf{C} &\rightarrow c\mathbf{C}\_\prime \end{aligned}$$

and *N*<sup>3</sup> is illustrated in Figure 3. If *M* is the set of all reachable markings, then *G*<sup>3</sup> generates the language

$$L(G\_3) = \{ a^n b^m c^k \mid n \ge m \ge k \ge 1 \}.$$

If *M* = {*μ*} with *μ*(*p*) = 0 for all *p* ∈ *P*, then it generates the language

$$L(G\_3) = \{ a^n b^n c^n \mid n \ge 1 \}.$$

**Figure 3.** A labeled Petri net *N*<sup>3</sup>

10 Petri Nets

•

In this section we consider a generalization of regularly controlled grammars: instead of a finite automaton we associate a Petri net with a context-free grammar and require that the sequence of applied rules corresponds to an occurrence sequence of the Petri net, i.e., to sequences of transitions which can be fired in succession. However, one has to decide what type of correspondence is used and what concept is taken as an equivalent of acceptance. Since the sets of occurrence sequences form the language of a Petri net, we choose the correspondence and the equivalent for acceptance according to the variations which are used

Therefore as correspondence we choose a bijection (between transitions and rules) or a coding (any transition is mapped to a rule) or a weak coding (any transition is mapped to a rule or the empty word) which agree with the classical three variants of Petri net languages (see e.g.

We consider two types of acceptance from the theory of Petri net languages: only those occurrence sequences belonging to the languages which transform the initial marking into a marking from a given finite set of markings or all occurrence sequences are taken (independent of the obtained marking). If we use only the occurrence sequence leading to a marking in a given finite set of markings we say that the Petri net controlled grammar is of *t*-type; if we consider all occurrence sequences, then the grammar is of *r*-type. We add a further type which can be considered as a complement of the *t*-type. Obviously, if we choose a finite set *M* of markings and require that the marking obtained after the application of the occurrence sequence is smaller than at least one marking of *M* (the order is componentwise), then we can choose another finite set *M* of markings and require that the obtained marking

than at least one marking of the given set *M*. The corresponding class of Petri net controlled grammars is called of *g*-type. Therefore, we obtain nine classes of Petri net controlled

. The complementary approach requires that the obtained marking is larger

**Figure 2.** A 2-Petri net *N*<sup>2</sup>

[34, 57, 58]).

belongs to *M*

in the theory of Petri net languages.

**4. Arbitrary Petri net controlled grammars**

Different labeling strategies and different definitions of the set of final markings result in various types of Petri net controlled grammars. We consider the following types of Petri net controlled grammars.

**Definition 7.** A Petri net controlled grammar *G* = (*V*, Σ, *S*, *R*, *N*, *γ*, *M*) is called *free* (abbreviated by *f*) if a different label is associated to each transition, and no transition is labeled with the empty string; *λ*-*free* (abbreviated by −*λ*) if no transition is labeled with the empty string; *extended* (abbreviated by *λ*) if no restriction is posed on the labeling function *γ*.

**Definition 8.** A Petri net controlled grammar *G* = (*V*, Σ, *S*, *R*, *N*, *γ*, *M*) is called *r-type* if *M* is the set of all reachable markings from the initial marking *ι*, i.e., *M* = R(*N*, *ι*); *t-type* if *M* ⊆ R(*N*, *ι*) is a finite set; *g-type* if for a given finite set *M*<sup>0</sup> ⊆ R(*N*, *ι*), *M* is the set of all markings such that for every marking *μ* ∈ *M* there is a marking *μ*� ∈ *M*<sup>0</sup> such that *μ* ≥ *μ*� .

We also use a notation an (*x*, *y*)-(generalized) state machine, ((generalized) marked graph, causal net, (extended) free-choice net, asymmetric choice net and ordinary net) controlled grammar where *x* ∈ { *f* , −*λ*, *λ*} shows the type of a labeling function *γ* and *y* ∈ {*r*, *t*, *g*}

We denote the families of languages generated by grammars controlled by state machines, generalized state machines, marked graphs, generalize marked graphs, causal nets, free-choice nets, extended free-choice nets, asymmetric nets, ordinary nets and Petri nets

*Example* 4*.* Let *G*<sup>4</sup> = ({*S*, *A*, *B*}, {*a*, *b*}, *S*, *R*, *N*4, *γ*, *M*) be a SM controlled grammar where *R*

*A* → *aA*, *A* → *bA*, *A* → *λ*, *B* → *aB*, *B* → *bB*, *B* → *λ*, the Petri net *N*<sup>4</sup> illustrated in Figure 4 is a labeled state machine and *M* = {*μ*} where *μ*(*p*0) = 1

*<sup>L</sup>*(*G*4) = {*ww* <sup>|</sup> *<sup>w</sup>* ∈ {*a*, *<sup>b</sup>*}∗} ∈ **SM***λ*(*λ*, *<sup>t</sup>*).

is as for the grammar *G*<sup>1</sup> in Example 4, a labeled marked graph *N*<sup>5</sup> is illustrated in Figure 5

*<sup>L</sup>*(*G*5) = {*ww*� <sup>|</sup> *<sup>w</sup>* ∈ {*a*, *<sup>b</sup>*}<sup>∗</sup> and *<sup>w</sup>*� <sup>∈</sup> Perm(*w*)} ∈ **MG***λ*(*λ*, *<sup>t</sup>*).

We have the same result on the labeling strategies as that in the previous section: the labeling of transitions of special Petri nets do not effect on the generative powers of the families of

The following theorem shows the relations of families of languages generated by special Petri

**Theorem 10.** *For* **X** ∈ {**SM**, **GSM**, **MG**, **GMG**, **CN**, **FC**, **EFC**, **AC**, **ON**}*, and y* ∈ {*r*, *t*, *g*}*,*

(*f* , *y*) = **X**[*λ*]

, *M*�

(−*λ*, *<sup>y</sup>*) = **<sup>X</sup>**[*λ*]

(*λ*, *y*).

(*x*, *y*), **GMG**[*λ*]

(*x*, *y*), **ON**[*λ*]

(*x*, *y*), **CN**[*λ*]

(*x*, *y*), **PN**[*λ*]

(*x*, *y*),

Grammars Controlled by Petri Nets 349

(*x*, *y*)

) be a MG controlled grammar where *R*

(*x*, *y*), **MG**[*λ*]

(*x*, *y*), **AC**[*λ*]

The inclusion **<sup>X</sup>**(*x*, *<sup>y</sup>*) <sup>⊆</sup> **<sup>X</sup>***λ*(*x*, *<sup>y</sup>*) immediately follows from the definition where

*S* → *AB*,

shows the type of a set of final markings.

(*x*, *y*), **GSM**[*λ*]

• **X** ∈ {**SM**, **GSM**, **MG**, **GMG**, **CN**, **FC**, **EFC**, **AC**, **ON**},

(*x*, *y*), **EFC**[*λ*]

**SM**[*λ*]

**FC**[*λ*]

where *x* ∈ { *f* , −*λ*, *λ*} and *y* ∈ {*r*, *t*, *g*}.

• *x* ∈ { *f* , −*λ*, *λ*} and *y* ∈ {*r*, *t*, *g*}.

and *μ*(*p*) = 0 for all *p* ∈ *P* − {*p*0}, then

net controlled grammars.

*Example* 5*.* Let *G*<sup>5</sup> = ({*S*, *A*, *B*}, {*a*, *b*}, *S*, *R*, *N*5, *γ*�

and *M*� = {*μ*} where *μ*(*p*) = 0 for all *p* ∈ *P*. Then

languages generated by grammars controlled by these nets.

**X**[*λ*]

consists of

We use the notation (*x*, *y*)*-PN controlled grammar* where *x* ∈ { *f* , −*λ*, *λ*} shows the type of a labeling function and *y* ∈ {*r*, *t*, *g*} shows the type of a set of final markings. We denote by **PN**(*x*, *y*) and **PN***λ*(*x*, *y*) the families of languages generated by (*x*, *y*)-PN controlled grammars without and with erasing rules, respectively, where *x* ∈ { *f* , −*λ*, *λ*} and *y* ∈ {*r*, *t*, *g*}.

The following theorem shows that the labeling strategy does not effect on the generative capacity of arbitrary Petri net controlled grammars.

**Theorem 8.** *For y* ∈ {*r*, *t*, *g*}*,*

$$\mathbf{PN}^{[\lambda]}(f,y) = \mathbf{PN}^{[\lambda]}(-\lambda,y) = \mathbf{PN}^{[\lambda]}(\lambda,y).$$

Not surprisingly, arbitrary Petri net controlled grammars generate matrix languages. Moreover, in [65] it was proven that the erasing rules in arbitrary Petri net controlled grammars can be eliminated without effecting on the generative power of the grammars. If we take into consideration this result, we obtain the following inclusions and equalities:

**Theorem 9.** *For x* ∈ { *f* , −*λ*, *λ*} *and y* ∈ {*r*,*t*, *g*}*,*

$$\mathbf{M}\mathbf{A}\mathbf{T} \subseteq \mathbf{PN}(\mathbf{x},\mathbf{r}) = \mathbf{PN}(\mathbf{x},\mathbf{g}) \subseteq \mathbf{PN}(\mathbf{x},\mathbf{t}) = \mathbf{PN}^{\lambda}(\mathbf{x},\mathbf{y}) = \mathbf{M}\mathbf{A}\mathbf{T}^{\lambda}.$$

### **5. Grammars controlled by special Petri nets**

In the previous section we investigated arbitrary Petri net controlled grammars in dependence on the type of labeling functions and on the definitions of final markings, and showed that Petri net controlled grammars have the same power as some other regulating mechanisms such as matrices, finite automata. If we consider these matrices and finite automata in terms of control mechanisms, special types of matrices and special regular languages are widely investigated in literature, for instance, as control, simple matrices ([37]) or some subclasses of regular languages ([15, 17]) are considered. Thus, it is also natural to investigate grammars controlled by some special classes of Petri nets. We consider (generalized) state machines, (generalized) marked graphs, causal nets, (extended) free-choice nets, asymmetric choice nets and ordinary nets. Similarly to the general case we also investigate the effects of labeling policies and final markings to the computational power, and prove that the family of languages generated by (arbitrary) Petri net controlled grammars coincide with the family of languages generated by grammars controlled by free-choice nets.

Let *G* = (*V*, Σ, *S*, *R*, *N*, *γ*, *M*) be an arbitrary Petri net controlled grammar. The grammar *G* is called a (generalized) state machine, (generalized) marked graph, causal net, (extended) free-choice net, asymmetric choice net or ordinary net controlled grammar if the net *N* is a (generalized) state machine, (generalized) marked graph, causal net, (extended) free-choice net, asymmetric choice net or ordinary net, respectively.

We also use a notation an (*x*, *y*)-(generalized) state machine, ((generalized) marked graph, causal net, (extended) free-choice net, asymmetric choice net and ordinary net) controlled grammar where *x* ∈ { *f* , −*λ*, *λ*} shows the type of a labeling function *γ* and *y* ∈ {*r*, *t*, *g*} shows the type of a set of final markings.

We denote the families of languages generated by grammars controlled by state machines, generalized state machines, marked graphs, generalize marked graphs, causal nets, free-choice nets, extended free-choice nets, asymmetric nets, ordinary nets and Petri nets

$$\mathbf{CM}^{[\lambda]}(\mathbf{x},\mathbf{y}), \mathbf{CGM}^{[\lambda]}(\mathbf{x},\mathbf{y}), \mathbf{MCG}^{[\lambda]}(\mathbf{x},\mathbf{y}), \mathbf{CGM}^{[\lambda]}(\mathbf{x},\mathbf{y}), \mathbf{CN}^{[\lambda]}(\mathbf{x},\mathbf{y}),$$
 
$$\mathbf{FC}^{[\lambda]}(\mathbf{x},\mathbf{y}), \mathbf{ECC}^{[\lambda]}(\mathbf{x},\mathbf{y}), \mathbf{ACC}^{[\lambda]}(\mathbf{x},\mathbf{y}), \mathbf{CN}^{[\lambda]}(\mathbf{x},\mathbf{y}), \quad \mathbf{PN}^{[\lambda]}(\mathbf{x},\mathbf{y})$$

where *x* ∈ { *f* , −*λ*, *λ*} and *y* ∈ {*r*, *t*, *g*}.

12 Petri Nets

**Definition 8.** A Petri net controlled grammar *G* = (*V*, Σ, *S*, *R*, *N*, *γ*, *M*) is called *r-type* if *M* is the set of all reachable markings from the initial marking *ι*, i.e., *M* = R(*N*, *ι*); *t-type* if *M* ⊆ R(*N*, *ι*) is a finite set; *g-type* if for a given finite set *M*<sup>0</sup> ⊆ R(*N*, *ι*), *M* is the set of all markings such that for every marking *μ* ∈ *M* there is a marking *μ*� ∈ *M*<sup>0</sup> such that *μ* ≥ *μ*�

We use the notation (*x*, *y*)*-PN controlled grammar* where *x* ∈ { *f* , −*λ*, *λ*} shows the type of a labeling function and *y* ∈ {*r*, *t*, *g*} shows the type of a set of final markings. We denote by **PN**(*x*, *y*) and **PN***λ*(*x*, *y*) the families of languages generated by (*x*, *y*)-PN controlled grammars

The following theorem shows that the labeling strategy does not effect on the generative

Not surprisingly, arbitrary Petri net controlled grammars generate matrix languages. Moreover, in [65] it was proven that the erasing rules in arbitrary Petri net controlled grammars can be eliminated without effecting on the generative power of the grammars. If we take into consideration this result, we obtain the following inclusions and equalities:

**MAT** <sup>⊆</sup> **PN**(*x*,*r*) = **PN**(*x*, *<sup>g</sup>*) <sup>⊆</sup> **PN**(*x*, *<sup>t</sup>*) = **PN***λ*(*x*, *<sup>y</sup>*) = **MAT***λ*.

In the previous section we investigated arbitrary Petri net controlled grammars in dependence on the type of labeling functions and on the definitions of final markings, and showed that Petri net controlled grammars have the same power as some other regulating mechanisms such as matrices, finite automata. If we consider these matrices and finite automata in terms of control mechanisms, special types of matrices and special regular languages are widely investigated in literature, for instance, as control, simple matrices ([37]) or some subclasses of regular languages ([15, 17]) are considered. Thus, it is also natural to investigate grammars controlled by some special classes of Petri nets. We consider (generalized) state machines, (generalized) marked graphs, causal nets, (extended) free-choice nets, asymmetric choice nets and ordinary nets. Similarly to the general case we also investigate the effects of labeling policies and final markings to the computational power, and prove that the family of languages generated by (arbitrary) Petri net controlled grammars coincide with the family of

Let *G* = (*V*, Σ, *S*, *R*, *N*, *γ*, *M*) be an arbitrary Petri net controlled grammar. The grammar *G* is called a (generalized) state machine, (generalized) marked graph, causal net, (extended) free-choice net, asymmetric choice net or ordinary net controlled grammar if the net *N* is a (generalized) state machine, (generalized) marked graph, causal net, (extended) free-choice

(−*λ*, *<sup>y</sup>*) = **PN**[*λ*]

(*λ*, *y*).

without and with erasing rules, respectively, where *x* ∈ { *f* , −*λ*, *λ*} and *y* ∈ {*r*, *t*, *g*}.

(*f* , *y*) = **PN**[*λ*]

capacity of arbitrary Petri net controlled grammars.

**Theorem 9.** *For x* ∈ { *f* , −*λ*, *λ*} *and y* ∈ {*r*,*t*, *g*}*,*

**5. Grammars controlled by special Petri nets**

languages generated by grammars controlled by free-choice nets.

net, asymmetric choice net or ordinary net, respectively.

**PN**[*λ*]

**Theorem 8.** *For y* ∈ {*r*, *t*, *g*}*,*

.

The inclusion **<sup>X</sup>**(*x*, *<sup>y</sup>*) <sup>⊆</sup> **<sup>X</sup>***λ*(*x*, *<sup>y</sup>*) immediately follows from the definition where


*Example* 4*.* Let *G*<sup>4</sup> = ({*S*, *A*, *B*}, {*a*, *b*}, *S*, *R*, *N*4, *γ*, *M*) be a SM controlled grammar where *R* consists of

$$\begin{array}{ll} S \rightarrow AB\_{\prime} \\\\ A \rightarrow aA\_{\prime} \\\\ B \rightarrow aB\_{\prime} \end{array} \quad A \rightarrow bA\_{\prime} \quad A \rightarrow \lambda\_{\prime} \\\\ \begin{array}{ll} A \rightarrow aB\_{\prime} \\\\ B \rightarrow bB\_{\prime} \end{array} \quad B \rightarrow \lambda\_{\prime} $$

the Petri net *N*<sup>4</sup> illustrated in Figure 4 is a labeled state machine and *M* = {*μ*} where *μ*(*p*0) = 1 and *μ*(*p*) = 0 for all *p* ∈ *P* − {*p*0}, then

$$L(G\_4) = \{ ww \mid w \in \{a, b\}^\* \} \in \mathbf{SM}^\lambda(\lambda, t).$$

*Example* 5*.* Let *G*<sup>5</sup> = ({*S*, *A*, *B*}, {*a*, *b*}, *S*, *R*, *N*5, *γ*� , *M*� ) be a MG controlled grammar where *R* is as for the grammar *G*<sup>1</sup> in Example 4, a labeled marked graph *N*<sup>5</sup> is illustrated in Figure 5 and *M*� = {*μ*} where *μ*(*p*) = 0 for all *p* ∈ *P*. Then

$$L(\mathbf{G}\_{\mathsf{F}}) = \{ ww' \mid w \in \{a, b\}^\* \text{ and } w' \in \text{Perm}(w) \} \in \mathbf{MG}^\lambda(\lambda, t).$$

We have the same result on the labeling strategies as that in the previous section: the labeling of transitions of special Petri nets do not effect on the generative powers of the families of languages generated by grammars controlled by these nets.

**Theorem 10.** *For* **X** ∈ {**SM**, **GSM**, **MG**, **GMG**, **CN**, **FC**, **EFC**, **AC**, **ON**}*, and y* ∈ {*r*, *t*, *g*}*,*

$$\mathbf{X}^{[\lambda]}(f,y) = \mathbf{X}^{[\lambda]}(-\lambda,y) = \mathbf{X}^{[\lambda]}(\lambda,y).$$

The following theorem shows the relations of families of languages generated by special Petri net controlled grammars.

**Theorem 11.** *The following inclusions and equalities hold:*

(*x*, *y*) = **GMG**[*λ*]

) ⊆ **MG**(*x*, *y*�

(4) **CF** ⊂ **MAT** = **SM**(*x*, *y*) ⊆ **VEC** ⊆

{**MG**, **GMG**, **CN**}*,* **Z** ∈ {**SM**, **GSM**, **FC**, **EFC**, **AC**, **ON**}*.*

(*x*, *y*) *and* **PN**(*x*, *y*�

) <sup>⊆</sup> **MAT***λ*,

**GSM**(*x*, *t*)

) <sup>⊆</sup> **MAT***λ*,

) ⊆ **PN**(*x*, *y*�

(5) **MAT***<sup>λ</sup>* = **PN***λ*(*x*, *y*) = **PN**(*x*, *t*) = **X***λ*(*x*, *t*) = **Y***λ*(*x*, *t*) = **Z***λ*(*x*, *y*),

*where x* ∈ { *f* , −*λ*, *λ*}*, y* ∈ {*r*, *g*, *t*}*, y*� ∈ {*r*, *g*} *and* **X** ∈ {**FC**, **EFC**, **AC**, **ON**}*,* **Y** ∈

In this section we continue the research in this direction by restricting to (context-free, extended or arbitrary) Petri nets with place capacities. Quite obviously, a context-free Petri net with place capacity regulates the defining grammar by permitting only those derivations where the number of each nonterminal in each sentential form is bounded by its capacity. Similar mechanisms have been introduced and investigated by several authors. Grammar with *finite index* (the index of a grammar is the maximal number of nonterminals simultaneously appearing in its complete derivations (considering the most economical derivations for each string)) were first considered by Brainerd [7]. *Nonterminal-bounded* grammars (a grammar a nonterminal-bounded if the total number of nonterminals in every sentential form does not exceed an upper bound) were introduced by Altman and Banerji in [3–5]. A "weak" variant of nonterminal-bounded grammars (only the complete derivations are required to be bounded) were defined by Moriya [44]. Ginsburg and Spanier introduced *derivation-bounded* languages in [32] (all strings which have complete derivation in a grammar *G* consisting of sentential forms each of which does not contain more than *k* nonterminals collected in the set *Lk*(*G*)). There it was shown that grammars regulated in this way generate the family of context-free languages of finite index, even if arbitrary nonterminal strings are allowed as left-hand sides of production rules. Finite index restrictions to regulated grammars have also been investigated [29, 30, 48, 49, 51, 53–55]. There it was shown that the families of

In this section we show that capacity-bounded context-free grammars have a larger generative power than context-free grammars of finite index while the family of languages generated by capacity-bounded phrase structure grammars (due to Ginsburg and Spanier) and several families of languages generated by grammars controlled by extended cf Petri nets with place

We will now introduce capacity-bounded grammars and show some relations to similar

**Definition 9.** A *capacity-bounded* grammar is a tuple *G* = (*V*, Σ, *S*, *R*, *κ*) where *G*� = (*V*, Σ, *S*, *R*) is a grammar and *κ* : *V* → **N** is a capacity function. The derivation relation ⇒*<sup>G</sup>* is defined as *α* ⇒*<sup>G</sup> β* iff *α* ⇒*G*� *β* and |*α*|*<sup>A</sup>* ≤ *κ*(*A*) and |*β*|*<sup>A</sup>* ≤ *κ*(*A*), for all *A* ∈ *V*. The

*<sup>G</sup> w*}.

capacities coincide with the family of matrix languages of finite index.

) ⊆ **PN**(*x*, *y*�

) = **X**(*x*, *y*�

),

Grammars Controlled by Petri Nets 351

**CN**(*x*, *<sup>t</sup>*) <sup>⊆</sup> **MG**(*x*, *<sup>t</sup>*) <sup>⊆</sup> **MAT***λ*,

(1) **MG**[*λ*]

(2) **CN**(*x*, *y*�

(3) **MAT** ⊆ **GSM**(*x*, *y*�

**6. Capacity-bounded grammars**

most regulated languages are collapse.

concepts known from the literature.

language of *G* is defined as *L*(*G*) = {*w* ∈ Σ<sup>∗</sup> | *S* ⇒<sup>∗</sup>

**Figure 4.** A labeled state machine *N*<sup>4</sup>

**Figure 5.** A labeled marked graph *N*<sup>5</sup>

**Theorem 11.** *The following inclusions and equalities hold:*

14 Petri Nets

→ →

λ

→ →

λ

→ →

→ →

→λ →λ

→

→λ →λ

p

•

**Figure 4.** A labeled state machine *N*<sup>4</sup>

λ

**Figure 5.** A labeled marked graph *N*<sup>5</sup>

→

(1) **MG**[*λ*] (*x*, *y*) = **GMG**[*λ*] (*x*, *y*) *and* **PN**(*x*, *y*� ) = **X**(*x*, *y*� ), (2) **CN**(*x*, *y*� ) ⊆ **MG**(*x*, *y*� ) ⊆ **PN**(*x*, *y*� ) <sup>⊆</sup> **MAT***λ*, (3) **MAT** ⊆ **GSM**(*x*, *y*� ) ⊆ **PN**(*x*, *y*� ) <sup>⊆</sup> **MAT***λ*, (4) **CF** ⊂ **MAT** = **SM**(*x*, *y*) ⊆ **VEC** ⊆ **GSM**(*x*, *t*) **CN**(*x*, *<sup>t</sup>*) <sup>⊆</sup> **MG**(*x*, *<sup>t</sup>*) <sup>⊆</sup> **MAT***λ*, (5) **MAT***<sup>λ</sup>* = **PN***λ*(*x*, *y*) = **PN**(*x*, *t*) = **X***λ*(*x*, *t*) = **Y***λ*(*x*, *t*) = **Z***λ*(*x*, *y*),

*where x* ∈ { *f* , −*λ*, *λ*}*, y* ∈ {*r*, *g*, *t*}*, y*� ∈ {*r*, *g*} *and* **X** ∈ {**FC**, **EFC**, **AC**, **ON**}*,* **Y** ∈ {**MG**, **GMG**, **CN**}*,* **Z** ∈ {**SM**, **GSM**, **FC**, **EFC**, **AC**, **ON**}*.*

## **6. Capacity-bounded grammars**

In this section we continue the research in this direction by restricting to (context-free, extended or arbitrary) Petri nets with place capacities. Quite obviously, a context-free Petri net with place capacity regulates the defining grammar by permitting only those derivations where the number of each nonterminal in each sentential form is bounded by its capacity. Similar mechanisms have been introduced and investigated by several authors. Grammar with *finite index* (the index of a grammar is the maximal number of nonterminals simultaneously appearing in its complete derivations (considering the most economical derivations for each string)) were first considered by Brainerd [7]. *Nonterminal-bounded* grammars (a grammar a nonterminal-bounded if the total number of nonterminals in every sentential form does not exceed an upper bound) were introduced by Altman and Banerji in [3–5]. A "weak" variant of nonterminal-bounded grammars (only the complete derivations are required to be bounded) were defined by Moriya [44]. Ginsburg and Spanier introduced *derivation-bounded* languages in [32] (all strings which have complete derivation in a grammar *G* consisting of sentential forms each of which does not contain more than *k* nonterminals collected in the set *Lk*(*G*)). There it was shown that grammars regulated in this way generate the family of context-free languages of finite index, even if arbitrary nonterminal strings are allowed as left-hand sides of production rules. Finite index restrictions to regulated grammars have also been investigated [29, 30, 48, 49, 51, 53–55]. There it was shown that the families of most regulated languages are collapse.

In this section we show that capacity-bounded context-free grammars have a larger generative power than context-free grammars of finite index while the family of languages generated by capacity-bounded phrase structure grammars (due to Ginsburg and Spanier) and several families of languages generated by grammars controlled by extended cf Petri nets with place capacities coincide with the family of matrix languages of finite index.

We will now introduce capacity-bounded grammars and show some relations to similar concepts known from the literature.

**Definition 9.** A *capacity-bounded* grammar is a tuple *G* = (*V*, Σ, *S*, *R*, *κ*) where *G*� = (*V*, Σ, *S*, *R*) is a grammar and *κ* : *V* → **N** is a capacity function. The derivation relation ⇒*<sup>G</sup>* is defined as *α* ⇒*<sup>G</sup> β* iff *α* ⇒*G*� *β* and |*α*|*<sup>A</sup>* ≤ *κ*(*A*) and |*β*|*<sup>A</sup>* ≤ *κ*(*A*), for all *A* ∈ *V*. The language of *G* is defined as *L*(*G*) = {*w* ∈ Σ<sup>∗</sup> | *S* ⇒<sup>∗</sup> *<sup>G</sup> w*}.

#### 16 Petri Nets 352 Petri Nets – Manufacturing and Computer Science Grammars Controlled by Petri Nets <sup>17</sup>

The families of languages generated by capacity-bounded GS grammars and by context-free capacity-bounded grammars are denoted by **GS***cb* and **CF***cb*, respectively. The capacity function mapping each nonterminal to 1 is denoted by **1**. The notions of finite index and bounded capacities can be extended to matrix, vector and semi-matrix grammars. The corresponding language families are denoted by

The above example shows that capacity-bounded grammars – in contrast to derivation bounded grammars – can generate non-context-free languages. Moreover, any context-free language generated by a grammar of *G* of finite index is also generated by the

On the other hand, capacity-bounded GS grammars generate exactly the family of matrix languages of finite index. This is in contrast to derivation bounded grammars which generate

It turns out that capacity-bounded context-free grammars are strictly between context-free

The next theorem shows that the families of capacity bounded matrix and vector languages

As regards closure properties, we remark that the constructions showing the closure of **CF** under homomorphisms, union, concatenation and Kleene closure can be easily extended to

Regarding intersection with regular sets and inverse homomorphisms, we can show

**Theorem 17. CF***cb is neither closed under intersection with regular sets nor under inverse*

Control by Petri nets can in a natural way be adapted to Petri nets with place capacities. A context-free grammar is controlled by its context-free Petri net with place capacity by only allowing derivations that correspond to valid firing sequences respecting the capacity bounds. The (trivial) proof for the equivalence between context-free grammars and grammars controlled by cf Petri nets can be immediately transferred to context-free grammars and Petri

**Theorem 18.** *Grammars controlled by context-free Petri nets with place capacity functions generate*

*cb* be the language families generated by context-free and arbitrary grammars

Grammars Controlled by Petri Nets 353

capacity-bounded grammar (*G*, *κ*) where *κ* is capacity function constantly *k*.

*cb.*

*cb and* **GS***cb* <sup>=</sup> **GS**<sup>1</sup>

languages of finite index and matrix languages of finite index.

are exactly the family of matrix languages with finite index.

*cb* <sup>=</sup> **MAT**[*λ*]

*cb .*

**Theorem 16. CF***cb is closed under homomorphisms, union, concatenation and Kleene closure.*

Let **CF**<sup>1</sup>

*cb* and **GS**<sup>1</sup>

**Lemma 12. CF***cb* = **CF**<sup>1</sup>

with capacity function **1**. Then,

**Lemma 13. GS***cb* = **MAT***fin.*

**Theorem 15. MAT***fin* <sup>=</sup> **VEC**[*λ*]

non-closure properties.

*homomorphisms.*

nets with capacities:

the case of capacity-bounded languages.

*the family of capacity-bounded context-free languages.*

only context-free languages of finite index [32].

**Theorem 14. CF***fin* ⊂ **CF***cb* ⊂ **GS***cb* = **MAT***fin*.

$$\mathbf{MAT}\_{\textit{fin}}^{[\lambda]}, \mathbf{VEC}\_{\textit{fin}}^{[\lambda]}, \mathbf{s} \\ \mathbf{MAT}\_{\textit{fin}}^{[\lambda]}, \mathbf{MAT}\_{\textit{cb}}^{[\lambda]}, \mathbf{VEC}\_{\textit{cb}}^{[\lambda]}.$$

Capacity-bounded grammars are very similar to derivation-bounded grammars, which were studied in [32]. A *derivation-bounded* grammar is a quintuple *G* = (*V*, Σ, *S*, *R*, *k*) where *G*� = (*V*, Σ, *S*, *R*) is a grammar and *k* ∈ **N** is a bound on the number of allowed nonterminals. The language of *G* contains all words *w* ∈ *L*(*G*� ) that have a derivation *S* ⇒<sup>∗</sup> *w* such that |*β*|*<sup>V</sup>* ≤ *k*, for each sentential form *β* of the derivation.

Other related concepts are nonterminal-bounded grammars and grammars of finite index. A context-free grammar *G* = (*V*, Σ, *S*, *R*) is *nonterminal-bounded* if |*β*|*<sup>V</sup>* ≤ *k* for some fixed *k* ∈ **N** and all sentential forms *β* derivable in *G*. The *index* of a derivation in *G* is the maximal number of nonterminal symbols in its sentential forms. *G* is of *finite index* if every word in *L*(*G*) has a derivation of index at most *k* for some fixed *k* ∈ **N**. The family of context-free languages of finite index is denoted by **CF***fin*.

Note that there is a subtle difference between the first two and the last two concepts. While context-free nonterminal-bounded and finite index grammars are just context-free grammars with a certain structural property (and generate context-free languages by definition), capacity-bounded and derivation-bounded grammars are special cases of *regulated rewriting* (and could therefore generate non-context-free languages). However, it has been shown that the family of derivation bounded languages is equal to **CF***fin*, even if arbitrary grammars due to Ginsburg and Spanier are permitted [32]. We will now give an example of capacity-bounded grammars generating non-context-free languages.

*Example* 6*.* Let *G* = ({*S*, *A*, *B*, *C*, *D*, *E*, *F*}, {*a*, *b*, *c*}, *S*, *R*, **1**) be the capacity-bounded grammar where *R* consists of the rules:

$$\begin{array}{llll} r\_1: S \to ABCD, \ r\_2: AB \to aEFb, \ r\_3: CD \to cAD, \ r\_4: EF \to EC, \\ r\_5: EF \to FC, \quad r\_6: AD \to FD, \quad r\_7: AD \to ED, \quad r\_8: EC \to AB, \\ r\_9: FD \to CD, \quad r\_{10}: FC \to AF, \quad r\_{11}: AF \to \lambda, \quad r\_{12}: ED \to \lambda. \end{array}$$

The possible derivations are exactly those of the form

$$\begin{array}{l} \mathcal{S} \stackrel{r\_1}{\Rightarrow} ABCD\\ \stackrel{(r\_2r\_3r\_4r\_6r\_8r\_9)^n}{\Longrightarrow} a^n ABb^n c^n CD\\ \stackrel{r\_2r\_3}{\Longrightarrow} a^{n+1} EFb^{n+1} c^{n+1} AD\\ \stackrel{r\_5r\_7}{\Longrightarrow} a^{n+1} FCb^{n+1} c^{n+1} ED\\ \stackrel{r\_{10}r\_{11}r\_{12}}{\Longrightarrow} a^n b^n c^n \end{array}$$

(in the last phase, the sequences *r*10*r*12*r*<sup>11</sup> and *r*12*r*10*r*<sup>11</sup> could also be applied with the same result). Therefore,

$$L(G) = \{ a^n b^n c^n \mid n \ge 1 \}.$$

The above example shows that capacity-bounded grammars – in contrast to derivation bounded grammars – can generate non-context-free languages. Moreover, any context-free language generated by a grammar of *G* of finite index is also generated by the capacity-bounded grammar (*G*, *κ*) where *κ* is capacity function constantly *k*.

Let **CF**<sup>1</sup> *cb* and **GS**<sup>1</sup> *cb* be the language families generated by context-free and arbitrary grammars with capacity function **1**. Then,

$$\mathbf{\color{red}{Lemma 12.}}\mathbf{\color{red}{C}F\_{cb}} = \mathbf{\color{red}{C}F\_{cb}^{1}} \text{ and } \mathbf{\color{red}{G}S\_{cb}} = \mathbf{\color{red}{G}S\_{cb}^{1}}.$$

On the other hand, capacity-bounded GS grammars generate exactly the family of matrix languages of finite index. This is in contrast to derivation bounded grammars which generate only context-free languages of finite index [32].

**Lemma 13. GS***cb* = **MAT***fin.*

16 Petri Nets

The families of languages generated by capacity-bounded GS grammars and by context-free capacity-bounded grammars are denoted by **GS***cb* and **CF***cb*, respectively. The capacity function mapping each nonterminal to 1 is denoted by **1**. The notions of finite index and bounded capacities can be extended to matrix, vector and semi-matrix grammars. The

*fin* , **sMAT**[*λ*]

Capacity-bounded grammars are very similar to derivation-bounded grammars, which were studied in [32]. A *derivation-bounded* grammar is a quintuple *G* = (*V*, Σ, *S*, *R*, *k*) where *G*� = (*V*, Σ, *S*, *R*) is a grammar and *k* ∈ **N** is a bound on the number of allowed nonterminals. The

Other related concepts are nonterminal-bounded grammars and grammars of finite index. A context-free grammar *G* = (*V*, Σ, *S*, *R*) is *nonterminal-bounded* if |*β*|*<sup>V</sup>* ≤ *k* for some fixed *k* ∈ **N** and all sentential forms *β* derivable in *G*. The *index* of a derivation in *G* is the maximal number of nonterminal symbols in its sentential forms. *G* is of *finite index* if every word in *L*(*G*) has a derivation of index at most *k* for some fixed *k* ∈ **N**. The family of context-free languages of

Note that there is a subtle difference between the first two and the last two concepts. While context-free nonterminal-bounded and finite index grammars are just context-free grammars with a certain structural property (and generate context-free languages by definition), capacity-bounded and derivation-bounded grammars are special cases of *regulated rewriting* (and could therefore generate non-context-free languages). However, it has been shown that the family of derivation bounded languages is equal to **CF***fin*, even if arbitrary grammars due to Ginsburg and Spanier are permitted [32]. We will now give an example of

*Example* 6*.* Let *G* = ({*S*, *A*, *B*, *C*, *D*, *E*, *F*}, {*a*, *b*, *c*}, *S*, *R*, **1**) be the capacity-bounded grammar

*r*<sup>1</sup> : *S* → *ABCD*, *r*<sup>2</sup> : *AB* → *aEFb*, *r*<sup>3</sup> : *CD* → *cAD*, *r*<sup>4</sup> : *EF* → *EC*, *r*<sup>5</sup> : *EF* → *FC*, *r*<sup>6</sup> : *AD* → *FD*, *r*<sup>7</sup> : *AD* → *ED*, *r*<sup>8</sup> : *EC* → *AB*, *r*<sup>9</sup> : *FD* → *CD*, *r*<sup>10</sup> : *FC* → *AF*, *r*<sup>11</sup> : *AF* → *λ*, *r*<sup>12</sup> : *ED* → *λ*.

=======<sup>⇒</sup> *<sup>a</sup>nABbncnCD <sup>r</sup>*2*r*<sup>3</sup> <sup>=</sup><sup>⇒</sup> *<sup>a</sup>n*+1*EFbn*+1*cn*+1*AD <sup>r</sup>*5*r*<sup>7</sup> <sup>=</sup><sup>⇒</sup> *<sup>a</sup>n*+1*FCbn*+1*cn*+1*ED <sup>r</sup>*10*r*11*r*<sup>12</sup> ====<sup>⇒</sup> *<sup>a</sup>nbncn*

(in the last phase, the sequences *r*10*r*12*r*<sup>11</sup> and *r*12*r*10*r*<sup>11</sup> could also be applied with the same

*<sup>L</sup>*(*G*) = {*anbncn* <sup>|</sup> *<sup>n</sup>* <sup>≥</sup> <sup>1</sup>}.

*fin* , **MAT**[*λ*]

*cb* , **VEC**[*λ*] *cb* .

) that have a derivation *S* ⇒<sup>∗</sup> *w* such that |*β*|*<sup>V</sup>* ≤ *k*,

corresponding language families are denoted by

language of *G* contains all words *w* ∈ *L*(*G*�

finite index is denoted by **CF***fin*.

where *R* consists of the rules:

result). Therefore,

for each sentential form *β* of the derivation.

**MAT**[*λ*]

*fin* , **VEC**[*λ*]

capacity-bounded grammars generating non-context-free languages.

*<sup>S</sup> <sup>r</sup>*<sup>1</sup> = *ABCD* (*r*2*r*3*r*4*r*6*r*8*r*<sup>9</sup> )*<sup>n</sup>*

The possible derivations are exactly those of the form

It turns out that capacity-bounded context-free grammars are strictly between context-free languages of finite index and matrix languages of finite index.

**Theorem 14. CF***fin* ⊂ **CF***cb* ⊂ **GS***cb* = **MAT***fin*.

The next theorem shows that the families of capacity bounded matrix and vector languages are exactly the family of matrix languages with finite index.

$$\textbf{Theorem 15. } \textbf{MAT}\_{\textit{fin}} = \textbf{VEC}\_{cb}^{[\lambda]} = \textbf{MAT}\_{cb}^{[\lambda]}.$$

As regards closure properties, we remark that the constructions showing the closure of **CF** under homomorphisms, union, concatenation and Kleene closure can be easily extended to the case of capacity-bounded languages.

**Theorem 16. CF***cb is closed under homomorphisms, union, concatenation and Kleene closure.*

Regarding intersection with regular sets and inverse homomorphisms, we can show non-closure properties.

**Theorem 17. CF***cb is neither closed under intersection with regular sets nor under inverse homomorphisms.*

Control by Petri nets can in a natural way be adapted to Petri nets with place capacities. A context-free grammar is controlled by its context-free Petri net with place capacity by only allowing derivations that correspond to valid firing sequences respecting the capacity bounds. The (trivial) proof for the equivalence between context-free grammars and grammars controlled by cf Petri nets can be immediately transferred to context-free grammars and Petri nets with capacities:

**Theorem 18.** *Grammars controlled by context-free Petri nets with place capacity functions generate the family of capacity-bounded context-free languages.*

Let us now turn to grammars controlled by arbitrary Petri nets with capacities. Let *G* = (*V*, Σ, *S*, *R*, *N*, *γ*, *M*) be an arbitrary Petri net controlled grammar. *G* is called a grammar controlled by an arbitrary Petri net with place capacity if *N* is a Petri net with place capacity. The families of languages generated by grammars controlled by arbitrary Petri nets with place capacities (with erasing rules) is denoted by **PN***cb*(*x*, *y*) (**PN***<sup>λ</sup> cb*(*x*, *y*)) where *x* ∈ { *f* , −*λ*, *λ*} and *y* ∈ {*r*, *t*, *g*}.

question is emerged, what kind of languages can be generated if we derestrict this condition,

Grammars Controlled by Petri Nets 355

In all investigated types of Petri net controlled grammars, we only used the sequential firing mode of transitions. The consideration of simultaneous firing of transitions, another fundamental feature of Petri nets, opens a new direction for the future research: one can study *grammars controlled by Petri nets under parallel firing strategy*, which introduces concurrently

Grammar systems can be considered as a formal model for a phenomenon of solving a given problem by dividing it into subproblems (grammars) to be solved by several parts in turn (CD grammar systems) or in parallel (PC grammar systems). The control of derivations in grammar systems also allows increasing computational power grammar systems. We can extend the regulation of a rule by a transition to the regulation a set of rules by a transition, which defines a new type of grammar systems: the firing of a transition allows applying

In [19–22, 41, 62] it was shown that by adding places and arcs which satisfy some structural requirements one can generate well-known families of languages as random context languages, valence languages, vector languages and matrix languages. Thus, the control by Petri nets can be considered as a unifying approach to different types of control. On the other hand, Petri nets can be transformed into *occurrence nets*, i.e., usually an infinite, tree-like structure whose nodes have the same labels as those of the places and transitions of the Petri net preserving the relationship of adjacency, using *unfolding technique* introduced in [43] and given in [24] in detail under the name of *branching processes*. Any *finite initial* part, i.e., *prefix* of the occurrence net of a cf Petri net can be considered as a derivation tree for the corresponding context-free grammar as it has the same structure as a usual derivation tree, here we can also accept the rule of reading "leaf"-places with tokens from the left to the right as in usual derivation trees. We can also generalize this idea for regulated grammars considering prefixes of the occurrences nets obtained from cf Petri nets with additional places. Hence, we can take into consideration the grammar as well as its control, and construct (Petri net) derivation trees for regulated grammars, which help to construct effective parsing algorithms for regulated rewriting systems. Though the preliminary results (general parsing algorithms, Early-like parsing algorithm for deterministic extended context-free Petri net controlled grammars, etc.) were obtained in [63, 64], the problem of the development of the effective parsing algorithms

This work has been supported by Ministry of Higher Education of Malaysia via Fundamental Research Grant Scheme FRGS /1/11/SG/UPM/01/1 and Universiti Putra Malaysia via

*Fakultät für Informatik, Otto-von-Guericke-Universität Magdeburg, Magdeburg, Germany*

several (assigned) rules in a derivation step parallelly and different modes.

i.e., allow any string in the left-hand side of the rules?

parallelism in formal language theory.

for regulated grammars remain open.

**Acknowledgements**

RUGS 05-01-10-0896RU/F1.

Jürgen Dassow and Ralf Stiebe

**Author details**

The next statement indicates that the language generated by a grammar controlled by an arbitrary Petri net with place capacities iff it is generated by a matrix grammar (for details, see [56]).

**Theorem 19.** *For x* ∈ { *f* , −*λ*, *λ*} *and y* ∈ {*r*, *t*, *g*}*,*

$$\mathbf{PN}\_{cb}(\mathbf{x}, \boldsymbol{y}) = \mathbf{MAT} \subseteq \mathbf{PN}\_{cb}^{\lambda}(\mathbf{x}, \boldsymbol{y}) = \mathbf{MAT}^{\lambda}.$$

We summarize our results in the following theorem.

**Theorem 20.** *The following inclusions and equalities hold:*

$$\begin{aligned} \mathbf{CF}\_{\textit{fin}} &\subset \mathbf{CF}\_{cb} = \mathbf{CF}\_{cb}^{1} \\ &\subset \mathbf{M} \mathbf{AT}\_{\textit{fin}} = \mathbf{M} \mathbf{AT}\_{cb}^{[\lambda]} = \mathbf{VEC}\_{cb}^{[\lambda]} = \mathbf{GS}\_{cb} = \mathbf{GS}\_{cb}^{1} \\ &\subset \mathbf{M} \mathbf{AT} = \mathbf{PN}\_{cb}(\mathbf{x}, \mathbf{y}) \subseteq \mathbf{M} \mathbf{AT}^{\lambda} = \mathbf{PN}\_{cb}^{\lambda}(\mathbf{x}, \mathbf{y}) \end{aligned}$$

*where x* ∈ { *f* , −*λ*, *λ*} *and y* ∈ {*r*, *t*, *g*}*.*
