**2. Preliminaries**

2 Petri Nets

context, valence grammars, and etc., have been introduced (see [16]). However, the rapid developments in present day technology, industry, medicine and other areas challenge to deal with more and more new and complex problems, and to look for new suitable tools for the modeling and investigation of these problems. *Petri net controlled grammars*, which introduce *concurrently parallel control mechanisms* in formal language theory, were proposed as a theoretical model for some problems appearing in systems biology and automated

Petri nets, which are graphical and mathematical modeling tools applicable to many concurrent, asynchronous, distributed, parallel, nondeterministic and stochastic systems, have widely been used in the study of formal languages. One of the fundamental approaches in this area is to consider Petri nets as language generators. If the transitions in a Petri net are labeled with a set of (not necessary distinct) symbols, a sequence of transition firing generates a string of symbols. The set of strings generated by all possible firing sequences defines a language called a Petri net language, which can be used to model the flow of information and control of actions in a system. With different kinds of labeling functions and different kinds of final marking sets, various classes of Petri net languages were introduced and investigated by Hack [34] and Peterson [46]. The relationship between Petri net languages and formal languages were thoroughly investigated by Peterson in [47]. It was shown that all regular languages are Petri net languages and the family of Petri net languages are strictly included in the family of context-sensitive languages but some Petri net languages are not context-free and some context-free languages are not Petri net languages. It was also shown that the

Another approach to the investigation of formal languages was considered by Crespi-Reghizzi and Mandrioli [11]. They noticed the similarity between the firing of a transition and application of a production rule in a derivation in which places are nonterminals and tokens are separate instances of the nonterminals. The major difference of this approach is the lack of ordering information in the Petri net contained in the sentential form of the derivation. To accommodate it, they defined the commutative grammars, which are isomorphic to Petri nets. In addition, they considered the relationship of Petri nets to matrix, scattered-context, nonterminal-bounded, derivation-bounded, equal-matrix and Szilard languages in [13].

The approach proposed by Crespi-Reghizzi and Mandrioli was used in the following works. By extending the type of Petri nets introduced in [11] with the places for the terminal symbols and arcs for the control of nonterminal occurrences in sentential forms, Marek and Ceška showed that for every random-context grammar, an isomorphic Petri net can be

constructed, where each derivation of the grammar is simulated by some occurrence sequence of transitions of the Petri net, and vice versa. In [39] the relationship between vector grammars and Petri nets was investigated, partially, hybrid Petri nets were introduced and the equality of the family of hybrid Petri net languages and the family of vector languages was shown. By reduction to Petri net reachability problems, Hauschildt and Jantzen [35] could solve a number of open problems in regulated rewriting systems, specifically, every matrix language without appearance checking over one letter alphabet is regular and the finiteness problem for the families of matrix and random context languages is decidable; In several papers [2, 14, 25], Petri nets are used as minimization techniques for context-free (graph) grammars. For instance, in [2], algorithms to eliminate erasing and unit (chain) rules, algorithms to

manufacturing systems (see [18–23, 56, 59–62]).

complement of a free Petri net language is context-free [12].

remove useless rules using the Petri net concept are introduced.

ˇ

In this section we recall some prerequisites, by giving basic notions and notations of the theories formal languages, Petri nets and Petri net languages which are used in the next sections. The reader is referred to [16, 34, 36, 42, 45, 47, 50, 52] for further information.

#### **2.1 General notions and notations**

Throughout the chapter we use the following general notations. ∈ denotes the membership of an element to a set while the negation of set membership is denoted by �∈. The inclusion is denoted by ⊆ and the strict (proper) inclusion is denoted by ⊂. The symbol ∅ denotes the empty set. The set of positive (non-negative) integers is denoted by **N** (**N**0). The set of integers is denoted by **Z**. The power set of a set *X* is denoted by 2*X*, while the cardinality of a set *X* is denoted by |*X*|.

**2.3 Regulated grammars**

