# Performing Arithmetic Operations with Locally Homogeneous Spiking Neural P Systems
## 4 An Locally Homogeneous Spiking Neural P System for Subtraction
### An LHSNP System with 2 Input Neurons for 2 Numbers Subtraction
Rule \(a^{4}/a^{3}\to crlambda\) means that 3 spikings in \(\sigma_{Sub}\) are consumed, 1 spiking is reserved (representing forward borrowing), and 0 spikings are sent to the environment. That is, the subtraction operation is \(0_{2}-1_{2}-1_{2}=0_{2}\), and 1 bit is borrowed forward. 5. Rule \(a^{6}\to a^{4}\) indicates that the highest bit of two binary numbers is carried during calculation in \(\sigma_{sub}\), data overflow. A total of 5 spikings come from the \(\sigma_{aux_{2}}\) and 1 spiking comes from \(\sigma_{sub}\) reservation. Rule \(a^{6}\to a^{4}\) means that 6 spikings in \(\sigma_{sub}\) are consumed and generate 4 spikings are sent to the environment, indicating data overflow. In summary, \(\Pi_{Sub1}\) can correctly calculate the difference between 2 \(k\)-bit binary numbers. \(\square\)  
In order to illustrate the operating process of \(\Pi_{Sub1}\), take the difference between 13 and 7 as an example for explanation. Assuming the current system is 8-bit. The equation 13 \(-\) 7 = 6 is expressed as \(00001101_{2}-00000111_{2}=00000110_{2}\) in \(\Pi_{Sub1}\). In the \(\Pi_{Sub1}\) calculation process, the number of spiking in all neurons and the number of spikings sent to the environment at each time slice are shown in Table 4. In Table 4, \"\(t\)\" represents the time slice. \"\(in_{1}\)\" represents the number of spiking in \(\sigma_{in_{1}}\). \"\(in_{2}\)\" represents the number of spiking in \(\sigma_{in_{2}}\). \"\(aux_{1,i}\) (\(0\leq i\leq 7\))\" represents the number of spiking in the auxiliary neuron \(\sigma_{aux1,i}\). \"\(aux_{2}\)\" represents the number of spiking in \(\sigma_{aux_{2}}\). \"\(aux_{3}\)\" represents the number of spiking in \(\sigma_{aux_{3}}\). \"\(m\)\" represents the number of spiking in \(\sigma_{minuend}\). \"\(s\)\" represents the number of spiking in \(\sigma_{Sub}\). \"\(out\)\" represent the number of spiking sent to the environment. The 2 \(k\)-bit binary numbers input and the calculation results are represented in bold font. \begin{table}
\begin{tabular}{c c c c c c c c c c c c c c c} \hline \(t\) & \(in_{1}\) & \(in_{2}\) & \(aux_{1,0}\) & \(aux_{1,1}\) & \(aux_{1,2}\) & \(aux_{1,3}\) & \(aux_{1,4}\) & \(aux_{1,5}\) & \(aux_{1,6}\) & \(aux_{1,7}\) & \(aux_{2}\) & \(aux_{3}\) & \(m\) & \(s\) & \(Sub\) & \(out\) \\ \hline \(t=0\) & - & - & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & - \\ \hline \(t=1\) & **1** & **1** & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & - \\ \hline \(t=2\) & **0** & **1** & 1 & 1 & 1 & 1 & 1 & 0 & 1 & 1 & 2 & 0 & 0 & 0 & 0 & - \\ \hline \(t=3\) & **1** & **1** & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 1 & 3 & 0 & 3 & 1 & 0 & - \\ \hline \(t=4\) & **1** & **0** & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 4 & 1 & 2 & 1 & 2 & - \\ \hline \(t=5\) & **0** & **0** & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 5 & 2 & 3 & 1 & 3 & **0** \\ \hline \(t=6\) & **0** & **0** & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 6 & 3 & 3 & 0 & 3 & **1** \\ \hline \(t=7\) & **0** & **0** & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 7 & 4 & 2 & 0 & 2 & **1** \\ \hline \(t=8\) & **0** & **0** & 2 & 2 & 1 & 1 & 1 & 1 & 0 & 0 & 1 & 5 & 2 & 0 & 2 & **0** \\ \hline \(t=9\) & - & - & 2 & 2 & 0 & 1 & 1 & 1 & 0 & 0 & 1 & 6 & 2 & 0 & 2 & **0** \\ \hline \end{tabular}
\end{table} 
Table 4: The number of spiking of all neurons in \(\Pi_{Sub1}\) and the number of spiking sent to the environment during the calculation of \(0000101_{2}-0000011_{2}=0000110_{2}\). The process of calculating the difference between \(0000101_{2}\) and \(00000111_{2}\) in \(\Pi_{Sub1}\) is as follows:  
1. Input Auxiliary Module
2. At \(t=0\) time slice, there is one spiking in \(\sigma_{aux1,0}\) and \(\sigma_{aux1,1}\). 3. At \(t=1\) to \(7\), \(\sigma_{aux1,0}\) and \(\sigma_{aux1,1}\) send 1 spiking to each other and maintain one spiking in. At the same time, \(\sigma_{aux1,1}\) will send one spiking to \(\sigma_{aux2}\) and \(\sigma_{aux1,2}\). After receiving spiking, these spikings accumulate inside \(\sigma_{aux2}\). And at \(t=7\) time slice, \(\sigma_{aux2}\) accumulates 7 spikings.