# Spiking Neural P Systems for Basic Arithmetic Operations
## 3 Arithmetic Operation in Spiking Neural P Systems
### Binary Addition in SNP Systems
\[\Pi_{\mathbf{BASNP}}=(\mathrm{O},\,\sigma_{aux1},\,\sigma_{aux2},\,\ldots, \,\sigma_{aux6},\,\sigma_{num1},\,\sigma_{num2},\,\ldots,\,\sigma_{numk},\, \text{syn},\,\text{in},\,\text{out}) \tag{3}\]  
where:  
(1) \(\mathrm{O}=\{a\}\);  
(2) \(\sigma_{Input}=(0,\mathrm{R}_{Input})\), \(\mathrm{R}_{Input}=\{a\!\rightarrow\!a\}\);  
(3) \(\sigma_{aux1}=(1,\mathrm{R}_{aux1})\), \(\mathrm{R}_{aux1}=[a\!\rightarrow\!a]\);  
(4) \(\sigma_{aux2}=(1,\mathrm{R}_{aux2})\), \(\mathrm{R}_{aux2}=[a\!\rightarrow\!a]\);  
(5) \(\sigma_{aux3}=(0,\mathrm{R}_{aux3})\), \(\mathrm{R}_{aux3}=[a^{\mathrm{k}}\!\rightarrow\!a^{2}]\);  
(6) \(\sigma_{aux4}=(0,\mathrm{R}_{aux4})\), \(\mathrm{R}_{aux4}=[a^{\mathrm{k}}\!\rightarrow\!a^{2}]\);  
(7) \(\sigma_{aux5}=(0,\mathrm{R}_{aux5})\), \(\mathrm{R}_{aux5}=[a\!\rightarrow\!a;a^{3}/a\!\rightarrow\!\!\lambda]\);  
(8) \(\sigma_{aux6}=(0,\mathrm{R}_{aux6})\), \(\mathrm{R}_{aux6}=[a\!\rightarrow\!\lambda;a^{3}/a\!\rightarrow\!\!a]\);  
(9) \(\sigma_{num1}=(0,\mathrm{R}_{num1})\), \(\mathrm{R}_{numi}=[a\!\rightarrow\!a]\), \(i\in\{1,2,\,\ldots,\,k\}\);  
(10) \(\sigma_{Add}=(0,\mathrm{R}_{Add})\), \(R_{Add}=\{a\!\rightarrow\!a;a^{2}/a\!\rightarrow\!\lambda;a^{3}/a^{2}\! \rightarrow\!\!a]\);  
Figure 1: \(\Pi_{\mathbf{BASNP}}\) structure diagram. 1. \(syn=\{(Input,aux)\}\,|\,i\in\{5,6\}\cup\bigcup(aux_{1},aux_{2})|\cup(aux_{2},aux _{3})\,|\,i\in\{1,3,4\}\cup\{(aux_{3},aux_{6})\}\cup\{(aux_{4},aux_{3})\,|\,i \in\{2,5\}\}\cup\{(aux_{5},num_{1})\}\cup\{(num_{i},num_{i+1})\,|\,i\in\{1,2, \ldots,k-1\}\}]\)\(\cup\bigcup(num_{i},Add)\);
2. \(in=\sigma_{input}\);
3. \(out=\sigma_{0}\) (indicates that the system outputs the calculation results to the environment) In \(\mathbf{\Pi}_{BASNP}\), we divide the neurons except \(\sigma_{Input}\) and \(\sigma_{Add}\) into several groups (see the dashed box in Figure 1), and their functions are as follows: * Neuron \(Input\). The \(Input\) neuron receives binary strings from the environment and converts them to spikes in \(\mathbf{\Pi}_{BASNP}\). * Neuron \(Add\). The bit-by-bit addition of binary strings is realized by spiking rules and forgetting rules. * Auxiliary neuron groups \((aux_{1},aux_{2})\). Continuously send one spike to neurons \(aux_{3}\) and \(aux_{4}\) at each time slice. * The augend is input to the auxiliary neuron group. Accurately input the spike train representing the augend into the augend cache neuron group, and shield the interference when the augend spike train is input. * Addend input to auxiliary neuron group. Shield the input of the addend spike train, and accurately input the spike train representing the addend to the neuron \(Add\). * The augend cache neuron group. Buffer the augend spike train, and send the augend spike train to the neuron Add for operation in due course. For \(\mathbf{\Pi}_{BASNP}\), Theorem 1 can be obtained. **Theorem 1**. : _Input two natural numbers of length k (k \(\geq\) 2) to the input neuron \(\sigma_{Input}\) of \(\mathbf{\Pi}_{BASNP}\) sequentially from low to high in binary form; this system can correctly calculate the sum of these two natural numbers._  
Proof of Theorem 1.: Let t represent the system time and the unit be a time slice, that is, the value of t increases by one every time a time slice is passed. Here, X and Y are any two binary natural numbers with no more than k digits, and X \(=\sum_{i=0}^{k-1}x_{i}2^{i}\), Y \(=\sum_{i=0}^{k-1}y_{i}2^{i}\). We provide input to \(\mathbf{\Pi}_{BASNP}\) sequentially from low bit to high bit in binary form. When the binary number received by \(\mathbf{\Pi}_{BASNP}\) is 1, a spike \(a\) appears in \(\sigma_{Input}\); otherwise, no spike appears in \(\sigma_{Input}\). From t = 1 to t = 2k, \(\mathbf{\Pi}_{BASNP}\) receives spikes corresponding to x\({}_{0}\) to x\({}_{k-1}\) and y\({}_{0}\) to y\({}_{k-1}\) in sequence. When t > 2k + 1, \(\mathbf{\Pi}_{BASNP}\) will not accept input.