Using Category Theory to Explore and Model Label Event Structures

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 con-structs, such as product and sum, to model events and relationships among events represented by LES. To explain the idea, several examples are devel-oped. Though a mathematical proof, the proposed idea helped to build a cor-rect-by-construction approach for formalizing LES models of concurrent systems.


Labeled Event Structure
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 [8]. de León, Haar and Longuet proposed a theoretical framework based on LES for testing and verifying observable behaviors of concurrent systems from true concurrency models like Petri nets or networks of automata [9]. Castellan, Clairambault, Rideau and Winskel introduced a detailed, self-contained update to concurrent games on event structures which were preserved by composition with a copycat strategy, and the construction of a bicategory of these strategies [10]. Bruni, Melgratti and Montanari proposed a definition of a particular class of graph grammars that are expressive enough to model name passing calculi while simplifying the denotational domain construction, and applied this technique to derive event structure semantic [11].

Category Theory
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 [12] [13] [14]. Sisiaridis, Kuchta and Markowitch proposed a framework for implementing Godement calculus and cartesian closed comma categories for information security management in the detection of threats and attacks in communication systems [15]. Paper [16] in-

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

Labeled Event Structure
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 Con  . Definition 1. An event structure is a tuple ( ) ; ; E Con  consisting of • a set of events E, • the consistency predicate 2 E Con ⊆ , the set of conflict-free finite subsets of E, and • the enabling relation Con E ⊆ ×  which satisfies the following properties: • consistency of Con: , , that is, if X enables e so does any conflict-free superset Y of X.

Category Theory
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.
• 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: : 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:  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: ; corresponding to transitivity, x ≤ y, y ≤ z, and x ≤ z, in the poset.
• Composition is associative: • the property that, for any object C and morphisms Figure 2 commutes.
That is a a g f 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 B  → + , and • the property that, for any object C and morphisms

An Overview of a Vending Machine Example
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:    {   {  } {  }}   ,  ,  ,  ,  ,  ,

Construct Categorical Structures for LES Models
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.

Object
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, ( ) 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 R is reflexive, transitive. In Figure 3, we omit reflexive and transitive arrows. Note that some pairs of events, e.g., a and c, are unrelated: this means simply that there are no constraints on their order of occurrence.

Morphism
Let ( )  • Event trees are objects: the object shown above in Figure 3 has a tree with c as root.
• There is a morphism from any path in a tree to the tree itself.

Sum (Coproduct)
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 fol- 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 h S T X +  → . The morphism h is unique. To illustrate the sum S + T, Figure 5 describes the sum and it commutes. 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 Then, there is a sum ( which can be represented by Figure 6.
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.   ,

Product
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: be objects corresponding to concurrent processes and let 1 e E ∈ . Then: • If 2 e E ∈ , it indicates that e is a communication event and e must occur simultaneously in both processes. • Otherwise, 2 e E ∉ , 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: 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. 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 h X S T  → × exists and is unique.

Journal of Computer and Communications
To illustrate the sum S × T, Figure 7 describes the product and it commutes. We can use product to build largest communication structures, which can be explained by using Example 5 as follows:

Use Categorical Structures to Model the Vending Machine
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    The above-mentioned sums are just some in the category, while there are other sums that are not listed specifically in above.

Conclusion
In view of the difficulties in the development of concurrent systems, the present 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.