Skip to main content
Advertisement
Browse Subject Areas
?

Click through the PLOS taxonomy to find articles in your field.

For more information about PLOS Subject Areas, click here.

  • Loading metrics

An arithmetic operation P system based on symmetric ternary system

Abstract

Nowadays, electronic computers use a “binary” numbering system, as opposed to “ternary” logic, which is closer to the way the human brain thinks. In this paper, the symmetric ternary system is applied to membrane computing for the first time. By combining the symmetric ternary system with membrane computing, this paper provides a more suitable arithmetic operation method for bio-computers, which breaks through the limitations of the traditional binary system in complex operations, and has a great potential for application in artificial intelligence and automatic learning in particular. The P System we designed include: Π+ for symmetric ternary addition, Π* for symmetric ternary multiplication, and Π/ for symmetric ternary division. The operation process of each P System was explained through examples, and their feasibility and effectiveness were verified through simulation software, UPSimulator. The system we designed can be further applied to symmetric ternary applications.

1 Introduction

Existing computers use a “binary” numbering system, which, despite the simplicity of its computational rules, is not a perfect representation of what humans really think. In contrast, “ternary” logic is much closer to the way the human brain thinks.

Ternary is the base 3 for the system, generally has two forms of expression: one is to “0”, “1”, “2” as the basic character form of expression. One is a representation with “-1”, “0”, “1” as the base character, and this representation is also known as symmetric or balanced ternary. In general, we do not have only “true” and “false” answers to questions, but also “I don’t know”. In symmetric triadic logic, the symbol “1” represents “true”; the symbol “-1” represents “false”; the symbol “0” represents “I don’t know”. Obviously, this logical expression is more in line with the development trend of computers in artificial intelligence, which provides the possibility of fuzzy arithmetic and autonomous learning for computers. The logic of symmetric ternary is usually applied to decision-making [1], such as voting with “yes”, “no”, or “abstain”; trading with “buy”, “sell”, or “wait-and-see”; double-entry bookkeeping reflects the thinking of symmetric ternary; SQL database system adopts three-valued logic, which is the application of symmetric ternary.

However, ternary logic is not a new emphasis. Ternary computers have long had a precedent in the history of computer development. As early as the 1950s and 1960s, a group of researchers at Moscow State University designed the first ternary computers in the history of mankind, “Сетунь” and “Сетунь 70”. The “Сетунь” computers used symmetric trigonometry instead of normal trigonometry [2]. Symmetric ternary logic circuits are not only faster and more reliable than binary logic circuits, but also require less equipment and power. One of the characteristics of symmetric ternary code is symmetry, i.e., the consistency of the opposite numbers, so that, unlike binary code, there is no concept of an “unsigned number”. As a result, the architecture of a ternary computer is much simpler, more stable, and more economical. The instruction system is also easier to read and very efficient. At the same time, symmetric ternary can represent integers more naturally than binary, with fewer integer digits of smaller absolute value (omitting the zero before the first non-zero digit). The numbers it records can express the full range of integers, and the introduction of “-1” eliminates the need for an extra minus sign for negative numbers. Its corresponding logic circuits are “negative voltage”, “zero voltage” and “positive voltage”.

As computer technology continues to advance, symmetric ternary logic has once again attracted the attention of the scientific community. As chips are made smaller and smaller, semiconductors are gradually moving closer to the realm of quantum. Difficult problems like quantum tunneling, where we might have to put in a very large amount of effort to possibly improve efficiency a little bit, might have to start opening up other paths. And ternary, right now, is being resurrected in forms other than electronic computers. The electronic computer has only two base states, on and off. But photonic computers, there are light intensity, wavelength, phase, propagation direction and polarization of five states. Professor Yi Jin of Shanghai University, starting from the basic principles of constructing computers and the basic characteristics of light, for the first time combined light intensity and polarization direction to represent the three-valued information, and utilized the spinning effect of liquid crystals and polarizers to realize the interconversion and migration of the three optical states, which put forward a brand-new theory of optical computers—Ternary Optical Computer (referred to as the TOC) [3]. In 2019, Chinese physicist Guangchan Guo and his team successfully completed the transmission of a ternary quantum signal called “qutrit”, which is the first successful ternary study by scientists in the quantum field [4].

Meanwhile, membrane computing has gradually become a popular research area in biocomputing. Membrane computing (also known as P System) is a new branch of natural computing, which is a new model of computation based on the abstraction of the structure and function of living cells and the collaboration of cell population such as tissues and organs. It is a computational model proposed by the Professor Gh.Păun in 1998 [5]. After Gh.Păun published his paper “Computing with membranes” in 2000 [6], it marked the birth of membrane computing as a research field. Since its introduction, membrane computing has attracted extensive attention from the scientific community, covering a wide range of disciplines or fields such as computer graphics and linguistics [7], biology [8], automation [9], and economics [10], and has rapidly evolved into a field of scientific research with great potential, and its development provides a rich computational framework for bio-computing.

With the intensive research on membrane computing, several studies have been devoted to the development and optimization of P System for arithmetic operations. Adrian Atanasiu designed arithmetic cell-like P System [11]. G.Ciobanu [12] designed arithmetic P System based on natural coding to realize arithmetic operations, which greatly simplified the membrane system structure. Ping Guo et al. [13] designed multi-layer membrane P System to realize arithmetic operations and reduce the computational complexity. Haiyan Zhang et al. [14] designed a single-layer membrane P System to realize arithmetic operations, which further simplifies the membrane structure and improves the computational efficiency. Minghong Luo et al. [15] designed a multi-layer membrane P System to realize arithmetic operations with signed numbers. Ping Guo et al. [1618] designed single-layer membrane P System to realize expression evaluation in the integer domain. Hong Zhang et al. [19] implemented basic arithmetic operations in the domain of rational numbers using P System. Kong, Y. et al. [20] investigated fundamental problems in fraction representation and arithmetic-fraction simplification. However all the above studies are based on binary or decimal.

While most research is still focused on binary and decimal systems, the potential of ternary is gradually emerging.Symmetric ternary is used in a number of applications due to its unique properties. Inspired by the balanced-ternary concept, Ji L et al. [21] demonstrates the reconfigurable generation of order-controllable vortices via cascaded N-layer meta surfaces. Faghih E et al. [22], for the first time, considers balanced ternary advantages to achieve a more efficient design for quantum multipliers as the main component in arithmetic blocks.

There are also many scientists who have devised arithmetic operations related to symmetric ternary. Ratan Kumar et al. [23] designs ternary logic circuits for nanoelectronics applications, the digital multiplier circuit is developed using Pseudo n-type carbon nanotube field effect transistors (CNTFETs). Based on the parallel carry-free TW-MSD adder, Yunfu S et al. [24] proposed a parallel R4-MSD square root algorithm, which is designed and implemented on the protype SD16 of ternary optical computer. Malik A et al. [25] proposes carbon nanotube field effect transistor (CNTFET)-based ‘exact’ and ‘approximate’ ternary full adders (TFA). Vudadha C [26] presents a new methodology to implement ternary Conditional Sum Adders (CSA) using CNFETs.

Although ternary has shown its potential for applications in several fields, its combination with membrane computing is still under-explored. And balanced ternary may become the most suitable number system for bio-computers. The study of arithmetic P System based on symmetric triples for membrane computing is of great academic and practical importance for the realization of a general-purpose bio-computer. The innovations of this paper mainly include:

  1. 1) Applying the symmetric ternary number system to membrane computing and designing a symmetric ternary arithmetic operation cell-like P System.
  2. 2) Dynamically creating cell membranes to realize arbitrary digit ternary arithmetic operations.
  3. 3) The symmetric ternary arithmetic operation system designed in this paper is simulated in UPSimulator (UPS), which is a simulator proposed in [27]. And the idea and feasibility of the algorithm are verified by examples.

