# Performing Arithmetic Operations with Locally Homogeneous Spiking Neural P Systems
## 3 An Locally Homogeneous Spiking Neural P System for Addition
### An LHSNP System with 1 Input Neuron for 2 Numbers Addition
If 1 spiking is received in the environment, it represents binary number 1. If 0 spiking is received in the environment, it represents binary number 0. If 4 spikings are received in the environment at \(2k+4\) time slices, it indicates data overflow. The design idea of \(\sigma_{Add}\) is as follows: 1 spiking represents the binary number 1, and 0 spiking represents the binary number 0. If there is a carry generation after addition, retain 1 spiking in \(\sigma_{Add}\) to indicate carry 1. The corresponding formulas for each rule in \(\sigma_{Add}\) are as follows: (1) Rule \(a\to a\) indicates performing addition operation: \(1_{2}+0_{2}=1_{2}\) or performing addition operation \(0_{2}+0_{2}+1_{2}=0_{2}\)(there are carry reservations in \(\sigma_{Add}\)). There are two types of sources for this spiking in \(\sigma_{Add}\). Case 1: This 1 spiking comes from \(\sigma_{sum_{0}}\) or \(\sigma_{add}\). It indicates that the two binary addends input are 0 and 1. Case 2: This spiking comes from reserved in \(\sigma_{Add}\), and the two addends are 0. At this point, \(\sigma_{Add}\) is fired using rule \(a\to a\), consumes 1 spiking and generates 1 spiking, and sends it to the environment. (2) Rule \(a^{2}/a\to crlambda\) indicates performing an addition operation: \(1_{2}+1_{2}=10_{2}\), or \(1_{2}+0_{2}+1_{2}=10_{2}\) (there is carry reservation in \(\sigma_{Add}\)). There are two sources of these two spikings in \(\sigma_{Add}\). Case 1: these two spikings come from \(\sigma_{sum_{0}}\) and \(\sigma_{add}\). This indicates that the two binary addends input are 1 and 1. Case 2: one spiking comes from \(\sigma_{sum_{0}}\) or \(\sigma_{add}\), another spiking from \(\sigma_{Add}\) (i.e., carry 1). At this point, \(\sigma_{Add}\) is fired using rule \(a^{2}/a\to crlambda\), consume 1 spiking, retain 1 spiking (i.e., carry 1), and send 0 spiking to the environment. (3) Rule \(a^{3}/a^{2}\to a\) indicates performing an addition operation: \(1_{2}+1_{2}+1_{2}=11_{2}\). These 3 spikings come from \(\sigma_{sum_{0}}\) and \(\sigma_{add}\) (the 2 binary addends input are 1 and 1) and 1 spiking reserved in \(\sigma_{Add}\) (i.e., carry 1). At this point, \(\sigma_{Add}\) is fired using rule \(a^{3}/a^{2}\to a\), consumes 2 spikings, retains 1 spiking (i.e., carry 1), generates 1 spiking, and sends it to the environment. (4) Rule \(a^{5}\to a^{4}\) indicates data overflow. Among these 5 spikings, 4 spikings come from \(\sigma_{aux_{i}}\), and 1 spiking comes from the two addends with the highest bits after calculation retained in \(\sigma_{Add}\) (i.e., carry 1). At this point, rule \(a^{5}\to a^{4}\) is fired in \(\sigma_{Add}\), which consumes 5 spikings and generates 4 spikings to be sent to the environment. In summary, \(\Pi_{Add2}\) can correctly perform the sum of 2 \(k\)-bit binary numbers. \(\square\)  
To illustrate the operation process in \(\Pi_{Add2}\), an example is used to calculate the sum of 5 and 6. If the number of bits in the current system is 8, then \(5+6=11\) is represented as \(00000101_{2}+00000110_{2}=00001011_{2}\) in \(\Pi_{Add2}\). During the calculation process, the number of spiking in all neurons at each time slice and the number of spiking sent to the environment are shown in Table 1. In Table 1, \"\(t\)\" represents the time slice, and in represents the number of spiking in \(\sigma_{in}\). \"\(in\)\" represents the number of spiking in neuron \(\sigma_{in}\). \"\(aux_{3}\)\" and \"\(aux_{4}\)\" represent the number of spiking in auxiliary neurons \(\sigma_{aux_{i}}\) (\(i=3\), 4). \"\(aux_{1,i}\) (\(0\leq i\leq 9\))\" and \"\(aux_{2,i}\) (\(0\leq i\leq 1\))\" represent the number of spiking in auxiliary neurons \(\sigma_{aux_{i}}\) (\(1\leq j\leq 2\), \(0\leq i\leq 9\)). \"\(sum_{i}\)\" represents the number of spiking in the auxiliary neuron \(\sigma_{sum_{i}}\) (\(0\leq i\leq 7\)). \"\(add\)\" represents the number of spiking in additive neuron \(\sigma_{add}\). \"\(Add\)\" represents the number of spiking in the addition operation neuron \(\sigma_{Add}\).