# Spiking Neural P Systems for Basic Arithmetic Operations
## 3 Arithmetic Operation in Spiking Neural P Systems
### Binary Multiplication in SNP Systems
\(syn=\{(Input,aux_{1})\,i\in\{5,6\}\}\cup((aux_{1},aux_{2}))\cup((aux_{2},aux_{ 3})\,i\in\{1,3,4\}\cup\{(aux_{3},aux_{6})\}\cup(|aux_{4},aux_{i})\,i\in\{2,5\} \cup\{(aux_{4},camd_{i})\}\,i\in\{1,2,\cdots,k\}\cup\{(aux_{5},camd_{1})\}\cup(|aux_{6 },mut_{1})\cup(|camd_{i},camd_{i+1})\,i\in\{1,2,\ldots,k-1\}\cup\{(mut_{i},mut_ {i+1})\,\,|\,i\in\{1,2,\ldots,k-1\}\}\cup\{1,2,\ldots,k-1\}\cup\{(bit_{i},bit_{ i+1})\,|\,i\in\{1,2,\ldots,k-1\}\}\cup\{(cant_{i},bit_{k+1})\,\,|\,i\in\{1,2,\ldots,k\}\}\] \(\cup\{(mut_{i},bit_{i})\,\,i\in\{1,2,\ldots,k\}\}\cup\{(bit_{i},Add)\,\,|\,i \in\{1,2,\ldots,k\}\}\);
14. \(in=input\);
15. \(out=Add\);  
In \(\mathbf{\Pi_{BMSNP}}\), the functions of each neuron (neuron group) are as follows:  
* Input neuron \(Input\). \(Input\) receives binary strings from the environment and converts them to spikes in \(\mathbf{\Pi_{BMSNP}}\). * Addition neuron \(Add\). The result of multiplying the multiplier by the multiplicand's bits is summed in the \(Add\) neuron. * Auxiliary neuron groups \((aux_{1},aux_{2})\). Continuously send a spike to neurons \(aux_{3}\) and \(aux_{4}\) at each time slice. * The multiplicand is input to the auxiliary neuron group. Control the multiplicand to be accurately input into the summand buffer neuron, shield the interference during multiplication input, and save the multiplicand in the multiplicand neuron group when the input of the highest bit of the multiplicand is completed. * Multiply the input auxiliary neuron group. The control multiplier is accurately input into the multiplier cache neuron group, and the interference when the multiplier is input is shielded. * Group of multiplicand cache neurons. Cache multiplicand. * Group of multiplier cache neurons. The multiplier is buffered, and each binary bit of the control multiplier is multiplied by the multiplicand. * Group of multiplicand neurons. The multiplicand is stored, and the multiplication operation of the multiplier and each binary bit of the multiplicand is performed. It can be seen from the following theorem that \(\mathbf{\Pi_{BMSNP}}\) can complete the multiplication of two k-bit binary strings as input. Theorem 3: _For the binary multiplier realized by the SNPS shown in Figure 7, two natural numbers of length k (k \(\geq\) 2) are input to its input neuron \(\sigma_{Input}\) in binary form from low to high, and this system can correctly calculate the product of two natural numbers._  
Proof of Theorem 3: Let t represent the time slice length, t = 0 the initial state of the system, X and Y two arbitrary natural numbers, and m and n two natural numbers less than or equal to k; then:  
\[\mathrm{X}\,=\sum\
olimits_{i=0}^{m-1}x_{i}2^{i},\,\,\mathrm{Y}\,=\sum \
olimits_{j=0}^{n-1}y_{j}2^{j},\,\,Z=\mathrm{X}\times\mathrm{Y}\]  
\[\mathrm{X}\times\mathrm{Y}=(\sum\
olimits_{i=0}^{m-1}x_{i}2^{i})\times(\sum \
olimits_{i=0}^{m-1}y_{j}2^{j})\]  
\[=\sum\limits_{i=0}^{m-1}\sum\limits_{j=0}^{n-1}x_{i}y_{j}2^{i+j}=\sum \limits_{i=0}^{m-1}y_{0}x_{i}2^{i+0}+\sum\limits_{i=0}^{m-1}y_{1}x_{i}2^{i+1}+ \ldots+\sum\limits_{i=0}^{m-1}y_{n-1}x_{i}2^{i+n-1}\]  
From the above formula, it can be concluded that the operation of solving X \(\times\) Y can be converted into solving n times the product of m digits and 1 digits, and the result of the product is shifted to the left by \(j\) bits according to the weight \(j\) of the multiplier y\({}_{j}\); then, the result of n times is shifted to the left summation. In fact, in the [30] the author did the same, using k\({}^{2}\) neurons to store the results of the n operations, and the storage process required k auxiliary neurons. The left shift of the product of the m-bit and 1-bit is achieved by adjusting the connections of neurons and finally adding the corresponding results n times. In the SNPS for multiplication designed in this section, k\({}^{2}\) neurons are not used to store the results of these n operations. This paper uses a new control method to make full use of the parallelism of neuron calculations, and sequentially outputs the converted operation results Z from low to high.