The rest of the paper is organized as follows, Section 2 introduces the biological basis of membrane computing, describes the definition of cell-like P System. And then briefly introduces symmetric ternary and its arithmetic rules. Section 3 designs and implements an arithmetic P System based on symmetric ternary and detailing the rule execution process. Section 4 gives examples to elaborate the execution flow of the rule and verifies the correctness of the rule design through experimental simulation on computer. Section 5 summarizes the work accomplished in this paper and presents issues for future refinement.

2 Research foundation

2.1 Cell-like P system

The cell-like P System is one of the most basic and earliest proposed model of membrane computing [6], and an abstract schematic of the cell-like P System is shown in Fig 1. The membrane computing model divides a cell into multiple regions with a hierarchical structure, and the boundary of each region is the membrane. The outermost membrane, called the skin, separates the entire membrane system from its external environment, and the region outside the skin is the environment. If there are no other membranes within the membrane, it is called the basic membrane [28]. Each membrane represents a region; the region of a basic membrane is the space it contains; the region of a non-basic membrane refers to the space between the membrane itself and the membrane it directly contains. Regions contain objects represented by multi-sets, and objects evolve by executing reaction rules: objects are converted into other objects that can reach a certain membrane, which can also be dissolved or split. The execution of rules follows a nondeterministic and parallel character. The time when there are no rules to be executed in the region is called downtime, and the results of the computation are sent in the specified membrane or environment.

Membrane structures can be represented by generalized tables. A membrane is denoted by a pair of brackets ‘[]’, with the subscripts of the brackets denoting the label of the membrane. The basic membrane i is denoted as [i]i; if membrane i contains membrane k inside, the membrane structure is denoted as [i[k]k]i. The membrane structure of Fig 1 can be represented by the generalized table [1 [2]2 [3]3 [4 [5]5 [6 [8]8 [9]9]6 [7]7]4]1.

A cell-like P System of degree m (m ≥ 1) is defined as formula (1) [6]. (1) where:

  1. V is a finite non-empty alphabet, whose elements are objects;
  2. μ is a membrane structure containing m membranes, where m is called the degree of Π;
  3. ωiV* (1 ≤ im), denotes the multiset of objects contained inside region i in the membrane structure μ. V* is the set of arbitrary strings consisting of characters in V;
  4. Ri (1 ≤ im) is a finite set of evolutionary rules inside region i in the membrane structure μ, the evolutionary rules are binary groups (u, v), usually written as uv, where, u is a string in V+ and V+ is a set of non-empty strings in V*, v = v′ or v = vδ, here v′ is a string on the set , δ is a special character that does not belong to V, when a rule contains δ, the membrane is dissolved after executing the rule, the length of u is known as the radius of the rule uv;
  5. ρi (1 ≤ im), denotes a partial order relation in Ri;
  6. io is a number between 1 and m where the output of results in Π.

In this paper, the initial grid refers to the P System that has not yet started the computation. When operands are sent into the P System, which triggers the rules to be executed, the computation starts. The P System at a certain time slice in the computation is called the configuration at that moment. As rules are executed, the configuration of the P System will change until there are no rules left to be executed.

In every membrane structure, the rules will be enforced according to the following two principles:

  1. 1) Uncertainty. The P System will follow the principle of uncertainty when executing rules, which means that when there are n evolutionary rules in the membrane that can be executed at the same time, the P System randomly selects some of the rules to be implemented and the objects in the system to be evolved and chooses the rule that governs this evolution in a non-deterministic way [28].
  2. 2) Maximum Parallelism. In the P System, each step of the computation follows the principle of maximum parallelism, which means that all the rules that can be executed must be executed at the same time.

2.2 Symmetric ternary

The symmetric ternary was inspired by Gauss’s idea of the simplest set of weights. The simplest set of weights problem is as follows: How should the simplest set of weights be designed for weighing an object of any integer gram weight with weights on a balance. Usually when weighing an object with weights on a balance, the object to be weighed is placed on one side of the balance pan and the weights on the other side. Gauss proposed that the simplest set of weights is 1, 3, 9, 27, …, 3n, … grams, and that the weights can be placed on either side of the balance pan when weighing an object. It can be shown that the formula for weighing an object of any integer gram weight with the simplest set of weights is expressed as follows [29]: (2)

Where K is any positive integer, 3n, 3n−1, …, 31, 30 is the weight of each weight, the coefficients an, an−1, …, a1, a0 is one of −1,0,1. “1” represents that the weight is placed on the other side of the balance pan of the object to be weighed, “−1” represents that the weight is placed on the same side of the object to be weighed. And “0” means that the weight does not participate in the weighing. The 3n, 3n−1, …, 31, 30 are used to represent the mass of the weights are viewed as bit-weights, and ignoring the bit-weights, any positive integer K can be expressed in the following form [29]: (3)

Where an, an−1, …, a1, a0 is one of −1,0,1. To avoid confusion, −1 is generally denoted by T, and Z or z under special conditions. In this paper, we denote −1 by T. This representation of an arbitrary integer K by a string of numbers consisting of the various coefficients is called symmetric ternary.

Symmetric ternary system has many advantages, first of all, it has both positive and negative number elements, which can be expressed as positive or negative numbers by the same Eq (2). The sign of the first digit can be used to determine whether K is positive or negative; i.e., when the first digit is positive, K is positive, and when the first digit is negative, K is negative. The quadratic operations for symmetric ternary are also simple, and Tables 14 shows the quadratic rules for symmetric ternary.

3 Arithmetic P system based on symmetric ternary system

3.1 Addition and subtraction

According to the definition of cell-like P System, an addition and subtraction arithmetic P System based on symmetrical ternary can be defined as: (4) Where:

V = {a, b, c, T, 0, 1, s, f, E, Y};

;

ω1 = {Y};

;

i0 consists of M1 and his submembrane to hold the output;

ρ = 1, 2;

;

R1 = {r1: (T → (a, M1), 1), r2: (0 → (b, M1), 1), r3: (1 → (c, M1), 1),

r4: (sYE, 1), r5: (E → (E, M1), 1)};

r4: (EfE[f], 1), r5: (a → (a, in), 2), r6: (b → (b, in), 2), r7: (c → (c, in), 2),

r8: (aET(E, in), 1), r9: (bE → 0(E, in), 1), r10: (cE → 1(E, in), 1),

r11: (02 → 0, 1), r12: (0TT, 1), r13: (01 → 1, 1), r14: (T2 → 1(T, in), 1),

r15: (T1 → 0, 1), r16: (12T(1, in), 1)};

In this case, the correspondence of objects is as follows. The augend numbers T, 0, 1 are represented as objects a, b, c when they enter membrane M1 from membrane 1. Objects a, b, c reach to the membrane where object f is located, and are converted to objects T, 0 and 1 after reacting with f. In this way, the incoming objects a, b, and c will only react if they enter the membrane where f is located, thus enabling dynamic modeling and the storage of the augend numbers from low to high in membrane M1 and its submembranes. Object s is used to indicate the end of the augend input and to generate E with Y in Membrane 1. The purpose of E is twofold: to signal that the system is ready to input the addend, and to convert the addend to T, 0, and 1 so that it can be added to the augend.

Let us assume that the augend is anan−1a1 and the addend is bmbm−1b1. Then we illustrate the use of the rules in Π+ by adding these two numbers.

(1) Input of the augend:

We input one bit of the augend every two time slices from low to high. First a1 is sent into membrane 1.

  • Case 1: a1 = T. Executing rule r1 in R1, object T is converted to object a and sent into membrane M1. Executing rule r1 in RM, object a and object f are consumed with T produced, a new membrane M2 is created at the same time, and f is sent into membrane M2.
  • Case 2: a1 = 0. Executing rule r2 in R1, object 0 is converted to object b and sent into membrane M1. Executing rule r2 in RM, object b and object f are consumed with 0 produced, a new membrane M2 is created, and f is sent into membrane M2.
  • Case 3: a1 = 1. Executing rule r3 in R1, object 1 is converted to object c and is sent into membrane M1. Executing rule r3 in RM, object c and object f are consumed with 1 produced, a new membrane M2 is created, and f is sent into membrane M2.

