# 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
These spikings are transmitted along \(\sigma_{aux_{1,7}}\), \(\sigma_{outrabnd}\), and \(\sigma_{Sub}\). 10. \(t=3\) to \(k+2\), the spiking corresponding to each binary bit of the subtrahend is sequentially received by \(\sigma_{Sub}\). 11. \(t=1\) to \(k\), the spiking corresponding to each binary bit of the subtrahend is sequentially received by \(\sigma_{in_{2}}\) in order from low to high. These spikings are transmitted along \(\sigma_{aux_{1,7}}\), \(\sigma_{outrabnd}\), and \(\sigma_{Sub}\). 12. \(t=3\) to \(k+2\), the spiking corresponding to each binary bit of the subtrahend is sequentially received by \(\sigma_{outrabnd}\). 13. \(t=4\) to \(k+3\), the spiking corresponding to each binary bit of the subtrahend is sequentially received by \(\sigma_{Sub}\). At each time slice, one spiking sent by \(\sigma_{outrabnd}\) represents the binary number 1, and zero spiking represents the binary number 0. At \(k+3\) time slice, the highest bit of the subtrahend is received by \(\sigma_{Sub}\). 14. Subtraction Operation \(t=1\) to \(3\), there is no spiking were received in \(\sigma_{sub}\). 15. \(t=4\) to \(k+3\), the spiking corresponding to each binary bit of the minuend and subtrahend sent by \(\sigma_{minuend}\) and \(\sigma_{outrabnd}\) are sequentially received by \(\sigma_{Sub}\). 16. \(t=5\) to \(k+4\), \(\sigma_{sub}\) sends calculation results to the environment at each time slice. It is the effective output time of \(\Pi_{Sub1}\) when there is no overflow in the calculation. At \(t=k+3\) time slice, the highest bit of the two subtractors is calculated. At \(t=k+4\) time slice, \(\sigma_{aux3}\) uses rule \(a^{k}\to a^{5}\) to send 5 spikings to \(\sigma_{sub}\). These 5 spikings in the \(\sigma_{sub}\) detect whether there is a carry after the calculation of the highest bit of the two subtractions. If there is a carry generation, \(\sigma_{sub}\) uses rule \(a^{6}\to a^{4}\)_to_ send 4 spikings to the environment to indicate data overflow. 17. Subtraction Rules There are 5 rules in \(\sigma_{Sub}\) represent subtraction operations. The situation of performing subtraction in \(\sigma_{Sub}\) is as follows: 1. Rule \(a\to a\) indicates performing subtraction calculation: \(1_{2}-0_{2}=1_{2}\). There is one spiking in \(\sigma_{sub}\), which comes from \(\sigma_{minuend}\). It represents the subtracted binary bit 1. Rule \(a\to a\) represents consumption 1 spiking in \(\sigma_{sub}\), and sending 1 spiking to the environment, namely performing subtraction operation \(1_{2}-0_{2}=1_{2}\). 2. Rule \(a^{2}\to crlambda\) indicates performing subtraction calculation: \(0_{2}-0_{2}=0_{2}\) or \(1_{2}-1_{2}=0_{2}\). There are two spikings in the \(\sigma_{sub}\), and there are three sources of these two spikings. In the first case, these two spikings have come from \(\sigma_{minuend}\) and \(\sigma_{subturbnd}\). In the second case, one of them come from \(\sigma_{sub}\) retained spiking in \(\sigma_{sub}\)(be borrowed), and the other one come from \(\sigma_{subtAnhand}\). In the third case, these two spikings came from \(\sigma_{minuend}\). Rule \(a^{2}\to crlambda\) consumption 2 spikings in \(\sigma_{sub}\), and send 0 spiking to the environment, namely performance subtraction operation \(0_{2}-0_{2}=0_{2}\) or \(1_{2}-1_{2}=0_{2}\). 3. Rule \(a^{3}/a^{2}\to a\) indicates performing subtraction calculation: \(0_{2}-1_{2}=1_{2}\) and borrowing one digit forward. Two spikings come from \(\sigma_{minuend}\) and one spiking comes from \(\sigma_{addend}\). Rule \(a^{3}/a^{2}\to a\) represents consuming 2 spikings in \(\sigma_{sub}\), retaining 1 spiking (representing forward borrowing), and sending 1 spiking to the environment. That is, the subtraction operation performed is \(0_{2}-1_{2}=1_{2}\) and borrowing 1 digit forward. 4. Rule \(a^{4}/a^{3}\to crlambda\) means to perform subtraction: \(0_{2}-1_{2}-1_{2}=0_{2}\) and borrow 1 bit forward. Two spikings were sent by \(\sigma_{minuend}\), one spiking was sent by \(\sigma_{addend}\), and one spiking was retained in \(\sigma_{Sub}\).