# Spiking Neural P Systems for Basic Arithmetic Operations
## 3 Arithmetic Operation in Spiking Neural P Systems
### Binary Subtraction in SNP Systems
When t = k + 2, the minuend is input into the minuend cache neuron group, and the pattern C\({}_{k+2}\) of \(\mathbf{\Pi}_{\mathbf{BSSNP}}\) is as shown in $\rightarrow$3
5. From t = k + 3 to 2k + 2, \(\sigma_{Sub}\) simultaneously receives \(\text{sp-}x_{i}\) and \(\text{sp-}y_{i}\) (\(0\leq i\leq k-1\)) sequentially. Readers can refer to [13] for details of the subtraction operation in \(\sigma_{Sub}\). 6. Starting from time t = k + 4, the environment starts to receive the calculation results in sequence. 7. \(\text{t}=\text{2k}+2\), there are 2k + 1 spikes in \(\sigma_{aux9}\), and the rule \(a^{\text{2k+1}}{\rightarrow}a^{2}\) is executed, which will consume 2k + 1 spikes and send two spikes to \(\sigma_{aux7}\). 8. \(\text{t}=\text{2k}+3\), there is 1 spike in \(\sigma_{aux9}\), three spikes in \(\sigma_{aux7}\), and one spike in \(\sigma_{aux8}\), which will not change after that. Because subtraction does not need to consider the carry operation of adding the highest digits of two natural numbers, there is no need to wait another time for the system to reach the termination pattern. It is not difficult for readers to verify that the system will reach the termination pattern at t = 2k + 3. Based on the above description, readers can verify that for k \(\geq\) 2, the SNPS \(\mathbf{\Pi}_{\mathbf{BSSNP}}\) for subtractor constructed above can correctly solve the difference between two natural numbers with a binary length of k, and the proof is complete. Figure 6 shows a \(\mathbf{\Pi}_{\mathbf{BSSNP}}\) structure for a three-bit binary subtraction. Based on this \(\mathbf{\Pi}_{\mathbf{BSSNP}}\), the subtraction process of natural numbers 5 and 2 is listed in Table 2, which shows the number of spikes contained in each neuron in \(\mathbf{\Pi}_{\mathbf{BSSNP}}\) (5,2). The two natural numbers expressed in binary form are: \(101_{2}\), \(010_{2}\), and \(101_{2}-010_{2}=011_{2}\). In Figure 6, the augend and the addend are input through the neuron \(Input\), the auxiliary neuron group \((aux_{1},aux_{2})\) continuously sends a spike to the neuron \(aux_{3}\), \(aux_{4}\), respectively, and the auxiliary neuron group \((aux_{1},aux_{2})\) continuously sends a spike to the subtraction neuron \(Sub\), the subtrahend input auxiliary neuron group \((aux_{4},aux_{5})\) controls the subtrahend 5 (101) input to the subtrahend cache neuron group \((num_{1}\), \(num_{2}\), \(num_{3,1}\), \(num_{3,2}\), \(num_{3,3})\), the subtrahend input auxiliary neuron group \((aux_{3},aux_{6})\) controls subtrahend 2 (010) input to neuron \(Sub\), and finally subtraction operation is performed in neuron \(Sub\). In Table 2 column 1 likewise represents the system moment and columns 2-1 represent each neuron in the system. Each row of Table 2 represents the number of spikes in each neuron in the system at the corresponding moment. For example, the number in the first column of row 6 (step t = 5) is 1, indicating that the binary bit currently input to the neuron Input is 1. The numbers from the 11 th column to the 13 th column are 1, 0, 1, respectively, indicating that the binary bits of the minuend cache neuron group (\(num_{1}\), \(num_{2}\), \(num_{3,1}\), \(num_{3,2}\), \(num_{3,3}\)) are 1, 0, 1 respectively, and the input of minuend 5 (101) has been completed. The \(\mathbf{\Pi_{BSSNP}}\) designed in this section can complete the subtraction of two k-bit binary numbers within 2k + 3 time slices, and the number of neurons used is k + 13. The neurons in \(\mathbf{\Pi_{BSSNP}}\) use a total of seven types of non-delay spiking rules and four types of forgetting rules.