Object ai (1 < i < n) is sent into membrane 1, converted to object a, b, or c (R1: r1r3), and enters membrane M1, then continues into the inner membrane (RM: r5r7) until it reaches membrane Mi where it is consumed with f and produces object T, 0, or 1 (RM: r1r3).

The last object an is input to the system with s. Object s is used to indicate that the augend has been fully entered. Rule r4 in R1 is executed, object s is consumed with Y and E produced, indicating that the system is ready to input the addend, while E enters Membrane M1.

(2) Input of the addend:

Object b1 is sent into membrane 1.

  • Case 1: b1 = T, rule r1 in R1 is executed, object T is converted to a to enter membrane M1. Object a is consumed with E (RM: r8), a is converted to T to be preserved in membrane M1, and E enters the inner membrane M2.
  • Case 2: b1 = 0, executing rule r2 in R1. Object 0 is converted to b and is sent into membrane M1. Object b and E are consumed (RM: r9), generating 0 to remain in membrane M1 and E is sent into membrane M2.
  • Case 3: b1 = 1, executing rule r3 in R1. Object 1 is converted to c to enter M1, then object c is consumed with E (RM: r10) and object 1 produced to stay in membrane M1, and E enters membrane M2.

The next object bi (1 < im) follows a similar pattern to b1. It is sent into membrane 1 first, and then converted to object a or b or c (R1: r1r3), entering membrane M1. Object bi continues into the inner membrane (RM: r5r7) until it reaches membrane Mi. Then it is consumed with E to produce object T, 0 or 1 (RM: r1r3).

(3) Addition:

The process of addition is simultaneous with the input of the addend. When b1 reaches membrane M1, the addition operation can be performed without having to wait for the addend to be fully input. Two numbers are added bit-wise from low to high and may produce carrying. The possibilities of ai + bi (1 ≤ i ≤ min{n, m}) in anan−1a1 and bmbm−1b1 are as follows:

  • Case 1: 0 + 0 = 0 (RM: r11);
  • Case 2: 0 + T = T (RM: r12);
  • Case 3: 0 + 1 = 1 (RM: r13);
  • Case 4: T + T = T1 (RM: r14);
  • Case 5: T + 1 = 0 (RM: r15);
  • Case 6: 1 + 1 = 1T (RM: r16).

For Case 4 and Case 6 that have generated feeds, the high bit of the result is sent into the inner membrane and the low bit is left in the original membrane.

The result of the addition is saved in the membrane M1, …, Mk (k ≥ 1) from low to high. The example of addition in Section 4.1.1 provides a more concrete demonstration of the implementation of the rules. In the addition P System Π+, symmetric ternary numbers “n + m” require at most 3n + 4m time slices for addition.

The subtraction P System simply changes the rule r1 in R1 to (T → (c, M1)), and r3 to (1 → (a, M1)), the operations are all consistent with addition, so we won’t go into too much detail here.

3.2 Multiplication

According to the definition of cell-like P System, a multiplication arithmetic P System based on symmetrical ternary can be defined as: (5) Where:

V = {a, b, c, T, 0, 1, A, B, C, x, y, z, p, q, r, u, n, s, f, E, Y};

;

ω1 = {Y};

;

i0 consists of M1 and his submembrane to hold the output;

ρ = 0, 1, 2;

;

R1 = {r1: (T → (a, M1), 2), r2: (0 → (b, M1), 2), r3: (1 → (c, M1), 2),

r4: (Tnun(a, M1), 1), r5: (0nun(b, M1), 1), r6: (1nun(c, M1), 1),

r7: (sYEn, 1), r8: (E → (E, M1), 1), r9: (u → (u, M1)|T, 0),

r10: (u → (u, M1)|0, 0), r11: (u → (u, M1)|1, 0)}

r4: (a → (a, in), 2), r5: (b → (b, in), 2), r6: (c → (c, in), 2), r7: (aEx(E, in), 1),

r8: (bEy(E, in), 1), r9: (cEz(E, in), 1), r10: (Ax → 1(px, in), 1),

r11: (Bx → 0(qx, in), 1), r12: (CxT(rx, in), 1), r13: (Ay → 0(py, in), 1),

r14: (By → 0(qy, in), 1), r15: (Cy → 0(ry, in), 1), r16: (AzT(pz, in), 1),

r17: (Bz → 0(qz, in), 1), r18: (Cz → 1(rz, in), 1), r19: (xf → [f], 1),

r20: (yf → [f], 1), r26: (ruC(u, in), 1), r27: (02 → 0, 1), r28: (0TT, 1),

r29: (01 → 1, 1), r30: (T2 → 1(T, in), 1), r31: (T1 → 0, 1), r32: (12T(1, in), 1)}

In this case, the correspondence of the objects is as follows.

The multiplicand numbers T, 0, and 1 are represented as objects a, b, and c when they enter membrane M1 from membrane 1. They reach the membrane where object f is located, and are converted to objects A, B and C after reacting with f. They are converted to objects p, q, and r when they are multiplied by the multiplier and move toward the inner membrane.

The multiplier numbers enter the membrane M1 also represented by the objects a, b, and c. When they arrive in the membrane where E is located, they are represented by the objects x, y, and z after reacting with E. Objects s, f, E, and Y act in the same way as addition. Object n is to control the generation of u, which converts the shifted multiplicands p, q, and r into the objects A, B, and C.

Let us assume that the multiplicand is anan−1a1 and the multiplier is bmbm−1b1. We illustrate the use of the rules in Π* by multiplying two numbers.

(1) Input of the multiplicand:

We input one bit of the multiplicand from low to high every two time slices. First, object a1 is sent into membrane 1.

  • Case 1: a1 = T, executing rule r1 in R1, object T is converted to a and is sent into membrane M1. Object a is consumed with f (RM: r1), a is converted to A to stay in membrane M1 and a new membrane M2 is generated, and f enters into membrane M2.
  • Case 2: a1 = 0, executing rule r2 in R1, object 0 is converted to b and is sent into membrane M1. Object b is consumed with f (RM: r2), b is converted to B to stay in membrane M1 and a new membrane M2 is generated, and f enters into membrane M2.
  • Case 3: a1 = 1, executing rule r3 in R1, object 1 is converted to c and is sent into membrane M1. Object c is consumed with f (RM: r3), c is converted to C to stay in membrane M1 and a new membrane M2 is generated, and f enters into membrane M2.

The rules for the execution of the multiplicand ai (1 < i < n) are similar to the rules for a1. Object ai is sent into membrane 1 first, then it is converted to object a, b or c into membrane M1. It continues into the inner membrane until it reaches membrane Mi where it is consumed with f to produce object A, B or C. The highest bit of multiplicand an is sent in membrane 1 with object s, which is used to indicate that the multiplicand has been completely imported. Rule r7 in R1 is applied, object s is consumed with Y to produce E and n, signaling that it is ready to send in the multiplier. At the same time, E is sent into membrane M1, and n stays in membrane 1 for the production of u.

(2) Input of the multiplier:

Object b1 is sent into membrane 1.

  • Case 1: b1 = T, rule r4 in R1 is applied, object T and n are consumed to produce u, n, and a, object a is sent into membrane M1. Rule r7 in RM is applied, object a is converted to x to stay in membrane M1, and E enters membrane M2.
  • Case 2: b1 = 0, rule r5 in R1 is applied, object 0 and n are consumed to produce u, n, and b, object b is sent into membrane M1. Rule r8 in RM is applied, object b is converted to y to stay in membrane M1, and E enters membrane M2.
  • Case 3: b1 = 1, rule r6 in R1 is applied, object 1 and n are consumed to produce u, n, and c, object c is sent into membrane M1. Rule r9 in RM is applied, object c is converted to z to stay in membrane M1, and E is sent into membrane M2.

