^{1}

^{*}

^{1}

The development of a concurrent system poses unique challenges, especially those related to correctness and consistency, as such a system usually involves several interactive processes executing simultaneously. To deal with some of these challenges, we resorted to Labeled Event Structures (LES) and category theory as the formal methods to model concurrent systems. Specifically, in this paper, we proposed an idea to define categories and corresponding constructs, such as product and sum, to model events and relationships among events represented by LES. To explain the idea, several examples are developed. Though a mathematical proof, the proposed idea helped to build a correct-by-construction approach for formalizing LES models of concurrent systems.

A concurrent system that consists of several simultaneously executing components allows carrying out multiple tasks at the same time, which can accelerate the computational work of software substantially. To model concurrent system, Labeled Event Structures (LES) were proposed and evolved in research [

Researches [

LES is a mathematical model with true concurrency that describes a process in terms of relations between sets of events it generates. Loogen and Goltz used LES to analyze and model nondeterministic concurrent processes [

For modeling concurrency, category theory is used to model, analyze, and compare Transition System, Trace Language, Event Structure, Petri nets, and other classical models of concurrency [

In this section, background and work related to our research are introduced.

An event structure expresses how these events are related to each other. In general event structures that are widely used, a concurrent system or a process can be represented as tuples ( E ; C o n ; ⊢ ) .

Definition 1. An event structure is a tuple ( E ; C o n ; ⊢ ) consisting of

・ a set of events E,

・ the consistency predicate C o n ⊆ 2 E , the set of conflict-free finite subsets of E, and

・ the enabling relation ⊢ ⊆ C o n × E

which satisfies the following properties:

・ consistency of Con: ∀ X , Y ⊆ E ∧ X ⊆ Y ⇒ Y ∈ C o n and

・ ∀ e ∈ E . ∀ X , Y ⊆ E . X ⊢ e ∧ X ⊆ Y ∈ C o n ⇒ Y ⊢ e , that is, if X enables e so does any conflict-free superset Y of X.

Example 1. There is a transition system with states S = { S 0 , S 1 , S 2 , S 3 , S 4 } , where S_{0} is the initial state, and transitions T = { a , b , c , d } . The graphical representation of the transition system is show in

This transition system can be represented by LES as follows:

E = { a ; b ; c ; d }

C o n = { ∅ , { a } , { b } , { c } , { d } , { a , b } , { a , d } , { a , c } , { b , c } , { a , b , c } }

⊢ : ∅ ⊢ a , { a } ⊢ b , { a } ⊢ d , { a , b } ⊢ c

Category theory focuses on the relationships (morphisms) between objects instead of their representations; the morphisms can determine the nature of interactions established between the objects.

Definition 2. A category consists of the following data:

・ Objects: A, B, C, etc.

・ Arrows (Morphisms): f, g, h, etc.

・ For each arrow f, there are given objects: dom(f), cod(f) called domain as well as codomain of f, and f: A → B indicates that A = dom(f), B = cod(f).

・ Given arrows f: A → B and g: B → C with cod(f) = dom(g), there is an given arrow:

g ∘ f : A → C called composite of f and g.

・ For each object A, there is an given arrow: 1_{A}: A → A called identity arrow of A.

These data need to satisfy the following laws:

・ Associativity: h ∘ ( g ∘ f ) = ( h ∘ g ) ∘ f for all f: A → B, g: B → C, h: C → D.

・ Unit: f ∘ 1 A = f = 1 B ∘ f for all f: A → B.

Example 2. Let (S; ≤) be a partially-ordered set (poset). Define the category C in which: each member x of S is an object of C; and each relation x ≤ y of (S; ≤) is a morphism x → y of C.

We can verify that C is a category as follows:

・ For every object x, there is an identity morphism x → x, corresponding to reflexivity, x ≤ x, in the poset.

・ The morphisms (x → y) and (y → z) form a composition pair: ( y → z ) ∘ ( x → y ) = ( x → z ) ; corresponding to transitivity, x ≤ y, y ≤ z, and x ≤ z, in the poset.

・ Composition is associative:

( ( x → y ) ∘ ( v → x ) ) ∘ ( u → v ) = ( v → y ) ∘ ( u → v ) = u → y

and

( x → y ) ∘ ( ( v → x ) ∘ ( u → v ) ) = ( x → y ) ∘ ( u → x ) = ( u → y ) ,

because of

( ( x ≤ y ) ∘ ( v ≤ x ) ) ∘ ( u ≤ v ) = ( x ≤ y ) ∘ ( ( v ≤ x ) ∘ ( u ≤ v ) ) = ( x ≤ y ) ∘ ( u ≤ x ) = ( v ≤ y ) ∘ ( u ≤ v ) = ( u ≤ y )

Definition 3. Let A and B be objects in a category Cat. Then a product of A and B consists of:

・ an object, A × B,

・ morphisms, often called projections, A × B → π a A and A × B → π b B , and

・ the property that, for any object C and morphisms C → f a A , C → f b B , there is a unique morphism C → g A × B such that _{ π b ∘ g = f b }.

Definition 4. Let A and B be objects in a category Cat. Then a sum (or coproduct) of A and B consists of:

・ an object, A + B,

・ morphisms, often called inclusions or canonical projections, A → i a A + B and B → i b A + B , and

・ the property that, for any object C and morphisms C → f a A and C → f b B , there is a unique morphism A + B → 〈 f a ; f b 〉 C such that

In this paper, we use a vending machine example to illustrate how to construct categories and the corresponding structures for models specified by LES which is defined and specified in section 3.

Example 3. There is a vending machine and a person. The vending machine can offer coke and pepsi. Each time, the vending machine accepts a coin first, then dispenses a bottle of coke or pepsi according to the person’s choice.

In this example, the vending machine and the person are modeled as two processes. When the person inserts a coin and vending machine accepts the coin, this interaction can be represented by the shared event coin in person and vending machine. When person chooses coke or pepsi and vending machine accepts it, this interaction can be represented by the shared event coke or pepsi in person and vending machine. After that, the communications between person and vending machine terminate.

By using LES, the communications between person and vending machine in the example can be modeled as follows:

V M P = ( E ; C o n ; ⊢ )

E = { c o i n ; c o k e ; p e p s i ; s t o p }

C o n = { ∅ , { c o i n } , { c o k e } , { p e p s i } , { c o i n , c o k e } , { c o i n , p e p s i } , { c o i n , p e p s i , s t o p } , { c o i n , c o k e , s t o p } }

⊢ : ∅ ⊢ c o i n , { c o i n } ⊢ c o k e , { c o i n } ⊢ p e p s i , { c o i n , c o k e } ⊢ s t o p , { c o i n , p e p s i } ⊢ s t o p

In this section, we use category theory to construct structures for LES models. We first define categorical object and morphism for constructing categories for LES models, then we construct product and sum based on the categories, and we use the vending machine example in Section 3 to explain the categorical structures.

An object is like an event structure, but simpler. Formally, an object (E, R) consists of a set of events, E, and an ordering relation R ⊆ E × E . If events e_{1} and e_{2} are related by R (that is, ( e 1 , e 2 ) ∈ R ), { e 1 } ⊢ e 2 that indicates “e_{1} precedes e_{2}” or “e_{1} happens before e_{2}”.

The relation R is a partial order: reflexive, antisymmetric, and transitive. If e 1 ≠ e 2 , it is not possible to have both e 1 ⊢ e 2 and e 2 ⊢ e 1 , but it is possible that neither is true.

An object can be represented by a forest diagram such as

For this object,

E = { a , b , c , d , e } ,

R = { ∅ ⊢ a , ∅ ⊢ c , { a } ⊢ b , { c } ⊢ d , { c } ⊢ e }

R is reflexive, transitive. In

Let O 1 = ( E 1 , R 1 ) and O 2 = ( E 2 , R 2 ) be objects. There is a morphism O 1 → m O 2 if and only if E 1 ⊆ E 2 and O 1 ⊆ O 2 . In words:

・ Every event e that belongs to E_{1 }also belongs to E_{2}.

・ Every ordered pair { e 1 } ⊢ e 2 in O_{1} also belongs to O_{2}.

There is an identity morphism for every object (E, R) because E ⊆ E and R ⊆ R . Similarly, compositions of morphism exist by transitivity of ⊆ . Consequently, the objects and morphisms combined forma category CP.

If there is a morphism O 1 → m O 2 , which indicates O_{1} is contained by O_{2} or simply O_{2} contains O_{1}. This terminology is consistent with a set “containing” its subsets.

Also, if there is a morphism O 1 → m O 2 , then it must be unique, because there is only one way that a set can be a subset of another set.

There exist some special cases:

・ Traces are objects: the trace { a } ⊢ b , { a , b } ⊢ c can be represented as object a → b→ c.

・ If trace t_{1} is a prefix of trace t_{2}, there is a morphism t 1 → m t 2 .

・ Event trees are objects: the object shown above in

・ There is a morphism from any path in a tree to the tree itself.

If S and T are objects, we define their sum(coproduct) S + T to be the smallest object that contains both S and T. The sum can be defined by set union as follows:

Definition 5. Let S = ( E 1 , R 1 ) and T = ( E 2 , R 2 ) , then

S + T = ( E 1 , R 1 ) + ( E 2 , R 2 ) = ( E 1 ∪ E 2 , R 1 ∪ R 2 ) .

・ By definition, S + T contains S. Consequently, there is a morphism S → i s S + T . Similarly, there is a morphism T → i t S + T .

・ Let X be another object and suppose there is a morphism S → s X , then X contains S. Similarly, if there is a morphism T → t X , then X contains T. Thus X contains both S and T. Since S + T is the smallest object containing both S and T, it follows that X must contain S + T and therefore there is a morphism S + T → h X . The morphism h is unique.

To illustrate the sum S + T,

We can use sum to build branching structures, which can be explained by using Example 4 as follows:

Example 4. Given (E_{1}, R_{1}) and (E_{2}, R_{2}), where

・ E 1 = { a , b } , R 1 = { ∅ ⊢ a , { a } ⊢ b } .

・ E 2 = { a , c } , R 2 = { ∅ ⊢ a , { a } ⊢ c } .

Then, there is a sum ( E 1 ∪ E 2 , R 1 ∪ R 2 ) = ( { a , b , c } , { ∅ ⊢ a , { a } ⊢ b , { a } ⊢ c } ) which can be represented by

In general, when S + T is formed, we assume that the event structures S and T belong to the same process. If e occurs in both structures, it refers to the same event.

The purpose of the product is to combine concurrent processes, each defined by an object, i.e., event structure. To do this, two kinds of event must be distinguished:

Let P 1 = ( E 1 , R 1 ) and P 2 = ( E 2 , R 2 ) be objects corresponding to concurrent processes and let e ∈ E 1 . Then:

・ If e ∈ E 2 , it indicates that e is a communication event and e must occur simultaneously in both processes.

・ Otherwise, e ∉ E 2 , and e belongs to process P only. In this case, e is an independent event.

Product of P_{1} and P_{2} can be constructed as follows:

・ Let E × = E 1 ∩ E 2 be the set of events that communicate, namely the communication set. The communication set is as large as possible, which means that the only events that cannot be added to it are not communication events.

・ The ordering relation R^{ × }is the union R 1 ∪ R 2 restricted to elements of E^{ ×.} Formally,

R × = { ( e 1 , e 2 ) | e 1 ∈ E × and e 2 ∈ E × and ( e 1 , e 2 ) ∈ R 1 ∪ R 2 }

So, the definition of product is provided as follows:

Definition 6. Let S = ( E 1 , R 1 ) and T = ( E 2 , R 2 ) , then

S × T = ( E 1 , R 1 ) × ( E 2 , R 2 ) = ( E 1 ∩ E 2 , { ( e 1 , e 2 ) | e 1 ∈ E × and e 2 ∈ E × and ( e 1 , e 2 ) ∈ R 1 ∪ R 2 } )

・ By construction, S × T contains only events that occur in S and T and is therefore contained in both of them. Thus the projections S × T → π s S and S × T → π t T are well-defined.

・ Assuming that there is an object X and morphisms X → s S and X → t T . Then X must be contained in both S and T. Therefore it must also be contained in S × T which is the largest object contained in both S and T. Hence the morphism X → h S × T exists and is unique.

To illustrate the sum S × T,

We can use product to build largest communication structures, which can be explained by using Example 5 as follows:

Example 5. Let P = ( E P , R P ) and Q = ( E Q , R Q ) defined as in

Then the product P × Q has the events E P ∩ E Q = { c 1 , c 2 } and the ordering is just { c 1 } ⊢ c 2 . The processes execute as shown, with time increasing from left to right, synchronizing at c_{1} and c_{2}. The execution independent events, such as e_{3}, are ignored, as they don’t affect the communications. So, independent events are abstracted out of the system.

In Section 4, this paper provided a vending machine in Example 3 which is modeled by LES. In this section, we use categorical structures defined in Section 5 to model the vending machine example.

The objects of the vending machine are listed as follows:

A = ( { } , { } ) ,

B = ( { c o i n } , { ∅ ⊢ c o i n } ) ,

C = ( { c o i n , c o k e } , { ∅ ⊢ c o i n , { c o i n } ⊢ c o k e } ) ,

D = ( { c o i n , p e p s i } , { ∅ ⊢ c o i n , { c o i n } ⊢ p e p s i } ) ,

E = ( { c o i n , c o k e } , { ∅ ⊢ c o i n , { c o i n } ⊢ c o k e , { c o k e } ⊢ s t o p } ) ,

F = ( { c o i n , p e p s i } , { ∅ ⊢ c o i n , { c o i n } ⊢ p e p s i , { p e p s i } ⊢ s t o p } ) ,

G = ( { c o i n , c o k e } , { ∅ ⊢ c o i n , { c o i n } ⊢ c o k e , { c o i n } ⊢ p e p s i } ) ,

H = ( { c o i n , c o k e } , { ∅ ⊢ c o i n , { c o i n } ⊢ c o k e , { c o i n } ⊢ p e p s i , { c o k e } ⊢ s t o p } ) ,

I = ( { c o i n , c o k e } , { ∅ ⊢ c o i n , { c o i n } ⊢ c o k e , { c o i n } ⊢ p e p s i , { p e p s i } ⊢ s t o p } ) ,

J = ( { c o i n , c o k e } , { ∅ ⊢ c o i n , { c o i n } ⊢ c o k e , { c o i n } ⊢ p e p s i , { c o k e } ⊢ s t o p , { p e p s i } ⊢ s t o p } ) ,

The morphisms between objects are listed as follows, where identities and composites are ignored:

A → B , B → C , B → D , C → E , D → F , C → G , D → G , E → H , F → I , G → H , G → I , H → J , I → J

The diagram of the category of the vending machine is illustrated in

In

・ Products of the category of the vending machine are listed as follows:

G × F = D , H × F = D , H × I = G , E × G = C , H × F = D , E × F = B

The above-mentioned products are just some in the category, while there are other products that are not listed specifically in above.

・ Sums of the category of the vending machine are listed as follows:

C + D = G , E + G = H , G + F = I , H + I = J , E + D = H , E + F = J , C + F = I

The above-mentioned sums are just some in the category, while there are other sums that are not listed specifically in above.

In view of the difficulties in the development of concurrent systems, the present work proposes a new approach to model LES based on the category theory, which helps to explore the communication events and relationship among them. Specifically, categorical object, morphism, product, and sum are constructed for events and relationships. To explain the work, a vending machine example is designed by LES, and the communications between vending machines and persons are modeled by category theory. By adopting the categorical approach, we can explore and model concurrent systems designed by LES with categorical structures, which can be specified, proved and composed formally with preserving their properties. In Future, we will explore the usage of more categorical structures, such as limit/colimit and natural transformation in LES which may be useful for the formalization and verification of communications.

We thank the editor and the referee for their comments. Research of M. Zhu and J. Li is funded by the Shandong University of Technology grants 4041-416069 and 4041-417010. The support is greatly appreciated.

The authors declare no conflicts of interest regarding the publication of this paper.

Zhu, M. and Li, J. (2019) Using Category Theory to Explore and Model Label Event Structures. Journal of Computer and Communications, 7, 49-60. https://doi.org/10.4236/jcc.2019.71005