grammar *<sup>G</sup>* is *<sup>L</sup>*(*G*) = {*<sup>w</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> <sup>|</sup> *<sup>S</sup> <sup>π</sup>*

grammars.

∑*j*

*<sup>i</sup>*=<sup>1</sup> *v*(*ri*) ≥ 0.

**2.4 Petri nets**

*weight function*.

The idea of regulated rewriting consists of restricting the application of the rules in a context-free grammar in order to avoid some derivations and hence obtaining a subset of the context-free language generated in usual way. The computational power of some context-free grammars with regulated rewriting turns out to be greater than the power of context-free

A *regularly controlled grammar* is a quintuple *G* = (*V*, Σ, *S*, *R*, *K*) where *V*, Σ, *S*, *R* are specified as in a context-free grammar and *K* is a regular set over *R*. The language generated by *G* consists of all words *<sup>w</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> such that there is a derivation *<sup>S</sup> <sup>r</sup>*1*r*2···*rn* ====<sup>⇒</sup> *<sup>w</sup>* where *<sup>r</sup>*1*r*<sup>2</sup> ···*rn* <sup>∈</sup> *<sup>K</sup>*. A *matrix grammar* is a quadruple *G* = (*V*, Σ, *S*, *M*) where *V*, Σ, *S* are defined as for a context-free grammar, *M* is a finite set of *matrices* which are finite strings over a set *R* of context-free rules (or finite sequences of context-free rules). The language generated by the

=⇒ *w* and *π* ∈ *M*∗}. A *vector grammar* is a quadruple *G* = (*V*, Σ, *S*, *M*) whose components are defined as for a

An *additive valence grammar* is a quintuple *G* = (*V*, Σ, *S*, *R*, *v*) where *V*, Σ, *S*, *R* are defined as for a context-free grammar and *v* is a mapping from *R* into **Z**. The language generated by *G*

A *positive valence grammar* is a quintuple *G* = (*V*, Σ, *S*, *R*, *v*) whose components are defined as for additive valence grammars. The language generated by *G* consists of all strings *w* ∈ Σ<sup>∗</sup>

The families of languages generated by regularly controlled, matrix, vector, additive valence and positive valence grammars (with erasing rules) are denoted by **rC**, **MAT**, **VEC**, **aV**, **pV**

(3) **MAT** <sup>⊆</sup> **MAT***<sup>λ</sup>* <sup>=</sup> **rC***<sup>λ</sup>* <sup>=</sup> **VEC***<sup>λ</sup>* <sup>=</sup> **pV***<sup>λ</sup>* <sup>⊂</sup> **RE**.

A *Petri net* (PN) is a construct *N* = (*P*, *T*, *F*, *φ*) where *P* and *T* are disjoint finite sets of *places* and *transitions*, respectively, *F* ⊆ (*P* × *T*) ∪ (*T* × *P*) is the set of *directed arcs*, *φ* : *F* → **N** is a

A Petri net can be represented by a bipartite directed graph with the node set *P* ∪ *T* where places are drawn as *circles*, transitions as *boxes* and arcs as *arrows*. The arrow representing an

=⇒ *w* and *π* ∈ Shuf∗(*M*)}.

*<sup>i</sup>*=<sup>1</sup> *v*(*ri*) = 0.

Grammars Controlled by Petri Nets 341

*<sup>i</sup>*=<sup>1</sup> *v*(*ri*) = 0 and for any 1 ≤ *j* < *n*,

matrix grammar. The language generated by the grammar *G* is defined by

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*<sup>2</sup> ···*rn* ====<sup>⇒</sup> *<sup>w</sup>* where <sup>∑</sup>*<sup>n</sup>*

**Theorem 2.** *The following inclusions and equalities hold (for details, see [16]):*

arc (*x*, *y*) ∈ *F* is labeled with *φ*(*x*, *y*); if *φ*(*x*, *y*) = 1, then the label is omitted.

(2) **MAT** ⊆ **VEC** ⊂ **CS**;

(1) **CF** <sup>⊂</sup> **aV** <sup>=</sup> **aV***<sup>λ</sup>* <sup>⊂</sup> **MAT** <sup>=</sup> **rC** <sup>=</sup> **pV**;