The multiplier bi (2 ≤ im) performs similar rules to b1. Object bi is sent into membrane 1, then it is converted to object a, b, or c into membrane M1. It continues into the inner membrane until it reaches membrane Mi where it is consumed with E and produces object x, y, or z.

(3) Multiplication:

Multiplication of two numbers involves both multiplication and addition operations, and these rules are performed simultaneously. When object b1 is sent into membrane M1, it is prepared for multiplication operations with anan−1a1.

Multiplication possibilities of b1 × a1 are as follows:

  • Case 1: T × T = 1 (RM: r10);
  • Case 2: T × 0 = 0 (RM: r13);
  • Case 3: T × 1 = T (RM: r16);
  • Case 4: 0 × T = 0 (RM: r11);
  • Case 5: 0 × 0 = 0 (RM: r14);
  • Case 6: 0 × 1 = 0 (RM: r17);
  • Case 7: 1 × T = T (RM: r12);
  • Case 8: 1 × 0 = 0 (RM: r15);
  • Case 9: 1 × 1 = 1 (RM: r18).

Taking the case of “T × T = 1” as an example, Rule RM: r10 signifies that object A is consumed with x to produce 1, which is retained in the original membrane. Object A is converted to p and sent into membrane M2 along with object x. The conversion of object A to p and its movement into the inner membrane serves to: 1) Avoid confusion with the multiplicand object in the next layer of the membrane; 2) Allow the result of the multiplication to directly contribute to addition operations in the original membrane. After the input of b2, object u will first be sent to membrane M1 (RM: r9r11), where u will convert p back to A (RM: r24) before b2 is sent into membrane M2, enabling b2 to multiply with object A.

Object b1 is sent to membrane M2 to multiply by a2. The result of the calculation is retained in the original membrane, a2 is converted and sent into membrane M3 along with the multiplicand b1. This process continues until b1 enters membrane Mn. After multiplication by an, the converted b1 and an arrive at membrane Mn+1, where f is located. Object b1 is consumed with f (RM: r19r21), producing a new membrane Mn+2, and f is sent into the new membrane to prevent spillage.

After the input of b2, object u will be sent into membrane M1 first (RM: r9r11). Object u will convert the multiplicand from object p, q, or r to object A, B, or C (RM: r24r26) before b2 is sent into membrane M2. In membrane M2, object b2 multiplies with a1, and the product is then added to the result of b1 × a1 according to rules (RM: r27r32). b2 then continues into the inner membrane for further reactions. The next objects bi (3 ≤ im) also react according to the earlier described rules.

The final result is stored sequentially in membranes M1, …, Mk (k ≥ 1). The multiplication example in Section 4.1.2 demonstrates the concrete implementation of the rules. In the multiplication P System Π*, symmetric ternary numbers “n × m” require at most 3n + 4m + 3 time slices to complete the multiplication operation.

3.3 Division

According to the definition of cell-like P Systems, a division arithmetic P System based on symmetrical ternary can be defined as: (6) Where:

V = {a, b, c, T, 0, 1, A, B, C, K, M, N, H, V, k, x, i, v, r, u, g, s, f, e, E, Y, X};

;

ω1 = {Y};

;

i0 consists of M1 and his submembrane to hold the output;

ρ = 0, 1, 2, 3, 4, 5;

;

R1 = {r1: (T → (a, M1)|Y, 1), r2: (0 → (b, M1)|Y, 1), r3: (1 → (c, M1)|Y, 1),

r4: (T → (c, M1), 2), r5: (0 → (b, M1), 2), r6: (1 → (a, M1), 2),

r7: (sYE(s, M1), 1), r8: (E → (E, M1), 1), r9: (sKeK, 2),

r10: (KNk|e, 1), r11: (kee(k, M1), 1), r12: (NM|e, 1),

r13: (MH|e, 1), r14: (HK|e, 1), r15: (xeX(V, in), 0),

r16: (vXXV(k, in), 1), r17: (V → (V, in), 1), r18: (kXX, 0)}

r4: (a → (a, in), 2), r5: (b → (b, in), 2), r6: (c → (c, in), 2),

r7: (aEA(E, in), 1), r8: (bEB(E, in), 1), r9: (cEC(E, in), 1),

r10: (0kT, (k, in)|A, 3), r11: (0k → 0, (k, in)|B, 3), r12: (0k → 1, (k, in)|C, 3),

r13: (Tk → 1, (Tk, in)|A, 3), r14: (TkT, (k, in)|B, 3), r15: (Tk → 0, (k, in)|C, 3),

r16: (1k → 0, (k, in)|A, 3), r17: (1k → 1, (k, in)|B, 3), r18: (1kT, (1k, in)|C, 3),

r19: (02 → 0, 2), r20: (0TT, 2), r21: (01 → 1, 2), r22: (T2 → 1(T, in), 2),

r23: (T1 → 0, 2), r24: (12T(1, in), 2), r25: (s → (s, in), 1),

r26: (sg(u, out)|f, 0), r27: (0k → 0(k, in), 4), r28: (TkT(k, in), 4),

r29: (1k → 1(k, in), 4), r30: (u0 → δu, 1), r31: (u0kδu(k, in), 0),

r32: (ux|A, 0), r33: (ux|B, 0), r34: (ux|C, 0), r35: (xk → (ix, out), 1),

r36: (x → (x, out), 2), r37: (0i → 1(i, out)|A, 1), r38: (0i → 0(i, out)|B, 1),

r39: (0iT(i, out)|C, 1), r40: (Ti → 0(i, out)|A, 1), r41: (TiT(i, out)|B, 1),

r42: (Ti → (T, in)1(i, out)|C, 1), r43: (1i → (1, in)T(i, out)|A, 1),

r44: (1i → 1(i, out)|B, 1), r45: (1i → 0(i, out)|C, 1),

r46: (v → (v, out)|1A, 1), r47: (v → (v, out)|0B, 1), r48: (v → (v, out)|TC, 1),

r49: (v → (v, out)|1B, 1), r50: (v → (v, out)|0C, 1), r51: (v → (r, out)|1C, 1),

r52: (v → (r, out)|0A, 1), r53: (v → (r, out)|TB, 1), r54: (v → (r, out)|TA, 1),

r55: (r → (r, out), 1), r56: (V → (v, out)|f, 0), r57: (V → (V, in), 1),

r58: (gk → [1g], 0), r59: (1g → 1[g], 1), r60: (fkf(1, in), 1)}

In this case, the correspondence of some substances is as follows. The dividends T, 0, 1 are represented as the objects a, b, c when they enter the membrane M1 from the membrane 1. When they arrive in the membrane where f is located, and are represented as the objects T, 0, 1 after reacting with f. The divisors T, 0, 1 enter membrane M1 as objects c, b, a, and arrive in the membrane where E is located. They are represented as objects A, B, C after reacting with E. Objects s, f, E, and Y function in the same way as addition. Objects K, M, N, H, e are used to control the generation of object k. Object u is used to determine whether the digits of the dividend are equal to the divisor.

Object u is converted to x when it encounters the divisor. Object k produced after the dividend and the divisor digits are the same, will be consumed with x and i produced. Object i converts the dividend to the state it was in when it was just the same number of digits as the divisor. Send V from membrane 1 into the innermost submembrane of membrane M1. If the dividend is greater than the divisor, return v to membrane 1 to produce k, and continue with the addition; if it is less than that, return r to indicate that no more addition can be performed. At the end of the reaction, the quantity of k is the decimal representation of the quotient, and g converts the quantity of k to symmetric ternary.

