Transferable Programs and Reactions for Modeling IoT Network Šárka Vavrečková1 1 Silesian University in Opava, Bezručovo nám. 13, Opava, Czech Republic Abstract Membrane systems and their different variants (e.g. P Colonies with transferable programs) can be used to model various processes if we are satisfied with simple rules manipulating the elements of a set of objects. However, these systems were designed more for computational purposes, so we may encounter problems when solving non-numerical problems. Reaction systems, on the other hand, come with the concept of reactants and inhibitors, which we can also use in simulating (typically dynamic) processes. In this paper, we compare these two concepts and propose a new type of system: IR Colonies, which are inspired by both of these concepts. The IR Colonies are designed to be mainly applicable for modeling communication in the Internet of Things networks. In the paper, the reader will find both a proposed definition of IR Colonies and an example of a network model with several IoT devices. Keywords IR Colony, P System, P Colony, Transferable program, Reaction system, Network, IoT 1. Introduction A network of reaction systems is a graph with reaction systems as its nodes. Each reaction system can be affected Membrane computing (introduced by Gheorghe Pǎun in by the reactions of its neighbours. 1998) is a framework for modeling parallel distributed There are several papers that combine the concept processing. Information about this paradigm is available of P Systems (or P Colonies) and R Systems. In [10] in [1, 2, 3], or the bibliography at http://ppage.psystems. the authors compare the two mentioned mathematical eu/ [2024-07-04]. Membrane systems are based on the models and construct a P Colony simulating processes hierarchical structure of cell membranes and can be used taking place in a reaction system. In [11] we can find the to model distributed computing. Mathematical models concept of PR Systems, where reactions from reaction of membrane systems have been called P Systems. systems are applied in membranes of a P System. P Colony (introduced in [4] in 2004) is a simple com- In [11] P Systems are referred to as a quantitative putational model based on membrane systems. On the model because they focus primarily on computation, basic variant, the environment containing objects of a whereas R Systems are referred to as a qualitative model given type is shared by agents that also contain objects because they focus more on evolution. This does not inside their internal environment and are equipped with mean that P Systems are of poor quality, just that their programs consisting of rules. The programs allow the focus is different (on calculations, the result is a number). agents to influence both their own environment and also In [12] we introduce a membrane system working as the shared environment. a communication interface between IoT devices, but we P Colonies with transferable programs were intro- encounter problems with implementing some properties duced in [5] and additional examples and discussions of the resulting system based on P Systems. P Systems can be found in [6]. In the given concept, programs can have been found to be useful for this purpose, however, be transferred between an agent and the environment a structure of membranes with unit rules (i.e. rules with and vice versa, not only objects. a single symbol or object on both sides) is not flexible Reaction systems were introduced in [7], and in [8, 9] enough and some operations are not easy to implement. we can find information about networks of reaction sys- On the other hand, membrane systems naturally repre- tems. Reaction systems (R Systems) are a formal frame- sent the tree structure of a network interconnecting IoT work intended for modeling interactions between bio- devices. chemical entities. The intention was to simulate the co- In [6] we discuss properties of systems derived from existence of two reverse mechanisms – using reactants P Systems – P Colonies, adding the concept of transfer- and inhibitors. able programs introduced in [5]. In [6] only the basic idea is outlined, in [6] we develop the idea and give further ITAT’24: Information technologies – Applications and Theory, Septem- examples. The capabilities of P Colonies with transfer- ber 20–24, 2024, Drienica, Čergovské vrchy able programs are compared with the properties of the $ sarka.vavreckova@fpf.slu.cz (.̌ Vavrečková) © 2024 Copyright for this paper by its authors. Use permitted under Creative Commons License concept of osmotic computing and the functionality of Attribution 4.0 International (CC BY 4.0). CEUR CEUR Workshop Proceedings (CEUR-WS.org) Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 computer viruses, showing that similarities can be found CEUR ceur-ws.org Workshop ISSN 1613-0073 Proceedings between the three concepts. However, for the purposes the P Colony can be viewed as a two-level membrane of this paper, we are primarily interested in P Colonies structure. with transferable programs. The question is to what extent it would be possible to Definition 1 ([5]). A P Colony of capacity 𝑘, 𝑘 ≥ 1, is replace the P Systems in the concept proposed in [12] by a construct Π = (𝐴, 𝑒, 𝑓, 𝑣𝐸 , 𝐵1 , . . . , 𝐵𝑛 ) where P Colonies with transferable programs. The concept of • 𝐴 is an alphabet, its elements are called objects, transferable programs naturally lends itself to e.g. the distribution of updates, but on the other hand, the possi- • 𝑒 ∈ 𝐴 is the environmental object, bility of representing the tree structure of the network be- • 𝑓 ∈ 𝐴 is the final object, tween IoT devices by membranes gets lost here – agents • 𝑣𝐸 is a finite multiset over 𝐴−{𝑒} called the initial in P Colony cannot be nested. And the environment is state of the environment, only a repository of objects and programs, it is not able • 𝐵𝑖 , 1 ≤ 𝑖 ≤ 𝑛, are agents where each agent to execute its own rules. Here, networks of reaction sys- 𝐵𝑖 = (𝑜𝑖 , 𝑃𝑖 ) is defined as follows: tems, specifically a suitable combination with P Colonies – 𝑜𝑖 is the initial state of the agent, a multiset with transferable programs, could be helpful. over 𝐴 consisting of 𝑘 objects, This section is followed by the preliminaries section, in – 𝑃𝑖 = {𝑝𝑖,1 , . . . , 𝑝𝑖,𝑘𝑖 } is a finite set of pro- which we briefly introduce P Colonies, P Colonies with grams where each program consists of 𝑘 transferable programs, reaction systems and networks of rules, the rules can be in one of the following reaction systems. We also briefly introduce the world of forms: IoT devices. ∗ 𝑎 → 𝑏, 𝑎, 𝑏 ∈ 𝐴 called an evolution The subsequent section 3 is a brief comparison and rule, evaluation of the properties of P Colonies (with transfer- able programs) and (networks of) reaction systems. In ∗ 𝑐 ↔ 𝑑, 𝑐, 𝑑 ∈ 𝐴 called a communi- particular, we observe states, rules, processes, possibili- cation rule, ties of cooperation of involved entities and sharing, also ∗ 𝑟1 /𝑟2 called a checking rule, 𝑟1 , 𝑟2 possibilities for conditioning of events taking place in are both evolution or communication the system. rules. Section 4 proposes a definition of a new type of system: the IR colony. The section describes and explains various The evolution rules are of the form 𝑎 → 𝑏. This type aspects of this system. IR Colony is used in Section 5 of rule allows the agent to influence its internal envi- to create an outline of a model of communication in a ronment: an object 𝑎 inside the agent’s environment is network with several devices. rewritten to the specified object 𝑏. The communication rules (𝑐 ↔ 𝑑) are intended for communication between the given agent and the envi- 2. Preliminaries ronment. An object 𝑐 inside the agent is swapped with the given object 𝑑 in the environment. We assume the reader to be familiar with the basics of the The checking rules (𝑟1 /𝑟2 ) are composed of two rules formal language theory[13] and membrane computing 𝑟1 and 𝑟2 of any of the previous two types. The first rule [3]. has a higher priority to apply, and if the first rule cannot We denote the length of a word 𝑤 by |𝑤|, and also the be executed, the second rule in order may be executed. number of elements in a (multi)set 𝑆 by |𝑆|. The empty The configuration of a P Colony Π with capacity 𝑘 is word is represented by the symbol 𝜀, so |𝜀| = 0. an (𝑛 + 1)-tuple of multisets 𝑜𝑖 for 1 ≤ 𝑖 ≤ 𝑛 for the For details and definitions of the graph theory, we agents 𝐵𝑖 , and 𝑣𝐸 for the environment can refer e.g. to https://www.britannica.com/topic/ graph-theory [2024-07-08]. We denote the set of all nodes (𝑤1 , . . . , 𝑤𝑛 , 𝑤𝐸 ) from which an edge leads to a node 𝑣 by in(𝑣). where 𝑤𝑖 ∈ 𝐴* , |𝑤𝑖 | = 𝑘, 𝑤𝑖 ∈ 𝐴* , 𝑤𝐸 ∈ (𝐴−{𝑒})*. Several derivation modes have been defined, in [5] and 2.1. P Colonies [6] the maximally parallel derivation mode is primarily P Colonies enrich the concept of P Systems by agents taken into account where all agents can work parallelly evolving activities according to defined programs. On the in each derivation step (each agent non-deterministically contrary, the complex structure of membranes was aban- chooses one of its programs with applicable rules). The doned. An agent is actually analogous to a membrane calculation halts if no agent finds an applicable program. within an environment of the main membrane so that 2.2. P Colonies with Transferable 2.3. R Systems and their Networks Programs A reaction takes place over a set of symbols, reactants. As mentioned above, the concept of transferable pro- A reactant enters a (chemical or other) reaction and grams for P Colonies has been introduced in [5]. A trans- changes into a product of the given reaction. The re- ferable program is an ordered pair action may not take place under certain circumstances if an inhibitor is present in the environment (set), i.e. (⟨simple_program⟩ ; {conditions}) a substance that slows down or prevents the reaction. located inside an agent or the environment. The program Definition 2 (according to [9]). A reaction over a fi- can be transferred from the agent to the environment and nite nonempty set 𝑆 is a triple 𝑎 = (𝑅, 𝐼, 𝑃 ) where vice versa (from the source to the destination, depending on the direction), and the stated condition determines • 𝑅 ⊆ 𝑆 is a set of reactants, 𝑅 ̸= ∅, under what circumstances this transfer can occur. Two • 𝐼 ⊆ 𝑆 is a set of inhibitors, 𝑅 ∩ 𝐼 = ∅, types of conditions are admissible: an object condition • 𝑃 ⊆ 𝑆 is a set of products, 𝑃 ̸= ∅. and a program condition. The “object” condition specifies which objects must The set 𝑆 is called the background set. (or must not, with the negation symbol) be present in Denote by res𝑎 (𝑇 ) the result of applying the reaction 𝑎 the destination for the program to be transferable. This to the set 𝑇 , we call the function res𝑎 () the result function. condition is formed by multisets of objects, the size of A reaction 𝑎 = (𝑅, 𝐼, 𝑃 ) with 𝑃 = res𝑎 (𝑇 ) is enabled the multisets is equal to the capacity of the P Colony. in a configuration 𝑇 ⊆ 𝑆 iff The “program” condition specifies programs that must • 𝑅 ⊆ 𝑇 , and (or must not) be present in the destination for the given • 𝐼 ∩ 𝑇 = ∅. program to be transferable. If res𝑎 (𝑇 ) = ∅, the reaction 𝑎 is not enabled in the config- Example 1. Let Π be a P Colony of capacity 2. The uration with the set 𝑇 . capacity is reflected in both the number of objects in We write 𝑅𝑎 , 𝐼𝑎 , 𝑃𝑎 , if we can stress the relationship to agents’ environments and the number of rules in each the reaction 𝑎. program. If 𝐴 is the set of all reactions 𝑎 over the background set An example program with an object condition inside 𝑆, we denote res𝐴 set of results of all reactions belonging an agent can be as follows: to 𝐴, so res𝐴 = ∪𝑎∈𝐴 𝑃𝑎 . (⟨𝑎 → 𝑏; 𝑐 ↔ 𝑑⟩ ; {𝑑𝑚, ¬𝑎𝑔}) A reaction system is an ordered pair 𝒜 = (𝑆, 𝐴) where the finite nonempty set of reactions 𝐴 is built over the This means that the given program is transferable only if background set 𝑆. at least one occurrence of 𝑑 and one occurrence of 𝑚 is present and there is no 𝑎𝑔 pair, both in the environment In [9] we can also find the condition 𝐼 ̸= ∅ for the set (the shared environment is the destination). of inhibitors, and the author states that by omitting this An example program with a program condition inside condition we get an equivalent system, so here we stick the environment can be as follows: to the shorter definition without this condition. As we can see, the core of each reaction 𝑎 is its function (⟨𝑎 → 𝑏; 𝑐 ↔ 𝑑⟩ ; {⟨𝑎 ↔ 𝑏; 𝑏 → 𝑐⟩}) res𝑎 . The input of this function is a set 𝑇 ⊆ 𝑆, all The given program can be transferred into an agent only members of 𝑅𝑎 are in 𝑇 , no member of a set 𝐼𝑎 should if the agent contains the program ⟨𝑎 ↔ 𝑏; 𝑏 → 𝑐⟩. be a part of 𝑇 , and the output of the function is the set 𝑃𝑎 . The function should be computable, we can represent it A combination of both types of conditions in a single by rules, program code, etc. according to the particular transferable program is allowed. use of the system. According to [5], a program can be classified as perma- ment. When a permanent program is being transferred, Definition 3 (according to [9]). An interactive pro- the program remains in the original location and the copy cess 𝜋 in a reaction system 𝒜 is a pair (𝛾, 𝛿) such that is included in the destination location, but the program • 𝛾 = 𝐶0 , 𝐶1 , . . . , 𝐶𝑛 (the context sequence), loses this property at the new location. When a non- 𝛿 = 𝐷0 , 𝐷1 , . . . , 𝐷𝑛 (the result sequence), permanent program is being transferred, it is removed • 𝐶𝑖 ⊆ 𝑆, 𝐷𝑖 ⊆ 𝑆, 0 ≤ 𝑖 ≤ 𝑛, from its original location. • 𝐷𝑖 = res𝐴 (𝐶𝑖−1 ∪ 𝐷𝑖−1 ) for each 1 < 𝑖 ≤ 𝑛. In each computation step, an agent can either apply one of its applicable programs or transfer one of the The state sequence of the interactive process 𝜋 is programs in or out[5]. This implies that the transfer of 𝑊0 , . . . , 𝑊𝑛 where 𝑊0 = 𝐶0 is the initial state of 𝜋 programs is actually an analogy of programs. and 𝑊𝑖 = 𝐶𝑖 ∪ 𝐷𝑖 for all 1 ≤ 𝑖 ≤ 𝑛. The definitions show that the output of the system 2.4. IoT Concepts depends on the initial state 𝑊0 (resp. the first context IoT (Internet of Things) devices are small, simple devices 𝐶0 ). For two different initial states, we get two different that emphasize the ability to connect to other devices, outputs. interact with each other, and automate their operation. For the purposes of this paper, it is very practical that Their programs are not usually complex (except perhaps symbols (potential reactants) can be continuously added for security devices), and their operation consists mostly to the system (by the members of the context sequence), of transmitting simple data ( either one-time or at regular corresponding to processes occurring in dynamic sys- intervals) or, conversely, receiving simple data and then tems. reacting. For example, a thermometer sends the current temperature to network at regular intervals, to which Definition 4 (according to [9]). A network of reaction a window controller can respond by opening or closing systems is a tuple 𝒩 = (𝐺, ℱ, 𝜇) where a window, or a heating or air conditioning controller can • 𝐺 = (𝑉, 𝐸) is a finite graph where 𝑉 is a finite start or stop a related device. In [14] several definitions set of nodes (vertices) and 𝐸 is a finite set of edges, of IoT network can be found, a more compact definition • ℱ is a nonempty finite set of reaction systems, is provided in [12]. In IoT device networks, we encounter one of two • 𝜇 : 𝑉 → ℱ is a location function, assigning reac- types of communication: Request-Response or Publisher- tion systems to nodes. Subscriber. The Request-Response model comes from the Moreover, if 𝐺 is undirected, then it is connected. If 𝐺 is decentralized world of WWW networks. The Publisher- directed, then it is weakly connected. Subscriber model is better adapted to requests of IoT networks or other automated systems, however, usually Each reaction system can have a different background a central control device is being used. More details about set. Denote 𝑆 𝑗 the background set of the reaction system IoT network communication models, including protocols, 𝑣 𝑗 , 1 ≤ 𝑗 ≤ 𝑚. can be found in [15]. The superscript (“𝑥𝑗 ”) in the following paragraphs does not denote multiplicity, it denotes membership to a 𝑗 𝑡ℎ R System in the network. 3. Comparison of Base Systems Definition 5 (according to [9]). Let 𝒩 = (𝐺, ℱ, 𝜇) In this section, we compare the capabilities of P Colonies be a network of reaction systems with |𝑉 | = 𝑚, 𝑚 ≥ 1. with transferable programs and R Systems and/or net- For 𝑛 ∈ N+ , an interactive (n-step) network process is works of R Systems. a tuple Π = (𝜋 1 , . . . , 𝜋 𝑚 ) where for all vertices 𝑣 𝑗 , 1 ≤ As mentioned above, various mathematical models 𝑗 ≤ 𝑚: are either quantitative (as P Systems) or qualitative (as R Systems). P Colonies can be considered as something • 𝜋 𝑗 = (𝛾 𝑗 , 𝛿 𝑗 ), 𝛾 𝑗 = 𝐶0𝑗 , 𝐶1𝑗 , . . . , 𝐶𝑛𝑗 (the context between quantitative and qualitative concepts, but close sequence of the 𝑗 𝑡ℎ vertex), 𝛿 𝑗 = 𝐷0𝑗 , 𝐷1𝑗 , . . . , 𝐷𝑛𝑗 to the first one. We need a system somewhere between (the result sequence of the 𝑗 𝑡ℎ vertex), as well, but close to the second one, to be more suitable • 𝐶𝑖 ⊆ 𝑆 , 𝐷𝑗 ⊆ 𝑆 , 0 ≤ 𝑗 ≤ 𝑛, 𝑗 𝑗 𝑗 𝑗 for modeling and simulations. (︁⋃︀ )︁ We can find some parallels between the concepts of • 𝐶𝑖𝑗 = 𝑆 𝑗 ∩ 𝑘 ⃒ ⃒ 𝑘 𝑗 1≤𝑘≤𝑚 𝐷𝑖−1 𝑣 ∈ in(𝑣 ) , P Colonies with transferable programs and reaction sys- • 𝐷𝑖𝑗 = res𝐴𝑗 𝐶𝑖−1 for each 1 ≤ 𝑖 ≤ 𝑛. tems. (︀ 𝑗 𝑗 )︀ ∪ 𝐷𝑖−1 Moreover, if in(𝑣 𝑗 ) = ∅, then 𝐶𝑖𝑗 = ∅, 1 ≤ 𝑖 ≤ 𝑛. States. In P Colonies, each agent has its own state, and the shared environment has the state as well (all states The key for us is the ability of the individual compo- are the parts of the configuration). The agents can evolve nents of the network (here reaction systems) to commu- their own state using evolution rules, and influence the nicate with each other. It may look a bit complicated in state of the shared environment using communication the definition, but the point is that at each step of the rules. Agents cannot directly affect the state of other process, each system can send the result of its own re- agents, only indirectly through the environment. action (product) to another system using the edge that Each R System has its own state too. Networked R Sys- connects them. tems can both evolve their own state and influence the states of neighbouring nodes through reactions, and they can influence the states of other R Systems in the network only indirectly through their neighbours. Rules, Processes, Functions. With using transferable The potential central component can be represented by programs, the sets of programs inside agents and shared one of the network nodes, with an adjustment of the environment are changeable. But programs can only network structure (e.g. a tree structure). be transferred, not new ones created. When defining a new P Colony, the format of the rules and programs is predetermined. Even the number of objects in the agents’ 4. IR Colonies with Transferable environments and the number of rules in programs is Programs and Reactions given by the capacity of the P Colony. Every R System has its own set of reactions, and it is In [11], the authors have designed PR Systems in such not possible to change or upgrade it subsequently. There a way that the rules of the P System have been replaced is no strict form for the function res𝑎 describing the reac- by reactions, i.e. each membrane has an associated set tion 𝑎 inside a reaction system, this function should only of reactions. This concept is interesting, but not very be computable. However, the purpose of this function is suitable for our purposes (optimization for IoT network to process a set of reactants and transform them into a simulation). set of products, so this function can also be represented From the definition of the network of R Systems, we by a set of rules (not necessarily simple or regular). take: When defining a new R System, we have a relatively free hand and can better customize the system to what we • definition of infrastructure using a graph, need to model (which is very practical for a qualitatively • system of reactions with reactants and inhibitors, oriented system intended for simulations of real systems); the rules will follow the computational function some specific simulated systems cannot be represented with variable input arguments (not only static by regular or context-free rules. objects), • partly the principle of processes, context se- Conditionality of Transfer or Reaction. The orig- quence and result sequence, inal programs with rules in P Colony agents are static, • flexibility in the number of symbols/objects inside but transferable programs add dynamism. The object agents’ states and rules in programs. conditions for transferable programs are analogous to From the definition of the P Colonies with transferable reactants (positive conditions) and inhibitors (conditions programs, we take: with negation) used in R Systems. We can also consider as conditionality in R Systems • the system of agents and shared environment as the fact that the reaction is only enabled in certain con- storage for objects and programs, figurations. • a set of objects as agent state, supplemented by P Colonies go a bit further, allowing the transfer the ability to store objects in the shared environ- to be conditioned not only by objects but also by the ment, (non)presence of rules in the agent’s environment or in • some rule types in programs, transferable pro- the shared environment (depending on the transfer di- grams. rection). Since we want to design a quality-oriented system, Cooperation and Sharing. In P Colonies with trans- we will abandon the capacity parameter. Each agent has ferable programs, agents cooperate through a shared a specific role for which it needs a specific number of environment. It is a two-level hierarchy, the shared en- objects in the environment and a differently complex pro- vironment serves as a repository for objects and rules. gram. While abandoning capacity means that the ability Individual agents do not communicate directly with each to compare with other systems and to represent various other. This communication model corresponds to an characteristics of the system numerically is degraded, but infrastructure with a central control component repre- these characteristics are not important for our purposes. sented by the shared environment. Because, unlike other similar systems, we add variable R Systems themselves do not have a defined neigh- properties to objects, it makes no sense to work with bourhood. However, the network of R Systems precisely multisets. In the definition, we can only find sets, which defines the connections of R Systems as nodes of a graph. will ensure the determinism of each operation and make Each R System is adjacent to at least one different R Sys- programming easier. tem, all nodes communicate right with their neighbours, with respect to edge directions. There is no shared envi- Object Properties. Our system has a shared alphabet ronment. This communication model allows using vari- of objects, but each object can have variable properties, ous structures: centralized, decentralized, and distributed. numbers from Z. For example, an agent representing a device has an object in its state for the version of the system installed in the agent, the specific version num- Rules and Programs. The rules in Π𝐼𝑅 consist of ber is a property of this object. A rule in some program symbols, these symbols may or may not have properties will work with an object specifying the version, the (vari- specified. Listing a property on the left side of a rule able) argument will be a specific version number. Or an indicates a conditional application of that rule. The prop- agent simulating a weather station products an object for erties are numbers from Z. The rules can be in one of the temperature with the current temperature as its property. following forms: The intersection operation on sets of objects with prop- erties corresponds to the operation without using prop- • evolution rule: 𝑎 → 𝑏 or 𝑎(𝑥) → 𝑏(𝑦), 𝑎, 𝑏 ∈ Σ, erties (properties are ignored when comparing). E.g. for an agent evolves its state, 𝑥, 𝑦 ∈ Z are properties an object 𝑎 with a property 𝑥 and a set of objects Σ: of the given objects, {𝑎(𝑥)} ∩ Σ ∼ = {𝑎} ∩ Σ. The exception is the case when • deletion rule: 𝑎 → 𝜀, 𝑎 ∈ Σ, out the same object is on both sides of the operator, but with • multicast rule: 𝑎 −→ 𝑏, 𝑎, 𝑏 ∈ Σ to send the different properties: {𝑎(𝑥)} ∩ {𝑎(𝑦)} = ∅ if 𝑥 ̸= 𝑦. All object 𝑏 to all outgoing edges, 𝑎 remains inside membership operators (e.g. ⊆) work with properties in the sending agent; if 𝑎 = 𝑏, it is not necessary to the same way. specify the properties of the objects, the current The unification operation applied on a set of objects property of 𝑎 is used, with properties is not commutative. If the same object • backup rule: 𝑎 →, 𝑎 ∈ Σ, to put the object is in both sets, but with different properties, the object down into the environment (including its current from the set on the right side of the union operator will property), the object 𝑎 remains in the agent’s be the member of the resulting set. E.g. {𝑎(𝑥), 𝑏(𝑦)} ∪ state, {𝑏(𝑧), 𝑐(𝑟)} = {𝑎(𝑥), 𝑏(𝑧), 𝑐(𝑟)}. This corresponds to • restoration rule: ← 𝑏, 𝑏 ∈ Σ, to pick an object up updating properties in the right-to-left direction. from the environment (including its current prop- If the same object has a property in only one of the erty), the object 𝑏 remains in the environment; if sets, then the result of the union will contain the object 𝑏 has been present in the state of the given agent, with the property. E.g. {𝑎(𝑥)} ∪ {𝑎, 𝑏} = {𝑎(𝑥), 𝑏}. the parameter will be rewritten (updated), • programming rule: 𝑝 ◁ IR Colony and Agents. An IR Colony (IoT Reaction Colony) is a construct Π𝐼𝑅 = (Σ, 𝒜, 𝐺, 𝜇, 𝑊0 , 𝑃0 ) The backup and restoration rule types apply the unifica- where tion operation, including the processing of parameters. The programming rule will be explained later. • Σ is a finite nonempty alphabet, a set of base Denote 𝒰 the set of all possible rules for Π𝐼𝑅 . A pro- objects, the objects can have default properties, gram in Π𝐼𝑅 is a construct 𝑝lab = (lab, 𝑈, 𝑅, 𝐼) where • 𝒜 = {𝐴1 , . . . , 𝐴𝑚 } is a finite nonempty set of agents, • each program has the own unique label lab, • 𝐺 = (𝑉, 𝐸) is a graph, 𝑉 is a finite set of nodes, • 𝑈 ⊆ 𝒰 is a finite nonempty set of rules, |𝑉 | = 𝑚, 𝐸 is a finite set of edges, • 𝑅 ⊆ Σ ∪ 𝒰 is a finite set of reactants, reactants • 𝜇 : 𝑉 → 𝒜 is a location function, locating agents can be: into the graph nodes, – an object with or without a property (a re- • 𝑊0 ⊆ Σ, 𝑊0 ̸= ∅ is the initial state of the shared lational expression can be added to the ob- environment, ject for its property), • 𝑃0 is the initial set of programs located in the – a relation between properties of different shared environment. objects, – a program, If the graph 𝐺 is undirected, then it is connected. If 𝐺 is directed, then it is weakly connected. • 𝐼 ⊆ Σ ∪ 𝒰 is a finite set of inhibitors, 𝑅 ∩ 𝐼 = ∅, An agent 𝐴𝑗 , 1 ≤ 𝑗 ≤ 𝑚, is a pair 𝐴𝑗 = (𝑤𝑗 , 𝑃𝑗 ) the syntax of elements of this set is the same as where for 𝑅. • 𝑤𝑗 ⊂ Σ, 𝑤𝑗 ̸= ∅ is the initial state of the agent, The set 𝑈 must be deterministic in the sense that the • 𝑃𝑗 is the initial set of programs of the given agent, same object must not appear on the left-hand side of any 𝑃𝑗 is finite, and can be empty. two rules. A rule 𝑟 ∈ 𝑈 with an object 𝑎 ∈ Σ on the left side In the following paragraphs, we specify the individual is applicable to a state 𝑊 of a given agent iff the object parts of this basic definition, we take into account an IR 𝑎 is present in 𝑊 including potential parameters. The Colony Π𝐼𝑅 = (Σ, 𝒜, 𝐺, 𝜇, 𝑊0 , 𝑃0 ) and 𝐺 = (𝑉, 𝐸). restoration rule ← 𝑏 is applicable iff the object on the right side is present in the environment. The program- • 𝑊𝑗,𝑖 = map𝐴𝑗 (𝑊𝑗,𝑖−1 ∪ 𝐶𝑗,𝑖 , 𝑝) , 1 ≤ 𝑖 ≤ 𝑛, ming rule is always applicable. 𝑝 is a program applied in the 𝑖𝑡ℎ step. A program 𝑝lab in an agent 𝐴𝑗 = (𝑊𝑗 , 𝑃𝑗 ) is applica- ble iff The given process can be shortly represented by the se- quence (𝑊0,0 , . . . , 𝑊𝑚,0 ) ⇒* (𝑊0,𝑛 , . . . , 𝑊𝑚,𝑛 ). • all rules in 𝑈 are applicable to 𝑊𝑗 , • (𝑅 ∩ Σ) ⊆ 𝑊𝑗 , (𝑅 ∩ 𝒰 ) ⊆ 𝑃𝑗 , Transferring Programs. Unlike the original • 𝐼 ∩ 𝑊𝑗 = ∅, 𝐼 ∩ 𝑃𝑗 = ∅. P Colonies with transferable programs, here we set the automatic transfer of programs when the given It should be noted that only agents can run programs, conditions are met. it is not possible to run any program directly in the envi- As stated above, a program is defined by a label, a set ronment. of rules, a set of reactants, and a set of inhibitors. All agents have their own initial set of programs, and the Process and States. The agents in 𝒜, |𝒜| = 𝑚, work environment carries the base repository of programs with synchronously in the weakly parallel mode, in subse- the initial state 𝑃 . 0 quent steps. In each step, every agent 𝐴𝑗 , 1 ≤ 𝑗 ≤ 𝑚, A programming rule is a construct (label, 𝑈, 𝑅, 𝐼) ◁ non-deterministically chooses one of its applicable pro- with the parts of this sequence of the same meaning as grams and executes this program on its state. in the definition of a program. This rule creates a new An n-step process in Π𝐼𝑅 is a tuple (𝜋0 , 𝜋1 , . . . , 𝜋𝑚 ) program with the given parameters and stores it in the where for all agents 𝐴𝑗 , 1 ≤ 𝑗 ≤ 𝑚, is 𝜋𝑗 = (𝛾𝑗 , 𝛿𝑗 ): rule repository in the environment. • 𝛾𝑗 = 𝐶𝑗,0 , 𝐶𝑗,1 , . . . 𝐶𝑗,𝑛 (the context sequence), Before starting each step in an IR colony, agents check • 𝛿𝑗 = 𝐷𝑗,0 , 𝐷𝑗,1 , . . . 𝐷𝑗,𝑛 (the result sequence). the program repository for a new program with a label belonging to one of their programs. If so, the agent’s orig- 𝐷𝑗,𝑖 is a result of an agent 𝐴𝑗 (towards its neighbourhood, inal program is overwritten (updated) by a new program applying the multicast rules) for the 𝑖𝑡ℎ step, 𝑖 ≥ 0, and with the same label located in the repository. a program {︁ 𝑝 ∈⃒𝑃(︁𝑗 is used by 𝐴𝑗 )︁in the}︁given step: out 𝐷𝑗,𝑖 = 𝑏(𝑦) ⃒ 𝑎(𝑥) −→ 𝑏(𝑦) ∈ 𝑝 . ⃒ The flow of a process step. During a single step of If the property of object 𝑏 is not specified in the rule, a process, the following happens (for a 𝑗 agent): 𝑡ℎ the property 𝑥 assigned when applying the rule (the 1. the agent checks the program repository and up- current property of object 𝑎) is used. dates its own programs, 𝐶𝑗,𝑖 is a context set of an agent 𝐴𝑗 = (𝑊𝑗 , 𝑃𝑗 ) for 2. the agent nondeterministically chooses one of its the 𝑖𝑡ℎ step: (︁⋃︀ ⃒ )︁ applicable programs, 𝐶𝑗,𝑖 = 1≤𝑘≤𝑛 𝐷𝑘,𝑖−1 ⃒ 𝑣𝑘 ∈ in(𝑣𝑗 ) , 𝜇(𝑣𝑠 ) = 𝐴𝑠 3. all rules in the program are processed with in- ⃒ for all 1 ≤ 𝑠 ≤ 𝑚. fluencing the own state and computation of the Denote map𝐴𝑗 (𝑊, 𝑝) the mapping function of an agent result and context sets for the given agent and 𝐴𝑗 (towards its state) for a program 𝑝 and a set of ob- step, jects 𝑊 : the function captures the use of all rules affect- 4. the result sets are used to calculate the new state ing the agent’s state contained in the program 𝑝, just of agents. except the multicast-type ones on the set 𝑊 which do not affect the state of the agent 𝐴𝑗 . Denote map0 (𝑊, 𝑃 ) the mapping function of an envi- 5. Sample Model of IoT Network ronment for some subset of agents’ programs 𝑃 affecting The system proposed in the previous section is used here the environment (the backup and restoration rules). to outline a model of communication in a network of IoT The sequence of states of the shared environment ap- devices. The sample network consists of 7 devices: propriate to the given process is 𝑊0,0 , 𝑊0,1 , . . . , 𝑊0,𝑛 : 𝐴1 : control panel with buttons and other controls for • 𝑊0,0 = 𝑊0 ∪ 𝐶0,0 , manual handling of several following devices, • 𝑊0,𝑖 = map0 (𝑊𝑖−1 , 𝑃 ), 𝑃 is a set of all pro- 𝐴2 : display (an LCD panel) to show some sensor val- grams being used by agents in the given step ues (thermometer, CO2 sensor), affecting the environment. 𝐴3 : updater that provides updates for all devices on the network, keeps an inventory of software ver- The sequence of states of an agent 𝐴𝑗 appropriate to the sions on different devices, and forwards updates given process is 𝑊𝑗,0 , 𝑊𝑗,1 , . . . , 𝑊𝑗,𝑛 : of programs to the environment, • 𝑊𝑗,0 = 𝑊𝑗 ∪ 𝐶𝑗,0 , 𝐴4 : smart light bulb, 𝐴5 : window control device that can open or close (wopent, {𝑤𝑠(0) → 𝑤𝑠(1)}, a window based on data from other IoT devices {𝑡𝑛(> 22)}, {𝑤𝑚(1)}) (here thermometer and CO2 sensor), (wopens, {𝑤𝑠(0) → 𝑤𝑠(1)}, {𝑡𝑠(> 1200)}, 𝐴6 : thermometer, its values can affect the window {𝑤𝑚(1)}) control, (wclose, {𝑤𝑠(1) → 𝑤𝑠(0)}, {𝑡𝑛(≤ 22), 𝑡𝑠(≤ 1200)}, 𝐴7 : CO2 sensor, its values can also affect the window {𝑤𝑚(1)}) control. We can notice that there is a conjunction relation be- tween the elements in the set of reactants, so the opening Figure 1 shows the demonstrated network with the listed operation is divided into two programs. devices and connections (directed edges). The agent 𝐴3 only displays information obtained from its own state. The initial state consists of one object 𝑑𝑣(1), it is the version. The remaining objects will be Control  Updater - Display delivered during the system operation. No programs panel are needed, the change of the display view state is done 𝐴1 J 𝐴2 J 𝐴3  ] JJ automatically if there is a change in the objects and their J J parameters from other agents. ? ^ J  ^ J J ? 𝐴3 = ({𝑐𝑣(1)}, ∅) Smart light Window  Thermo- CO2 The agent 𝐴4 is a light bulb. There are three objects bulb control meter sensor in its state: the version, the device state (0 for lights off, 𝐴4 𝐴5 𝐴6 𝐴7 6 1 for lights on), and the light intensity (0–12). Figure 1: Sample IoT network 𝐴4 = ({𝑏𝑣(1), 𝑏𝑠(0), 𝑏𝑖(2)}, ∅) The agent 𝐴1 plays the role of the control panel for the manual handling of devices. It needs the objects with the Each agent can have a different number of objects in current state of the controlled devices (the light bulb, the its state, and this number can also be changed. window), and one additional object indicating manual The agent 𝐴6 is a thermometer. It is a very simple handling for the window. device: it needs only two objects inside the state. The 𝐴1 = ({𝑐𝑣(1), 𝑐𝑏(0), 𝑐𝑤𝑚(0), 𝑐𝑤𝑠(0)}, object 𝑡𝑣 means the version, the object 𝑡𝑛 is intended to {clight, cwindowman, cwindowstate}) store the current temperature. There is only one program (clight, out {𝑐𝑏 −→ 𝑐𝑏}, ∅, ∅) in the set of programs, with one (multicast) rule. out ( cwindowman, {𝑐𝑤𝑚 −→ 𝑤𝑚}, ∅, ∅) 𝐴6 = ({𝑡𝑣(1), 𝑡𝑛(24)}, {tout}) with the program: out out ( cwindowstate, {𝑐𝑤𝑠 −→ 𝑤𝑠}, {𝑐𝑤𝑚(1)}, ∅) (tout, {𝑡𝑛 −→ 𝑡𝑛}, ∅, ∅) The last agent, 𝐴2 , is the updater. It holds the database The agent exports the object 𝑡𝑛 with its current prop- of all programs and their versions (as object properties). erty to all edges directed from the agent (so the object Because of lack of space, we will show here only the appears in the states of the agents 𝐴5 and 𝐴3 for the next creation of an update program (more precisely: two pro- step, their contexts). grams) for the agent 𝐴5 , when it is necessary to change The agent 𝐴7 is similar: it has only two objects inside the temperature at which the window will automatically the state and one program with the multicast rule: open. We use one special helper object 𝑤𝑣𝑛 indicating 𝐴7 = ({𝑠𝑣(1), 𝑠𝑛(1000)}, {sout}) with the program: out a new value intended for the object 𝑤𝑣. (sout, {𝑠𝑛 −→ 𝑠𝑛}, ∅, ∅) 𝐴2 = ({𝑐𝑣(1), 𝑢𝑣(1), 𝑤𝑣(1), . . . , 𝑤𝑣𝑛(2)}, The agent 𝐴5 is a bit more complicated. Its role is {uw2, uw2d, . . . }) a window control, and it is necessary to synchronize in- The program uw2 creates and exports the new version puts from three different sources: the thermometer, the of the program wopent, multicasts the object 𝑤𝑣 with CO2 sensor, and the manual operation on the control the property 2, and evolves its own copy of the object panel. The agent has three programs: opening a win- 𝑤𝑣 by changing the property. The set of rules must be dow in response to high room temperature or high CO2 deterministic, therefore the multicast rule has a different levels, and closing the window. These programs are not symbol on each side. triggered when the manual mode (operation from the (uw2, { (wopent, {𝑤𝑠(0) → 𝑤𝑠(1)}, control panel) is enabled. {𝑡𝑛(> 24)}, {𝑤𝑚(1)}) ◁, Besides the object for the version, we have an object out 𝑤𝑣𝑛(2) −→ 𝑤𝑣(2), for the state (0=closed, 1=open) and an object for the 𝑤𝑣(1) → 𝑤𝑣(2)}, manual mode indication. {𝑤𝑣𝑛(2)}, ∅) 𝐴5 = ({𝑤𝑣(1), 𝑤𝑠(0), 𝑤𝑚(0)}, The set of reactants has the member 𝑤𝑣𝑛(2), so the {wopent, wopens, wclose}) given rule is applied immediately after the new helper object 𝑤𝑠𝑛 is created. After the update is provided, the can be a problem in a dynamically changing graph node helper object is removed using a deletion rule: structure. (uw2d, {𝑤𝑣𝑛(2) → 𝜀}, {𝑤𝑣𝑛(2), 𝑤𝑣(2)}, ∅) Another option for communication between agents While most devices (and agents) will operate more or is the use of a shared environment. If one agent uses less automatically based on hardware signals affecting a backup rule and another agent uses a restoration rule, the properties of objects in the agent state and according both with the same object, we get the equivalent of broad- to contained rules, for the updater we assume external cast communication (one-to-all). This method of commu- intervention resulting in the dynamic creation of new nication was not shown in the example in the previous rules for program updates. section, but the principle is not complicated. IR Colonies assume not only the processes mentioned in the definition but also potential external interventions 6. Discussion and Conclusion (e.g. a temperature sensor as hardware directly influences the property containing the instantaneous temperature, The proposed system is optimized for a very specific this value is not influenced by any rule). In the previous application – IoT network modeling. section with the IR Colony example, two agents are in- Unlike other systems, here we count on the existence fluenced in this way: 𝐴6 (Thermometer) and 𝐴7 (CO2 of object properties directly in the definition because the sensor). purpose of most IoT devices is just to send or receive The activities taking place in the IR Colony can there- (mostly numeric) data, or to react to them in a short, fore be divided into two groups: simple code (these devices are not computationally de- manding, they are often powered by a battery, which • explicit (provided by rules in programs), limits their performance considerably). • implicit (provided by other means). Compared to P Colonies, we also abandoned the static Implicit operations are included because the system is in- number of objects in the agent environment (state) and tended to model real systems dealing with heterogeneous the number of rules in programs. While this feature data, including dynamic systems with variable structure makes it easier to detect and compare the computational and purpose. power of systems, it complicates the modeling of a group Some aspects of the system could, of course, be de- of heterogeneous entities. In our system, it is even possi- signed differently. For example, it is not possible to create ble to continuously add objects to (or remove from) the and distribute completely new rules with a new label. In agent’s state that were not originally there. some circumstances this functionality would be useful, The agent 𝐴5 does not have any 𝑡𝑛 and 𝑠𝑛 objects in if needed it is not a problem to add it to the system. its state at the beginning of the system operation, it gets Further research can be focused in several directions: them only after the agents running the thermometer (𝐴6 ) and CO2 sensor (𝐴7 ) become functional and use their • improving the definition of IR Colonies to better multicast rules. match expected uses, The format of rules and programs is a hybrid between • detailed comparison of the properties, capabili- P Colonies with transferable programs and networks of R ties, and relationships with P Colonies (with trans- Systems. All programs are in principle transferable, this ferable programs), R Systems, and possibly other property (unlike P Colonies) is not determined directly similar systems, by a condition, but by a match in the label. • evaluation of possibilities and limits of the use of Conditionality refers more to the execution of rules IR Colonies, (similar to R Systems) and is even represented in two • creation of supporting tools that will allow the places in the system design: system to be used for modeling in digital form. • sets of reactants and inhibitors in programs, • properties of objects on the left-hand sides of References rules. [1] G. Păun, Membrane Computing: An Introduction, Cooperation is very simple between directly connected Springer, Heidelberg, 2002. agents, agents can send objects with properties to each [2] G. Păun, G. Rozenberg, A Guide to Membrane other at each step. A multicast rule is used for this pur- Computing, Theoretical Computer Science 287 pose, which corresponds to one-to-many communication (2002) 73–100. doi:https://doi.org/10.1016/ in computer networks. We also considered a rule for S0304-3975(02)00136-6. one-to-one communication, but this would mean adding [3] G. Păun, G. Rozenberg, A. Salomaa, The Oxford a destination agent label to the rule definition, which Handbook of Membrane Computing, Oxford Uni- versity Press, New York, 2010. [4] J. Kelemen, A. Kelemenová, G. Păun, P Colonies: Machinery 51 (2019). URL: https://doi.org/10.1145/ A Biochemically Inspired Computing Model, in: 3292674. doi:10.1145/3292674. Workshop and Tutorial Proceedings. Ninth Interna- tional Conference on the Simulation and Synthesis of Living Systems (Alife IX), Boston, Massachusetts, 2004, pp. 82–86. [5] L. Ciencialová, L. Cienciala, Transferable Knowl- edge in P Colonies, in: Information Technologies – Applications and Theory 2022 (ITAT 2022), volume 3226, Zuberec, Slovakia, 2022, pp. 167–174. [6] Š. Vavrečková, Notes on Relationship of P Colonies to Osmotic Computing and Computer Viruses, in: CEUR Proceedings of the 23rd Conference Informa- tion Technologies – Applications and Theory (ITAT 2023), 2023, pp. 147–153. [7] A. Ehrenfeucht, G. Rozenberg, Reaction Systems, Fundam. Informaticae 75 (2007) 263–280. URL: http://content.iospress.com/articles/ fundamenta-informaticae/fi75-1-4-15. [8] P. Bottoni, A. Labella, G. Rozenberg, Networks of Reaction Systems, International Journal of Foundations of Computer Science 31 (2020) 53–71. doi:10.1142/S0129054120400043. [9] B. Aman, From Networks of Reaction Systems to Communicating Reaction Systems and Back, in: J. Durand-Lose, G. Vaszil (Eds.), Machines, Com- putations, and Universality, Springer International Publishing, Cham, 2022, pp. 42–57. doi:https:// doi.org/10.1007/978-3-031-13502-6_3. [10] L. Ciencialová, L. Cienciala, E. Csuhaj-Varjú, P Colonies and Reaction Systems, volume 2, Springer International Publishing, 2020, pp. 269– 280. doi:10.1007/s41965-020-00051-1. [11] P. Sethy, Notes on P Systems versus R Systems, in: Developments in Computer Science(DCS), 2021, pp. 263–266. [12] Š. Vavrečková, Membrane System as a Communica- tion Interface between IoT devices, in: CEUR Pro- ceedings of the 22nd Conference Information Tech- nologies – Applications and Theory (ITAT 2022), 2022, pp. 184–190. [13] J. E. Hopcroft, J. D. Ullman, Introduction to Automata Theory, Languages and Computation, Addison-Wesley Series in Computer Science and Information Processing, Addison-Wesley, 1979. [14] W. Kassab, K. A. Darabkh, A–Z Survey of Internet of Things: Architectures, Protocols, Applications, Recent Advances, Future Directions and Recom- mendations, Journal of Network and Computer Ap- plications 163 (2020). URL: https://doi.org/10.1016/j. jnca.2020.102663. [15] J. Dizdarević, F. Carpio, A. Jukan, X. Masip-Bruin, A Survey of Communication Protocols for Internet of Things and Related Challenges of Fog and Cloud Computing Integration, Association for Computing