*<sup>L</sup>*(*G*) = {*<sup>w</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> <sup>|</sup> *<sup>S</sup> <sup>π</sup>*

such that there is a derivation *<sup>S</sup> <sup>r</sup>*1*r*2···*rn* ====<sup>⇒</sup> *<sup>w</sup>* where <sup>∑</sup>*<sup>n</sup>*

(**rC***λ*, **MAT***λ*, **VEC***λ*, **aV***λ*, **pV***λ*), respectively.

Let Σ be an *alphabet* which is a finite nonempty set of symbols. A *string* (sometimes a *word*) over the alphabet Σ is a finite sequence of symbols from Σ. The *empty* string is denoted by *λ*. The *length* of a word *w*, denoted by |*w*|, is the number of occurrences of symbols in *w*. The number of occurrences of a symbol *a* in a string *w* is denoted by |*w*|*a*. The set of all strings over the alphabet Σ is denoted by Σ∗. The set of nonempty strings over Σ is denoted by Σ+, i.e., <sup>Σ</sup><sup>+</sup> <sup>=</sup> <sup>Σ</sup><sup>∗</sup> − {*λ*}. A subset of <sup>Σ</sup><sup>∗</sup> is called a *language*. A language *<sup>L</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> is *<sup>λ</sup>*-*free* if *<sup>λ</sup>* �∈ *<sup>L</sup>*. For two languages *L*1, *L*<sup>2</sup> ⊆ Σ<sup>∗</sup> the *operation shuffle* is defined by

> Shuf(*L*1, *L*2) = {*u*1*v*1*u*2*v*<sup>2</sup> ··· *unvn* | *u*1*u*<sup>2</sup> ··· *un* ∈ *L*1, *v*1*v*<sup>2</sup> ··· *vn* ∈ *L*2, *ui*, *vi* ∈ Σ∗, 1 ≤ *i* ≤ *n*}

and for *<sup>L</sup>* ⊆ <sup>Σ</sup>∗, Shuf∗(*L*) = *<sup>k</sup>*≥<sup>1</sup> Shuf*<sup>k</sup>* (*L*) where

$$\text{Shuf}^1(L) = L \text{ and } \text{Shuf}^k(L) = \text{Shuf}(\text{Shuf}^{k-1}(L), L), k \ge 2.$$

#### **2.2 Grammars**

A *phrase structure* (*Chomsky*) grammar is a quadruple *G* = (*V*, Σ, *S*, *R*) where *V* and Σ are two disjoint alphabets of *nonterminal* and *terminal* symbols, respectively, *S* ∈ *V* is the *start symbol* and *R* ⊆ (*V* ∪ Σ)∗*V*(*V* ∪ Σ)<sup>∗</sup> × (*V* ∪ Σ)<sup>∗</sup> is a finite set of (*production*) *rules*. Usually, a rule (*u*, *v*) ∈ *R* is written in the form *u* → *v*. A rule of the form *u* → *λ* is called an *erasing rule*.

A phrase structure grammar *G* = (*V*, Σ, *S*, *R*) is called a *GS grammar* (a phrase structure grammar due to Ginsburg and Spanier [31]) if *<sup>R</sup>* <sup>⊆</sup> *<sup>V</sup>*<sup>+</sup> <sup>×</sup> (*<sup>V</sup>* <sup>∪</sup> <sup>Σ</sup>)∗.

The families of languages generated by GS grammars and by phrase structure grammars are denoted by **GS** and **RE**, respectively. It is well-known that the family **GS** is equal to the family **RE**.

A string *x* ∈ (*V* ∪ Σ)<sup>∗</sup> *directly derives* a string *y* ∈ (*V* ∪ Σ)<sup>∗</sup> in *G*, written as *x* ⇒ *y* if and only if there is a rule *u* → *v* ∈ *R* such that *x* = *x*1*ux*<sup>2</sup> and *y* = *x*1*vx*<sup>2</sup> for some *x*1, *x*<sup>2</sup> ∈ (*V* ∪ Σ)∗. The reflexive and transitive closure of the relation ⇒ is denoted by ⇒∗. A derivation using the sequence of rules *<sup>π</sup>* <sup>=</sup> *<sup>r</sup>*1*r*<sup>2</sup> ···*rk*, *ri* <sup>∈</sup> *<sup>R</sup>*, 1 <sup>≤</sup> *<sup>i</sup>* <sup>≤</sup> *<sup>k</sup>*, is denoted by *<sup>π</sup>* <sup>=</sup><sup>⇒</sup> or *<sup>r</sup>*1*r*2···*rk* ====⇒. The *language* generated by *G*, denoted by *L*(*G*), is defined by *L*(*G*) = {*w* ∈ Σ<sup>∗</sup> | *S* ⇒<sup>∗</sup> *w*}.

A phrase-structure grammar *G* = (*V*, Σ, *S*, *R*) is called *context-sensitive* if each rule *u* → *v* ∈ *R* has *<sup>u</sup>* <sup>=</sup> *<sup>u</sup>*1*Au*2, *<sup>v</sup>* <sup>=</sup> *<sup>u</sup>*1*xu*<sup>2</sup> for *<sup>u</sup>*1, *<sup>u</sup>*<sup>2</sup> <sup>∈</sup> (*<sup>V</sup>* <sup>∪</sup> <sup>Σ</sup>)∗, *<sup>A</sup>* <sup>∈</sup> *<sup>V</sup>* and *<sup>x</sup>* <sup>∈</sup> (*<sup>V</sup>* <sup>∪</sup> <sup>Σ</sup>)<sup>+</sup> (in context sensitive grammars *S* → *λ* is allowed, provided that *S* does not appear in the right-hand members of rules in *R*); *context-free* if each rule *u* → *v* ∈ *R* has *u* ∈ *V*; *linear* if each rule *u* → *v* ∈ *R* has *u* ∈ *V* and *v* ∈ Σ<sup>∗</sup> ∪ Σ∗*V*Σ∗; *regular* if each rule *u* → *v* ∈ *R* has *u* ∈ *V* and *v* ∈ Σ ∪ Σ*V*.

The families of languages generated by context-sensitive, context-free, linear and regular grammars are denoted by **CS**, **CF**, **LIN** and **REG**, respectively. Further we denote the family of finite languages by **FIN**. The next strict inclusions, named *Chomsky hierarchy*, hold (for details, see [52]):

**Theorem 1. FIN** ⊂ **REG** ⊂ **LIN** ⊂ **CF** ⊂ **CS** ⊂ **RE**.

#### **2.3 Regulated grammars**

4 Petri Nets

is denoted by ⊆ and the strict (proper) inclusion is denoted by ⊂. The symbol ∅ denotes the empty set. The set of positive (non-negative) integers is denoted by **N** (**N**0). The set of integers is denoted by **Z**. The power set of a set *X* is denoted by 2*X*, while the cardinality of a

Let Σ be an *alphabet* which is a finite nonempty set of symbols. A *string* (sometimes a *word*) over the alphabet Σ is a finite sequence of symbols from Σ. The *empty* string is denoted by *λ*. The *length* of a word *w*, denoted by |*w*|, is the number of occurrences of symbols in *w*. The number of occurrences of a symbol *a* in a string *w* is denoted by |*w*|*a*. The set of all strings over the alphabet Σ is denoted by Σ∗. The set of nonempty strings over Σ is denoted by Σ+, i.e., <sup>Σ</sup><sup>+</sup> <sup>=</sup> <sup>Σ</sup><sup>∗</sup> − {*λ*}. A subset of <sup>Σ</sup><sup>∗</sup> is called a *language*. A language *<sup>L</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> is *<sup>λ</sup>*-*free* if *<sup>λ</sup>* �∈ *<sup>L</sup>*.

Shuf(*L*1, *L*2) = {*u*1*v*1*u*2*v*<sup>2</sup> ··· *unvn* | *u*1*u*<sup>2</sup> ··· *un* ∈ *L*1, *v*1*v*<sup>2</sup> ··· *vn* ∈ *L*2,

A *phrase structure* (*Chomsky*) grammar is a quadruple *G* = (*V*, Σ, *S*, *R*) where *V* and Σ are two disjoint alphabets of *nonterminal* and *terminal* symbols, respectively, *S* ∈ *V* is the *start symbol* and *R* ⊆ (*V* ∪ Σ)∗*V*(*V* ∪ Σ)<sup>∗</sup> × (*V* ∪ Σ)<sup>∗</sup> is a finite set of (*production*) *rules*. Usually, a rule (*u*, *v*) ∈ *R* is written in the form *u* → *v*. A rule of the form *u* → *λ* is called an *erasing rule*. A phrase structure grammar *G* = (*V*, Σ, *S*, *R*) is called a *GS grammar* (a phrase structure

The families of languages generated by GS grammars and by phrase structure grammars are denoted by **GS** and **RE**, respectively. It is well-known that the family **GS** is equal to the family

A string *x* ∈ (*V* ∪ Σ)<sup>∗</sup> *directly derives* a string *y* ∈ (*V* ∪ Σ)<sup>∗</sup> in *G*, written as *x* ⇒ *y* if and only if there is a rule *u* → *v* ∈ *R* such that *x* = *x*1*ux*<sup>2</sup> and *y* = *x*1*vx*<sup>2</sup> for some *x*1, *x*<sup>2</sup> ∈ (*V* ∪ Σ)∗. The reflexive and transitive closure of the relation ⇒ is denoted by ⇒∗. A derivation using the

A phrase-structure grammar *G* = (*V*, Σ, *S*, *R*) is called *context-sensitive* if each rule *u* → *v* ∈ *R* has *<sup>u</sup>* <sup>=</sup> *<sup>u</sup>*1*Au*2, *<sup>v</sup>* <sup>=</sup> *<sup>u</sup>*1*xu*<sup>2</sup> for *<sup>u</sup>*1, *<sup>u</sup>*<sup>2</sup> <sup>∈</sup> (*<sup>V</sup>* <sup>∪</sup> <sup>Σ</sup>)∗, *<sup>A</sup>* <sup>∈</sup> *<sup>V</sup>* and *<sup>x</sup>* <sup>∈</sup> (*<sup>V</sup>* <sup>∪</sup> <sup>Σ</sup>)<sup>+</sup> (in context sensitive grammars *S* → *λ* is allowed, provided that *S* does not appear in the right-hand members of rules in *R*); *context-free* if each rule *u* → *v* ∈ *R* has *u* ∈ *V*; *linear* if each rule *u* → *v* ∈ *R* has *u* ∈ *V* and *v* ∈ Σ<sup>∗</sup> ∪ Σ∗*V*Σ∗; *regular* if each rule *u* → *v* ∈ *R* has *u* ∈ *V* and *v* ∈ Σ ∪ Σ*V*.

The families of languages generated by context-sensitive, context-free, linear and regular grammars are denoted by **CS**, **CF**, **LIN** and **REG**, respectively. Further we denote the family of finite languages by **FIN**. The next strict inclusions, named *Chomsky hierarchy*, hold (for

(*L*) = Shuf(Shuf*k*−1(*L*), *<sup>L</sup>*), *<sup>k</sup>* <sup>≥</sup> 2.

<sup>=</sup><sup>⇒</sup> or *<sup>r</sup>*1*r*2···*rk* ====⇒. The *language*

*ui*, *vi* ∈ Σ∗, 1 ≤ *i* ≤ *n*}

*<sup>k</sup>*≥<sup>1</sup> Shuf*k*(*L*) where

For two languages *L*1, *L*<sup>2</sup> ⊆ Σ<sup>∗</sup> the *operation shuffle* is defined by

Shuf1(*L*) = *L* and Shuf*<sup>k</sup>*

grammar due to Ginsburg and Spanier [31]) if *<sup>R</sup>* <sup>⊆</sup> *<sup>V</sup>*<sup>+</sup> <sup>×</sup> (*<sup>V</sup>* <sup>∪</sup> <sup>Σ</sup>)∗.

sequence of rules *<sup>π</sup>* <sup>=</sup> *<sup>r</sup>*1*r*<sup>2</sup> ···*rk*, *ri* <sup>∈</sup> *<sup>R</sup>*, 1 <sup>≤</sup> *<sup>i</sup>* <sup>≤</sup> *<sup>k</sup>*, is denoted by *<sup>π</sup>*

**Theorem 1. FIN** ⊂ **REG** ⊂ **LIN** ⊂ **CF** ⊂ **CS** ⊂ **RE**.

generated by *G*, denoted by *L*(*G*), is defined by *L*(*G*) = {*w* ∈ Σ<sup>∗</sup> | *S* ⇒<sup>∗</sup> *w*}.

set *X* is denoted by |*X*|.

and for *<sup>L</sup>* ⊆ <sup>Σ</sup>∗, Shuf∗(*L*) =

**2.2 Grammars**

details, see [52]):

**RE**.

The idea of regulated rewriting consists of restricting the application of the rules in a context-free grammar in order to avoid some derivations and hence obtaining a subset of the context-free language generated in usual way. The computational power of some context-free grammars with regulated rewriting turns out to be greater than the power of context-free grammars.

A *regularly controlled grammar* is a quintuple *G* = (*V*, Σ, *S*, *R*, *K*) where *V*, Σ, *S*, *R* are specified as in a context-free grammar and *K* is a regular set over *R*. The language generated by *G* consists of all words *<sup>w</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> such that there is a derivation *<sup>S</sup> <sup>r</sup>*1*r*2···*rn* ====<sup>⇒</sup> *<sup>w</sup>* where *<sup>r</sup>*1*r*<sup>2</sup> ···*rn* <sup>∈</sup> *<sup>K</sup>*.

A *matrix grammar* is a quadruple *G* = (*V*, Σ, *S*, *M*) where *V*, Σ, *S* are defined as for a context-free grammar, *M* is a finite set of *matrices* which are finite strings over a set *R* of context-free rules (or finite sequences of context-free rules). The language generated by the grammar *<sup>G</sup>* is *<sup>L</sup>*(*G*) = {*<sup>w</sup>* <sup>∈</sup> <sup>Σ</sup><sup>∗</sup> <sup>|</sup> *<sup>S</sup> <sup>π</sup>* =⇒ *w* and *π* ∈ *M*∗}.

A *vector grammar* is a quadruple *G* = (*V*, Σ, *S*, *M*) whose components are defined as for a matrix grammar. The language generated by the grammar *G* is defined by

$$L(G) = \{ w \in \Sigma^\* \mid \mathbb{S} \stackrel{\pi}{\Rightarrow} w \text{ and } \pi \in \text{Shuf}^\*(M) \}.$$

An *additive valence grammar* is a quintuple *G* = (*V*, Σ, *S*, *R*, *v*) where *V*, Σ, *S*, *R* are defined as for a context-free grammar and *v* is a mapping from *R* into **Z**. The language generated by *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*<sup>2</sup> ···*rn* ====<sup>⇒</sup> *<sup>w</sup>* where <sup>∑</sup>*<sup>n</sup> <sup>i</sup>*=<sup>1</sup> *v*(*ri*) = 0.

A *positive valence grammar* is a quintuple *G* = (*V*, Σ, *S*, *R*, *v*) whose components are defined as for additive valence grammars. The language generated by *G* consists of all strings *w* ∈ Σ<sup>∗</sup> such that there is a derivation *<sup>S</sup> <sup>r</sup>*1*r*2···*rn* ====<sup>⇒</sup> *<sup>w</sup>* where <sup>∑</sup>*<sup>n</sup> <sup>i</sup>*=<sup>1</sup> *v*(*ri*) = 0 and for any 1 ≤ *j* < *n*, ∑*j <sup>i</sup>*=<sup>1</sup> *v*(*ri*) ≥ 0.

The families of languages generated by regularly controlled, matrix, vector, additive valence and positive valence grammars (with erasing rules) are denoted by **rC**, **MAT**, **VEC**, **aV**, **pV** (**rC***λ*, **MAT***λ*, **VEC***λ*, **aV***λ*, **pV***λ*), respectively.

**Theorem 2.** *The following inclusions and equalities hold (for details, see [16]):*

$$\begin{aligned} &(1) \; \mathbf{CF} \subset \mathbf{a} \mathbf{V} = \mathbf{a} \mathbf{V}^{\lambda} \subset \mathbf{M} \mathbf{A} \mathbf{T} = \mathbf{r} \mathbf{C} = \mathbf{p} \mathbf{V};\\ &(2) \; \mathbf{M} \mathbf{A} \mathbf{T} \subseteq \mathbf{V} \mathbf{E} \mathbf{C} \subset \mathbf{C} \mathbf{S};\\ &(3) \; \mathbf{M} \mathbf{A} \mathbf{T} \subseteq \mathbf{M} \mathbf{A} \mathbf{T}^{\lambda} = \mathbf{r} \mathbf{C}^{\lambda} = \mathbf{V} \mathbf{E} \mathbf{C}^{\lambda} = \mathbf{p} \mathbf{V}^{\lambda} \subset \mathbf{R} \mathbf{E}.\end{aligned}$$

#### **2.4 Petri nets**

A *Petri net* (PN) is a construct *N* = (*P*, *T*, *F*, *φ*) where *P* and *T* are disjoint finite sets of *places* and *transitions*, respectively, *F* ⊆ (*P* × *T*) ∪ (*T* × *P*) is the set of *directed arcs*, *φ* : *F* → **N** is a *weight function*.

A Petri net can be represented by a bipartite directed graph with the node set *P* ∪ *T* where places are drawn as *circles*, transitions as *boxes* and arcs as *arrows*. The arrow representing an arc (*x*, *y*) ∈ *F* is labeled with *φ*(*x*, *y*); if *φ*(*x*, *y*) = 1, then the label is omitted.

An *ordinary net* (ON) is a Petri net *N* = (*P*, *T*, *F*, *φ*) where *φ*(*x*, *y*) = 1 for all (*x*, *y*) ∈ *F*. We omit *φ* from the definition of an ordinary net, i.e., *N* = (*P*, *T*, *F*).

A *state machine* (SM) is an ordinary Petri net such that each transition has exactly one input

A *marked graph* (MG) is an ordinary Petri net such that each place has exactly one input

A *casual net* (CN) is a generalized marked graph each subgraph of which is not a a cycle.

A *free-choice* net (FC) is an ordinary Petri net such every arc is either the only arc going from

for all *p*1, *p*<sup>2</sup> ∈ *P*. This means that there can be both concurrency and conflict but not the same

Since a context-free grammar and its derivation process can also be described by a Petri net (see [11]), where places correspond to nonterminals, transitions are the counterpart of the production rules, and the tokens reflect the occurrences of symbols in the sentential form, and there is a one-to-one correspondence between the application of (sequence of) rules and the firing of (sequence of) transitions, it is a very natural and very easy idea to control the derivations in a context-free grammar by adding some features to the associated Petri net. In this section we introduce a Petri net associated with a context-free grammar (i.e., a *context-free Petri net*), construct Petri net control mechanisms from cf Petri nets by adding new places, and

The construction of the following type of Petri nets is based on the idea of using similarity between the firing of a transition and the application of a production rule in a derivation in

**Definition 1.** A *context-free Petri net* (in short, a *cf Petri net*) w.r.t. a context-free grammar

• there is an arc from place *p* to transition *t* if and only if *γ*(*t*) = *A* → *α* and *β*(*p*) = *A*. The

which places are nonterminals and tokens are separate occurrences of nonterminals.

<sup>2</sup> for all *p*1, *p*<sup>2</sup> ∈ *P*. In asymmetric choice nets concurrency and conflict (in sum,

•| = 1 for all *t* ∈ *T*. This means that there can

• *p*| = |*p*•| = 1 for all *p* ∈ *P*. This means that

<sup>2</sup> �= ∅ then |*p*•

<sup>1</sup> ∩ *p*•

<sup>1</sup> ∩ *p*•

<sup>1</sup> ∩ *p*•

•*t*| ≤ 1 and |*t*•| ≤ 1 for all

Grammars Controlled by Petri Nets 343

• *p*| ≤ 1 and |*p*•| ≤ 1 for

<sup>2</sup> �= ∅ then *p*•

<sup>2</sup> �= ∅ then *p*•

<sup>1</sup> | = |*p*•

<sup>2</sup> | = 1

<sup>1</sup> = *p*• 2

<sup>1</sup> ⊆ *p*• 2

•*t*| = |*t*

A *generalized state machine* (GSM) is an ordinary Petri net such that |

A *generalized marked graph* (GMG) is an ordinary Petri net such that |

An *extended free-choice* net (EFC) is an ordinary Petri net such that if *p*•

An *asymmetric choice net* (AC) is an ordinary Petri net such that if *p*•

define the corresponding grammars, called *k*-*Petri net controlled grammars*.

*G* = (*V*, Σ, *S*, *R*) is a septuple *N* = (*P*, *T*, *F*, *φ*, *β*, *γ*, *ι*) where

• labeling functions *β* : *P* → *V* and *γ* : *T* → *R* are bijections;

• (*P*, *T*, *F*, *φ*) is a Petri net;

weight of the arc (*p*, *t*) is 1;

the place, or it is the only arc going to a transition, i.e., that if *p*•

place and exactly one output place, i.e., |

*t* ∈ *T*.

all *p* ∈ *P*.

time.

or *p*•

for all *p*1, *p*<sup>2</sup> ∈ *P*.

<sup>1</sup> ⊇ *p*•

not be concurrency but there can be conflict.

transition and exactly one output transition, i.e., |

confusion) may occur but not asymmetrically.

**3.** *k***-Petri net controlled grammars**

there can not be conflict but there can be concurrency.

A mapping *μ* : *P* → **N**<sup>0</sup> is called a *marking*. For each place *p* ∈ *P*, *μ*(*p*) gives the number of *tokens* in *p*. Graphically, tokens are drawn as small solid *dots* inside circles. •*x* = {*y* | (*y*, *x*) ∈ *F*} and *x*• = {*y* | (*x*, *y*) ∈ *F*} are called *pre-* and *post-sets* of *x* ∈ *P* ∪ *T*, respectively. For *t* ∈ *T* (*p* ∈ *P*), the elements of •*t*(• *p*) are called *input* places (transitions) and the elements of *t*• (*p*•) are called *output* places (transitions) of *t*(*p*).

A transition *t* ∈ *T* is *enabled* by marking *μ* if and only if *μ*(*p*) ≥ *φ*(*p*, *t*) for all *p* ∈ •*t*. In this case *t* can *occur* (*fire*). Its occurrence transforms the marking *μ* into the marking *μ*� defined for each place *p* ∈ *P* by *μ*� (*p*) = *μ*(*p*) − *φ*(*p*, *t*) + *φ*(*t*, *p*). We write *μ t* −→ *μ*� to indicate that the firing of *t* in *μ* leads to *μ*� . A marking *μ* is called *terminal* if in which no transition is enabled. A finite sequence *t*1*t*<sup>2</sup> ··· *tk*, *ti* ∈ *T*, 1 ≤ *i* ≤ *k*, is called *an occurrence sequence* enabled at a marking *<sup>μ</sup>* and finished at a marking *<sup>μ</sup><sup>k</sup>* if there are markings *<sup>μ</sup>*1, *<sup>μ</sup>*2,..., *<sup>μ</sup>k*−<sup>1</sup> such that *μ <sup>t</sup>*<sup>1</sup> −→ *<sup>μ</sup>*<sup>1</sup> *<sup>t</sup>*<sup>2</sup> −→ ... *tk*−<sup>1</sup> −−→ *<sup>μ</sup>k*−<sup>1</sup> *tk* −→ *<sup>μ</sup>k*. In short this sequence can be written as *<sup>μ</sup> <sup>t</sup>*<sup>1</sup> *<sup>t</sup>*<sup>2</sup> ···*tk* −−−−→ *<sup>μ</sup><sup>k</sup>* or *μ <sup>ν</sup>* −→ *μ<sup>k</sup>* where *ν* = *t*1*t*<sup>2</sup> ··· *tk*. For each 1 ≤ *i* ≤ *k*, marking *μ<sup>i</sup>* is called *reachable* from marking *μ*. R(*N*, *μ*) denotes the set of all reachable markings from a marking *μ*.

A *marked* Petri net is a system *N* = (*P*, *T*, *F*, *φ*, *ι*) where (*P*, *T*, *F*, *φ*) is a Petri net, *ι* is the *initial marking*.

A Petri net *with final markings* is a construct *N* = (*P*, *T*, *F*, *φ*, *ι*, *M*) where (*P*, *T*, *F*, *φ*, *ι*) is a marked Petri net and *M* ⊆ R(*N*, *ι*) is set of markings which are called *final* markings. An occurrence sequence *ν* of transitions is called *successful* for *M* if it is enabled at the initial marking *ι* and finished at a final marking *τ* of *M*. If *M* is understood from the context, we say that *ν* is a successful occurrence sequence.

A Petri net *N* is said to be *k*-*bounded* if the number of tokens in each place does not exceed a finite number *k* for any marking reachable from the initial marking *ι*, i.e., *μ*(*p*) ≤ *k* for all *p* ∈ *P* and for all *μ* ∈ R(*N*, *ι*). A Petri net *N* is said to be *bounded* if it is *k*-bounded for some *k* ≥ 1.

A Petri net with *place capacity* is a system *N* = (*P*, *T*, *F*, *φ*, *ι*, *κ*) where (*P*, *T*, *F*, *φ*, *ι*) is a marked Petri net and *κ* : *P* → **N**<sup>0</sup> is a function assigning to each place a number of maximal admissible tokens. A marking *μ* of the net *N* is valid if *μ*(*p*) ≤ *κ*(*p*), for each place *p* ∈ *P*. A transition *t* ∈ *T* is *enabled* by a marking *μ* if additionally the successor marking is valid.

### **2.5 Special Petri nets**

It is known that many decision problems are equivalent to the reachability problem [33], which has been shown to be decidable. However, it has exponential space complexity [40], thus from a practical point of view, Petri nets may be too powerful to be analyzed. The result of this has been the definition of a number of subclasses of Petri nets in order to find a subclass with a smaller complexity and still adequate modeling power for practical purposes. These subclasses are defined by restrictions on their structure intended to improve their analyzability. We consider the following main structural subclasses of Petri nets.

A *state machine* (SM) is an ordinary Petri net such that each transition has exactly one input place and exactly one output place, i.e., | •*t*| = |*t* •| = 1 for all *t* ∈ *T*. This means that there can not be concurrency but there can be conflict.

A *generalized state machine* (GSM) is an ordinary Petri net such that | •*t*| ≤ 1 and |*t*•| ≤ 1 for all *t* ∈ *T*.

A *marked graph* (MG) is an ordinary Petri net such that each place has exactly one input transition and exactly one output transition, i.e., | • *p*| = |*p*•| = 1 for all *p* ∈ *P*. This means that there can not be conflict but there can be concurrency.

A *generalized marked graph* (GMG) is an ordinary Petri net such that | • *p*| ≤ 1 and |*p*•| ≤ 1 for all *p* ∈ *P*.

A *casual net* (CN) is a generalized marked graph each subgraph of which is not a a cycle.

A *free-choice* net (FC) is an ordinary Petri net such every arc is either the only arc going from the place, or it is the only arc going to a transition, i.e., that if *p*• <sup>1</sup> ∩ *p*• <sup>2</sup> �= ∅ then |*p*• <sup>1</sup> | = |*p*• <sup>2</sup> | = 1 for all *p*1, *p*<sup>2</sup> ∈ *P*. This means that there can be both concurrency and conflict but not the same time.

An *extended free-choice* net (EFC) is an ordinary Petri net such that if *p*• <sup>1</sup> ∩ *p*• <sup>2</sup> �= ∅ then *p*• <sup>1</sup> = *p*• 2 for all *p*1, *p*<sup>2</sup> ∈ *P*.

An *asymmetric choice net* (AC) is an ordinary Petri net such that if *p*• <sup>1</sup> ∩ *p*• <sup>2</sup> �= ∅ then *p*• <sup>1</sup> ⊆ *p*• 2 or *p*• <sup>1</sup> ⊇ *p*• <sup>2</sup> for all *p*1, *p*<sup>2</sup> ∈ *P*. In asymmetric choice nets concurrency and conflict (in sum, confusion) may occur but not asymmetrically.