In this paper, division of two numbers is actually accomplished by iterative subtraction, where the divisor is subtracted from the dividend. The cycle of subtraction continues until the dividend is less than the divisor. The number of rounds of subtraction is the quotient, and the remaining dividend that cannot be subtracted anymore is the remainder. In symmetric ternary, subtraction is converted to addition by simply changing the non-zero bit of the divisor to its opposite, i.e., 1 to T and T to 1. So, we can change iterative subtraction to iterative addition. The following modules are used in the Division P System:

  • Module 1 (R1: r1r8 and RM: r1r9) is the input of dividend and divisor. The dividend is input and stored in each layer of the membrane as “T, 0, 1”, and the non-zero bit of the divisor is turned into its opposite and stored in each layer of the membrane as “A, B, C”.
  • Module 2 (RM: r10r24) is the iterative addition of the dividend and the opposite of the divisor. When the number of bits of the dividend is greater than the number of bits of the divisor, no judgment is required to perform the addition operation.
  • Module 3 (RM: r37r45) is a module that restores the dividend to the state when the number of digits of the dividend is the same as the number of digits of the divisor. And at the same time, object k is consumed in its entirety, and the generation of k is suppressed in Membrane 1.
  • Module 4 (RM: r46r57) is a module that determines whether the dividend is greater than the divisor. If the dividend is greater than the divisor, the addition continues; if it is less, the reaction stops.

Let us assume that the dividend is anan−1a1 and the divisor is bmbm−1b1 (where nm), and we illustrate the use of the rules in Π/ below by dividing two numbers.

(1) Input of the dividend:

First, a1 is sent into membrane 1.

  • Case 1: a1 = T, rule r1 in R1 is applied, and object T is converted to a in the presence of Y and is sent into membrane M1. Rule r1 in RM is executed, and a is converted into T while a new membrane M2 is created, and f enters membrane M2.
  • Case 2: a1 = 0, rule r2 in R1 is applied, and object 0 is converted to b in the presence of Y and is sent into membrane M1. Rule r2 in RM is executed, and b is converted into 0 while a new membrane M2 is created, and f enters membrane M2.
  • Case 3: a1 = 1, rule r3 in R1 is applied, and object 1 is converted to c in the presence of Y and is sent into membrane M1. Rule r3 in RM is executed, and c is converted into 1 while a new membrane M2 is created, and f enters membrane M2.

Object ai (1 < i < n) is sent into membrane 1 and converted to object a, b, or c into membrane M1. Then it continues into the inner membrane until it reaches membrane Mi where it is consumed with f and is converted to object T, 0 or 1. The last bit of the dividend an is sent in with object s to indicate that the dividend has been fully entered. When object s enters membrane 1, rule r7 in R1 is applied. Object E is produced, signaling the system that it is ready to enter the divisor, while s is sent into membrane M1. After that, object s continues into the inner membrane (RM: r25) until it reaches membrane Mn. In membrane Mn, object s is converted to u and g (RM: r26) catalyzed by f. Object u is exported to membrane Mn−1 (RM: r26), and g stays in membrane Mn.

(2) Input of the divisor:

Object b1 is sent into membrane 1:

  • Case 1: b1 = T. Rule r4 in R1 is executed, and object T is converted to c in membrane M1. Then, rule r9 in RM is applied, object c is converted to C, and E enters membrane M2.
  • Case 2: b1 = 0. Rule r5 in R1 is executed, and object 0 is converted to b in membrane M1. Then, rule r8 in RM is applied, object b is converted to B, and E enters membrane M2.
  • Case 3: b1 = 1. Rule r6 in R1 is executed, and object 1 is converted to a in membrane M1. Then, rule r7 in RM is applied, object a is converted to A, and E enters membrane M2.

Object bi (2 ≤ im) is sent into membrane 1, then it is converted to object a, b, or c into membrane M1. It continues into the inner membrane until it reaches membrane Mi where it is consumed with E to produce object A, B, or C. The highest bit of the divisor bm is sent into membrane 1 with object s. When s is sent into membrane 1, rule r9 in R1 is applied, object s is consumed with K to produce E and K, which is used to produce object k.

(3) Division:

When the divisor is fully sent into the system, object k is produced in Membrane 1 (R1: r9r10), and k is sent into membrane M1 to trigger addition. Then one k is produced every three time slices into membrane M1 (RM: r10r14).

The possibilities of a1 + b1 are as follows:

  • Case 1: 0 + T = T (RM: r10);
  • Case 2: 0 + 0 = 0 (RM: r11);
  • Case 3: 0 + 1 = 1 (RM: r12);
  • Case 4: T + T = T1 (RM: r13);
  • Case 5: T + 0 = 0 (RM: r14);
  • Case 6: T + 1 = 0 (RM: r15);
  • Case 7: 1 + T = 0 (RM: r16);
  • Case 8: 1 + 0 = 1 (RM: r17);
  • Case 9: 1 + 1 = 1T (RM: r18).

For cases 4 and 9 that generate feeds, the high bit of the result is sent into the inner membrane and the low bit remains in the original membrane.

Taking “0+T = T” as an example, the rule RM: r10 indicates that 0 is consumed with k in the catalysis of A, generating T to remain in membrane M1 and k to enter membrane M2. The divisor, serving as a catalyst, remains unchanged to ensure that the size of the dividend decreases while the divisor remains the same.

When the first round of addition is completed and the first object k reaches the membrane Mn+1, where objects g and f are also present. The rule r58 in RM is executed to convert k to 1 and create a new membrane Mn+2, sending 1 and g into membrane Mn+2. Then, rule r59 in RM creates a new membrane Mn+3 and sends g into membrane Mn+3 to prevent result overflow. Thereafter, object f converts the k of membrane Mn+1 to 1 (RM: r60), sending it into membrane Mn+2 and converting the quotient to a symmetric ternary number. Object g encountering object 1 creates a new membrane, preventing overflow.

As addition proceeds, the dividend anan−1a1 decreases, and when an = 0, object u dissolves the membrane Mn (RM: r30). This continues until u dissolves the membrane Mm+1, and encounters the divisor (RM: r32r34). At this point, the bits of the dividend and the divisor are the same. Further additions should then check if the dividend is greater than the divisor, allowing addition to continue only if this condition is met. However, membrane 1 still produces one k every three time slices, which requires reversing the additions done after the numbers have the same number of digits and eliminating the k produced, sending a signal to stop k production in membrane 1.

When the digits of the dividend and divisor align, object u is converted to x. x is then transported out of the membrane (RM: r36) until it encounters k or reaches membrane 1. If x meets k, rule RM: r35 is enacted to produce i and x. Object i reverses the addition performed for this k (RM: r37r45), and x continues to membrane 1. Upon reaching, rule R1: r15 is executed, generating X and V. X regulates k production, while V moves to membrane Mm+1, converting to v catalyzed by f (RM: r56). v assesses whether the dividend exceeds the divisor, returning to membrane 1 if greater, or sending r to indicate that no further addition can be done (RM: r46r54).

When v returns to membrane 1, rule r16 in R1 is executed, producing k and sending it to membrane M1 for further addition, while V continues into membrane Mm+1, converted to v by f. The process iterates until r returns to membrane 1, signaling the cessation of reactions.

The remainder of the division is stored in membranes M1, …, Mi, and the quotient in membranes Mi+1, …, Mf (f > i + 1). The division example in Section 4.1.3 allows a more concrete demonstration of the implementation of the rule. In the division P System Π/, the symmetric ternary numbers of n/m (nm) bits require the following time slices to implement the division operation: The time slices required by the input module is 3n + 3m − 2, The time slices required by the iterative addition module is 4i, The time slices required by the revert module is 2m, The time slices required by the evaluation module is (2m + 3)j, where i + j = quotient, i is the quotient that results when the number of dividend digits is greater than the divisor, and j is the quotient that results when the number of dividend digits is equal to the divisor. The efficiency of the system will be greatly improved when the number of dividend digits is much larger than the divisor.

