# 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  
An LHSNP system \(\Pi_{Sub1}\) with 2 input neurons as formula (5). The structure of \(\Pi_{Sub1}\) is as Figure 3. In Figure 3, the solid arrows represents the directed connection between two neurons. The design idea of \(\Pi_{Sub1}\) is as follows: 1 Input auxiliary module adjusts the spiking corresponding to the minuend binary number 0. It uses 2 spikings to represent the minuend binary number 0 in \(\sigma_{Sub}\). In order to distinguish it from the spiking corresponding to the subtrahend binary number 0. 2 Spiking controlled neuron \(\sigma_{aux_{2}}\) control \(\sigma_{aux_{1,0}}\) and \(\sigma_{aux_{1,1}}\) stops generating spiking output. 3 After the minuend is received by input neuron \(\sigma_{\text{in1}}\), it follows the auxiliary neuron \(\sigma_{aux_{1,6}}\) and the minuend neurons \(\sigma_{minuend}\) passed to \(\sigma_{Sub}\). 4 After the subtrahend is received by input neuron \(\sigma_{in_{2}}\), it follows the auxiliary neuron \(\sigma_{aux_{1,2}}\) and subtrahend neurons \(\sigma_{subthanol}\) passed to \(\sigma_{Sub}\). 5 Minuend and subtrahend complete the calculation in \(\sigma_{Sub}\) and send the calculation results to the environment. 6 Overflow monitoring neurons \(\sigma_{aux_{3}}\) monitors after the highest order of the minuend and subtracted numbers in \(\sigma_{Sub}\) performing subtraction, whether the calculation result is overflow. Figure 3: The LHSNP system \(\Pi_{Sub1}\) with 2 input neurons for two \(k\)-bit binary numbers subtraction. The rules of \(\Pi_{5 ub1}\) are divided into 5 groups: (1) Homogeneous neurons: rule set \(R_{max}\) = \(\{a\to a\}\) for auxiliary neurons, subtrahend neurons, and input neurons. (2) Minuend neuron \(\sigma_{m}\) uses rule set \(R_{m}\) = \(\{a^{2}\to a^{2},a^{3}\to a\}\). (3) Spiking control neuron \(\sigma_{aux_{2}}\) uses rule set \(R_{aux_{2}}\) = \(\{a^{k-1}\to a\}\). (4) Overflow monitoring neuron \(\sigma_{aux_{3}}\) uses rule set \(R_{aux_{3}}\) = \(\{a^{k}\to a^{5}\}\). (5) Subtraction operator neuron \(\sigma_{Sub}\) uses rule set \(R_{Sub}\) = \(\{a\to a;a^{2}\to crlambda;a^{3}/a^{2}\to a;\)\(a^{4}/a^{3}\to c\)\(rlambda;a^{6}\to a^{4}\}\). The formal definition of \(\Pi_{5 ub1}\) is as follows:  
\[\Pi_{5 ub1}=(O,\,\sigma_{in_{1}},\sigma_{in_{2}},\sigma_{aux_{1, \theta}},\sigma_{aux_{1,1}},\ldots,\,\sigma_{aux_{1,\theta}},\sigma_{aux_{2}},\sigma_{aux_{3}},\sigma_{m},\sigma_{s},\sigma_{Sub},\,\text{syn},\,Input_{1 },\,Input_{2},\,out) \tag{5}\]  
where:  
\(\begin{array}{ll}\text{(1)}&O\)= \(\{a\}\);  
\( \begin{array}{ll}\text{(2)}&\sigma_{in_{1}}=(0,R_{aux});\\ \text{(3)}&\sigma_{in_{2}}=(0,R_{aux_{2}});\\ \text{(4)}&\sigma_{aux_{1,i}}=(1,R_{aux_{i}}),\,0\leq i\leq 1;\\ \text{(5)}&\sigma_{aux_{1,i}}=(0,R_{aux_{i}}),\,2\leq i\leq 7;\\ \text{(6)}&\sigma_{aux_{2}}=(0,R_{aux_{2}});\\ \text{(7)}&\sigma_{aux_{3}}=(0,R_{aux_{3}});\\ \text{(8)}&\sigma_{m}=(0,R_{m});\\ \text{(9)}&\sigma_{s}=(0,R_{aux_{3}});\\ \text{(10)}&\sigma_{Sub}=(0,R_{Sub});\\ \text{(11)}&\text{syn}=\{(in_{1},\,aux_{1,6}),\,(in_{2},aux_{1,7}),\,( aux_{1,6},\,m),\,(aux_{1,7},s),\,(m,\,Sub),\,(s,\,Sub),\,(aux_{1,0},\,aux_{1,1}),\\ \text{(}aux_{1,1},aux_{1,0}),\,(aux_{1,1},aux_{2}),\,(aux_{2},aux_{1,0}), \,(aux_{2},aux_{1,1}),\,(aux_{1,1},aux_{1,2}),\,(aux_{1,2},\,aux_{1,3}),\\ \text{(}aux_{1,2},aux_{1,4}),\,(aux_{1,3},aux_{m}),\,(aux_{1,4},aux_{m}), \,(aux_{1,4},aux_{1,5}),\,(aux_{1,5},aux_{3}),\,(aux_{3},Sub)\});\\ \text{(12)}&in_{1}=Input_{1},\,in_{2}=Input_{2};\\ \text{(13)}&\text{out}=\text{Sub}.\\ \end{array} \)  
Through analysis \(\Pi_{5 ub1}\) and its rule set, we can see: \(\Pi_{5 ub1}\) contains 15 neurons and 9 rules, and completing the subtraction operation of 2 \(k\)-bit binary numbers requires a \(k+4\) time slice. **Theorem 3**. : \(\Pi_{5 ub1}\) _can perform any 2 \(k\)-bit binary numbers subtraction with 2 input neurons.