3.4 Comparison of computational efficiency

In this section, we analyse and compare P systems proposed in recent years for basic arithmetic operations, the results are shown in Table 5. The statistics include the number of rule types used for the four basic operations (addition, subtraction, multiplication, and division), and the number of time slices required to complete the operations. In [13, 14], m and n respectively represent the two decimal numbers used in the operation, and n = max {m, n}. In this paper, m and n respectively represent the two symmetric ternary numbers used in the operation, and n = max {m, n}.

thumbnail
Table 5. Time slices required and number of rule types used for four arithmetic approaches.

https://doi.org/10.1371/journal.pone.0312778.t005

In Table 5, the arithmetic P systems designed in [1316] are all decimal based. And instead of considering the input of data, the numbers to be computed are directly put into the membranes. In other words, they did not take into account the input of computational data. [13] designed an arithmetic P system based on a multi-layer membrane, and [14] designed an arithmetic P system based on a single membrane In [15] the time slices of the operations is not given, only it is mentioned that the complexity of these operations in P system is “linear”. Since [16] discusses arithmetic operation and arithmetic expression evaluation in transition P system based on rules with priority, no arithmetic operations are performed. Therefore, the time slices required for arithmetic operations is marked with ‘-’.

From the above analysis, it can be seen that this paper not only considers the input of the data, the dynamic generation and dissolution of the membrane, but also introduces the symmetric ternary number system, which eliminates the influence of the operational sign on the calculation. The arithmetic operation P system designed in this paper is more novel and has a wider application scenario.

4 Simulation and validation of rules

This section is based on Section 3 to further validate the correctness of the rules in the P System. The rules in Section 3 are simulated and experimented with UPSimulator [27]. The main discussion is the simulation experiments of (1) addition: 1T00 + 1T1 = 10T1; (2) multiplication: 1TT × 1T = 101; and (3) division: 101/1T = 1TT.

4.1 Examples of symmetric ternary arithmetic operations

4.1.1 Example of addition.

Here is an example of “1T00 + 1T1” to illustrate the implementation of the addition rules.

The initial state of Π+ is shown in Fig 2. Firstly, objects 0, 0, T, 1 are sequentially sent into membrane 1 every two time slices. When object 0 is input to membrane 1, it is converted to object b and is sent into membrane M1 immediately. Object b is consumed with f in membrane M1 and object 0 produced, at the same time, a new membrane M2 is created with f entering membrane M2. The next input of object 0 is converted to object b and is sent into membrane M2, which then is consumed with f and object 0 produced, and creates a new membrane M3, with f entering membrane M3. Object T is input to membrane 1, it is converted to object a and is sent into membrane M3. Object a is consumed with f and object T produced, and creating a new membrane M4, with f entering membrane M4.

When the highest bit object 1 is input, object s is input at the same time to indicate the end of the augend number. Objects 1 and s are input to membrane 1, and object 1 is converted to object c which is sent into membrane M4. Object c is consumed with f and object 1 produced, and creates a new membrane M5, with f entering into membrane M5. Object s is consumed with Y in membrane 1 and E produced, which indicates that the addend number can be input now, and at the same time, object E enters into membrane M1. Fig 3 shows the membrane structure where the augend is input completely and the addend waits to be input.

The lowest bit of the addend, object 1, is sent into membrane 1. Object 1 is converted to c and is sent into membrane M1. Object c and E are consumed with object 1 produced, and object E is sent into membrane M2. Object 1 is added to the 0 in membrane M1, and the generated results is 1, which is stored in membrane M1.

Input the second bit of the addend, object T, to membrane 1. Object T is converted to a, which is sent into membrane M2, where it is consumed with E to generate object T. Object T and the object 0 in membrane M2 are consumed with object T produced, which is stored in membrane M2.

Send the last bit of the addend, object 1, to membrane 1. Object 1 is converted to c, which is sent into membrane M3 and reacts with E to generate object 1. Object 1 is consumed with object T in membrane M3 and object 0 produced, which is stored in membrane M3.

At this point, there are no more rules in the system that can be executed, the system stops, and the obtained result “10T1” is saved in low to high order in M1,…,4 as shown in Fig 4. The rules of the entire system run in parallel. While the augend is still moving towards the inner membrane and building new membranes, the addend has already been input to start the addition operation. In this way, the whole system can perform the operation quickly.

Tables 6 and 7 show the process of object changes in each membrane during the whole system run. The number of digits of the augend and the addend also has an effect on the time slices. For example, in Table 6, it takes 23 time slices for the augend to be 1T00 (four-digit number) and the addend to be 1T1 (three-digit number). While in Table 7, it takes 24 time slices for the augend to be 1T1 (three-digit number) and the addend to be 1T00 (four-digit number). Therefore, when using this arithmetic system, the one with more digits can be selected as the augend to reduce the time slices.

thumbnail
Table 6. Process of object changes in each membrane during the addition.

(1T00+1T1).

https://doi.org/10.1371/journal.pone.0312778.t006

thumbnail
Table 7. Process of object changes in each membrane during the addition.

(1T1+1T00).

https://doi.org/10.1371/journal.pone.0312778.t007

4.1.2 Example of multiplication.

Here is an example of “1TT × 1T” to illustrate the implementation of the multiplication rules.

The input of the multiplicand is the same as the augend, so we won’t go into too much detail here. The multiplicand “1TT” is finally stored in the form of “AAC” in the membranes M1, M2, M3. Object s is consumed with Object Y in membrane 1 and object E produced, at which point the multiplier object T can be input, and E then enters the membrane M1. The state of the membrane system when the multiplier is about to be input is shown in Fig 5.

thumbnail
Fig 5. The configuration of Π* when the multiplier is about to be input.

https://doi.org/10.1371/journal.pone.0312778.g005

The lowest bit of the multiplier, object T, is input. Object T is consumed with n to generate u, and T is converted to object a into membrane 1. Object a is consumed with E to produce x while E enters the membrane M2. Object x is consumed with A to produce object 1 which is retained in membrane M1, and A is converted to object p which enters membrane M2 with x. In membrane M2, object x is consumed with A to produce object 1 which is retained in membrane M2. Object A is converted to p which enters membrane M3 with x. In membrane M3, object x is consumed with C to produce T to be retained in membrane M3, and C is converted to r which is sent into membrane M4 with x. Object x and f in the membrane M4 are consumed to create a new membrane M5, while f is sent into membrane M5 to prevent the result from overflowing.

At this point, the objects “CCA” are converted to “ppr” and moved one layer into the membrane. In fact, when object T is sent into the membrane system to carry out the above biochemical reaction, object 1 is also sent into the membrane to start the calculation. Fig 6 shows the state of the membrane system when object 1 has just been sent into the membrane, and object T has just arrived in the membrane M2 about to undergo the next calculation, and these calculations are in parallel.

thumbnail
Fig 6. The configuration of Π* when the multiplier is input completely.

https://doi.org/10.1371/journal.pone.0312778.g006

When object 1 is input, object u will be sent into membrane M1 and reach membrane M2, which converts p to A. It continues to move to the inner membranes, converting p and r to A and C. Object 1 is converted to c to be sent into membrane M2, which is consumed with E to generate z. Object z is consumed with A to produce T, and Object A is converted to p, which is sent into membrane M3 with z. Object T is consumed with the previously generated object 1 and object 0 produced. In membrane M3, object z and A are consumed to produce T, and then A is converted to p along with z into membrane M4. Object T in membrane M3 is consumed with the previously generated T to produce objects T1, with 1 retained in membrane M3 and T as a feed into membrane M4. In membrane M4, object z is consumed with C to produce 1, and then C is converted to r along with z into membrane M5. Object 1 in membrane M4 is consumed with the previously fed T to generate 0 to be retained in membrane M4. Object x is consumed with f to create a new membrane M6 while f is sent into membrane M6.

At this point, the reaction was completed. The result “1010” is preserved in the membranes M1 to M4 as shown in Fig 7.

thumbnail
Fig 7. The configuration at the completion of multiplication.

https://doi.org/10.1371/journal.pone.0312778.g007

Table 8 shows the process of object changes in each membrane as the entire system runs, taking a total of 20 time slices.

thumbnail
Table 8. Process of object changes in each membrane during the multiplication.

https://doi.org/10.1371/journal.pone.0312778.t008

4.1.3 Example of division.

Here is an example of “101/1T” to illustrate the implementation of the division rules.

The input of the divisor is the same as the augend. When the highest bit of the dividend, object 1, is sent into membrane 1 with object s, s is consumed with Y to produce E. At the same time, s will enter the membrane M1 until it reaches the membrane M4. Object s is converted to u and g catalyzed by f. Object u is transported to membrane M3, where the highest bit of the dividend is located. Object g remains in membrane M4. When E is detected in the system, the divisor can be entered. First input T, Object T is converted to c into membrane M1. Object c and E are consumed to generate C, and E is sent to membrane M2. Input 1 and s, Object 1 is converted to object a into membrane M2. Object a and E are consumed to generate A, and E is sent to membrane M3. Object s and K are consumed to generate object e and K. Object e and K execute the rules r10 to r14 in R1, and one k is produced every four time slices. Then k is sent into membrane M1 to trigger addition operation. The state of the membrane system when all the divisors are sent into membrane M1 is shown in Fig 8.

thumbnail
Fig 8. The configuration when all divisors are input to membrane M1.

https://doi.org/10.1371/journal.pone.0312778.g008

The first k enters membrane M1, object 1 and k are consumed to generate 1 and T in the presence of C, then 1 enters membrane M2 as a feed along with k. Object k then triggers addition in membrane M2, and so on, and finally will reach membrane M4. Object k and g in membrane M4 are consumed to create a new membrane M5, and object 1 and g enters membrane M5. And then 1 and g are consumed to create a new membrane M6 and g is sent into membrane M6.

After three rounds of addition, the highest digit of the dividend turns to 0. Object u detects 0, dissolves the current membrane, and the objects in membrane M3 fall into membrane M2. Object u detects the highest digit of the divisor in membrane M2, indicating that the digits of the dividend and the divisor are now the same. At this point it is not possible to directly perform the addition operation, but to compare the dividend and the divisor before deciding whether it is possible to perform the addition. However, the system continues to produce the object k, and the configuration of the system when the fourth K is generated is shown in Fig 9.

thumbnail
Fig 9. The configuration when the fourth k is just generated.

https://doi.org/10.1371/journal.pone.0312778.g009

First, we have to restore the addition operation after the third k, and send a signal to membrane 1 to stop producing k. Object u is converted to x catalyzed by A, and k will be consumed to avoid another addition operation. At the same time, object i will be produced, which will restore the dividend to the state where it did three addition operations (RM:r37r45). Eventually object i and x will be transported to membrane 1, where x is consumed with e to prevent the generation of k, and produce X and V. Object V is sent into membrane M4, object V is consumed to produce v catalyzed by f. Object v is sent to membrane M3 to compare the dividend and the divisor. If the dividend is greater than the divisor, then X produces k to continue the addition.

In this example, the first round of testing determines that the dividend is greater than the divisor, so object v is sent to membrane 1. Rule r16 in membrane 1 is executed, producing k which is sent into membrane M1 to perform addition. At the same time V is produced to prepare for the second round of testing. The second round of testing detects that the dividend is still greater than the divisor and sends v to membrane 1, performing the same steps as above. The third round of testing judges that no more addition can be performed, returning r to membrane 1.

At this point, there are no more rules in the system to execute and the system stops. The result of the quotient is saved in membranes M4,…,6, and if there is a remainder, it is saved in membranes M1,…,3. In this example, there is no remainder. The quotient “1TT” is preserved in the membranes M4,…,6 as shown in Fig 10.

Table 9 shows the process of object changes in each membrane as the division system runs. Due to space constraints, only a portion of the table is shown. It takes a total of 51 time slices.

thumbnail
Table 9. Process of object changes in each membrane during the division.

https://doi.org/10.1371/journal.pone.0312778.t009

4.2 Simulation of addition

For the simulation of Π+, the rules in Π+ are described in UPLanguage [27]. The membrane class “M” (i.e., membrane 1) is defined to contain the membrane class “Add”, membrane class “B” and membrane class “C”. Membrane classes B and C are used to input the augend and addend respectively. The overall membrane structure is as follows:

Environment {
    Membrane M m1 {
        Object Y;
        Membrane Add A1 {
            Object f;
        }
        Membrane B B1 {
            Object O, B, T, I, s;
        }
        Membrane C C1 {
            Object C, T, I;
        }
    }
}

Where ‘Object’ is used to specify the objects used in the simulation. The above rules indicate that initially the membrane m1 contains one object Y, the membrane A1 contains one object f, the membrane B1 contains objects O, B, T, I, s, and the membrane C1 contains objects C, T, I. It should be noted that the UPS can’t use numbers to represent the objects, so we use object I instead of 1, object O instead of 0. When the system starts running, it will output objects O, O, T, and Is into membrane m1 every two time slices from membrane B. Object s and Y are converted to E and enters all submembranes. When Object E enters membrane C, Membrane C begins to output addend numbers.

Here is a brief description of the format in which the rules are written in UPS.

  • Rule r1: T → (a, in all), 1; this means that object T is converted to object a and enters all submembranes with priority 1.
  • Rule r2: afTAdd:a{f}, 1; this denotes that object a and f are converted to object T and creates a new membrane that inherits the rules of the Add membrane class and that object f goes into the newly created membrane.

Rewriting the rules in Section 3.1 in the above format, the result is shown in Fig 11. Objects I, T, O, I are retained in membranes M1,…,4 separately, and a total of 24 time slices are used. It is one time slice more than the actual projection, because object E has to enter membrane C before releasing the addition in UPS, this will consume one time slice.

4.3 Simulation of multiplication

The membrane structure for multiplication is the same as for addition; the membrane class “M” contains the membrane class “Mul”, membrane class “B” and membrane class “C”. Membrane classes B and C are used to input the multiplicand and multiplier into membrane m1. The overall membrane structure is as follows:

Environment {
    Membrane M m1 {
        Object Y;
        Membrane Mul A1 {
            Object f;
        }
        Membrane B B1 {
            Object A, T, I, s;
        }
        Membrane C C1 {
            Object T, I;
        }
    }
}

Rewriting the rules in Section 3.2 with UPLanguage and running it yields the results as shown in Fig 12. Objects I, O, and I are retained in membranes M1,…,3. It takes a total of 21 time slices. This duration is one time slice more than the projection because, in the UPS, object E must enter membrane C before releasing the multiplier.

4.4 Simulation of division

For the simulation of Π/, the rules of Π/ are described in UPLanguage. We define a membrane class “M” which contains the membrane class “Div”, membrane class “B” and membrane class “C”. Membrane classes B and C are used to input the dividend and divisor into membrane m1. The overall membrane structure is as follows:

Environment {
    Membrane M m1 {
        Object Y, K;
        Membrane Div A1 {
            Object f;
        }
        Membrane B B1 {
            Object I, O, C, s;
        }
        Membrane C C1 {
            Object T, I;
        }
    }
}

Division includes the operation of dissolving membranes, and the rules are reformulated in UPLanguage as follows:

  • Rule r1: Ou → dissolve(u, out), 1; this rule specifies that when objects O and u are present together, the membrane is dissolved.
  • Rule r2: v → (v, out)|@O & @C, 1; this rule indicates that object v moves out only in the presence of both objects O and C.

Rewriting the rules in Section 3.3 with UPLanguage and executing the simulation yields the results depicted in Fig 13. The sequence ITT is retained in membranes M5, M6, M7 in descending order, consuming a total of 54 time slices. This duration is three time slices longer than the initial projection because Object E has to enter membrane C before the divisor can be released, taking one additional time slice. Two extra time slices are consumed because, after the dividend and divisor are entered, object s is then introduced into membrane 1.

5 Conclusion

Membrane computing is characterized by parallelism, distribution, and uncertainty. It has been proved that membrane computing has equivalent computational capabilities with Turing machines, and its powerful parallel computing capability can effectively solve the bottleneck currently faced by electronic computers. The study of arithmetic operation system based on membrane computing has very important academic and practical significance for the realization of a general-purpose bio-computer.

In this paper, a symmetric ternary system is innovatively introduced, which is more adaptable in future bio-computers and can be closer to the natural computation of the human brain than the traditional binary system. A dynamic membrane structure based on membrane computing is designed, which makes the parallel operation of multi-digit numbers possible and improves the computational efficiency. Simulation results show that the designed P-system is not only suitable for basic arithmetic operations, but also can be extended to more complex computational tasks, which provides a new direction for the development of future computing devices.

In the P System we designed, 21 rules are used to implement addition and subtraction, symmetric ternary numbers “n + m” requires at most 3n + 4m time slices for addition. 43 rules are used to implement multiplication, “n * m” require at most 3n + 4m + 3 time slices for multiplication. And 78 rules are used to implement division, n/m (nm) require at most 3n + 5m − 2 + 4i + (2m + 3)j time slices, (i + j = quotient, i is the quotient that results when the number of dividend digits is greater than the divisor, and j is the quotient that results when the number of dividend digits is equal to the divisor).

Future work will focus on further optimizing the performance of the system and exploring its applicability in more practical application scenarios. Also, we will further investigate their general structure to make it more versatile.

References

  1. 1. Bessmertny I, Sukhikh N, Vedernikov J, Koroleva J. Ternary Logics in Decision Making. In: International Conference on Reliability and Statistics in Transportation and Communication. Springer; 2020. p. 411–419. https://doi.org/10.1007/978-3-030-68476-1_38
  2. 2. Alexander W. The ternary computer. Electronics and Power. 1964;10(2):36–39. https://doi.org/10.1049/ep.1964.0037
  3. 3. Jin Y, He H, Lü Y. Ternary optical computer principle. Science in China Series F: Information Sciences. 2003;46:145–150. https://doi.org/10.1360/03yf9012
  4. 4. Hu XM, Zhang C, Liu BH, Cai Y, Ye XJ, Guo Y, et al. Experimental high-dimensional quantum teleportation. Physical Review Letters. 2020;125(23):230501. https://doi.org/10.1103/physrevlett.125.230501 pmid:33337185
  5. 5. Paun G. Membrane computing: an introduction. Springer Science & Business Media; 2012.
  6. 6. Păun G. Computing with membranes. Journal of Computer and System Sciences. 2000;61(1):108–143. https://doi.org/10.1006/jcss.1999.1693
  7. 7. Ciobanu G, Păun G, Pérez-Jiménez MJ. Applications of membrane computing. vol. 17. Springer; 2006.
  8. 8. Frisco P, Gheorghe M, Pérez-Jiménez MJ. Applications of membrane computing in systems and synthetic biology. Springer; 2014.
  9. 9. Buiu C, Vasile C, Arsene O. Development of membrane controllers for mobile robots. Information Sciences. 2012;187:33–51. https://doi.org/10.1016/j.ins.2011.10.007
  10. 10. Păun G, Păun R. Membrane computing and economics: Numerical P systems. Fundamenta Informaticae. 2006;73(1-2):213–227.
  11. 11. Atanasiu A. Arithmetic with membranes. Romanian Journal of Information Science and Technology, 2001, 4(1): 5–20.
  12. 12. Ciobanu G. A Programming perspective of the membrane systems. INTERNATIONAL JOURNAL OF COMPUTERS COMMUNICATIONS & CONTROL. 2006;1(3):13–24. https://doi.org/10.15837/ijccc.2006.3.2291
  13. 13. Guo P, Chen J. Arithmetic operation in membrane system. In: 2008 International Conference on BioMedical Engineering and Informatics. vol. 1. IEEE; 2008. p. 231–234. https://doi.org/10.1109/bmei.2008.136
  14. 14. Guo P, Zhang H. Arithmetic operation in single membrane. In: 2008 International Conference on Computer Science and Software Engineering. vol. 3. IEEE; 2008. p. 532–535. https://doi.org/10.1109/csse.2008.1212
  15. 15. Guo P, Luo M. Signed numbers arithmetic operation in multi-membrane. In: 2009 First International Conference on Information Science and Engineering. IEEE; 2009. p. 393–396. https://doi.org/10.1109/icise.2009.1062
  16. 16. Guo P, Liu SJ. Arithmetic expression evaluation in membrane computing with priority. Advanced Materials Research. 2011;225:1115–1119. https://doi.org/10.4028/www.scientific.net/amr.225-226.1115
  17. 17. Guo P, Chen HZ. Arithmetic expression evaluation by P systems. Appl Math. 2013;7(2L):549–553. https://doi.org/10.12785/amis/072l26
  18. 18. GUO P, CHEN H, ZHENG H. Arithmetic expression evaluations with membranes. Chinese Journal of Electronics. 2014;23(1):55–60.
  19. 19. GUO P, ZHANG H, CHEN H, CHEN J. Fraction arithmetic operations performed by P systems. Chinese Journal of Electronics. 2013;22(4):690–694.
  20. 20. Nan H, Kong Y, Zhan J, Zhou M, Bai L. P System with Fractional Reduction. Applied Sciences. 2023;13(14):8514. https://doi.org/10.3390/app13148514
  21. 21. Liu J, Qi J, Yao J, Hu W, Zhang D, Xu HX, et al. Balanced-ternary-inspired reconfigurable vortex beams using cascaded metasurfaces. Nanophotonics. 2022;11(10):2369–2379. https://doi.org/10.1515/nanoph-2022-0066
  22. 22. Faghih E, Taheri M, Navi K, Bagherzadeh N. Efficient realization of quantum balanced ternary reversible multiplier building blocks: A great step towards sustainable computing. Sustainable Computing: Informatics and Systems. 2023;40:100908. https://doi.org/10.1016/j.suscom.2023.100908
  23. 23. Ratan Kumar S, Koteswara Rao L, Kiran Kumar M. Design of Ternary Multiplier Using Pseudo NCNTFETs. Russian Microelectronics. 2023;52(2):119–127. https://doi.org/10.1134/s1063739723700245
  24. 24. Yunfu S, Zhehe W. Design and implementation of R4-MSD square root algorithm in ternary optical computer. Soft Computing. 2024; p. 1–14. https://doi.org/10.1007/s00500-023-09518-6
  25. 25. Malik A, Hussain MS, Hasan M. Energy-Efficient Exact and Approximate CNTFET-Based Ternary Full Adders. Circuits, Systems, and Signal Processing. 2024;43(5):2982–3003. https://doi.org/10.1007/s00034-023-02589-8
  26. 26. Vudadha C. Design of CNFET-based Ternary Conditional Sum Adders using Binary Carry Propagation. In: 2024 IEEE International Symposium on Circuits and Systems (ISCAS). IEEE; 2024. p. 1–5. https://doi.org/10.1109/iscas58744.2024.10558451
  27. 27. Guo P, Quan C, Ye L. UPSimulator: A general P system simulator. Knowledge-Based Systems. 2019;170:20–25. https://doi.org/10.1016/j.knosys.2019.01.013
  28. 28. Păun G, Rozenberg G. A guide to membrane computing. Theoretical Computer Science. 2002;287(1):73–100. https://doi.org/10.1016/s0304-3975(02)00136-6
  29. 29. Chen Q. T01 Ternary numeral system. Journal of Mathematics(China). 1958;03:4–7.