# Spiking Neural P Systems for Basic Arithmetic Operations
## 3 Arithmetic Operation in Spiking Neural P Systems
### Binary Addition in SNP Systems
We use \(sp\)-\(x_{i}\) to represent the spike corresponding to the binary number x\({}_{i}\), that is, when x\({}_{i}\) = 1, \(sp\)-\(x_{i}\) = \(\{a\}\); otherwise, \(sp\)-\(x_{i}\) = \(\{\lambda\}\). Similarly, \(sp\)-\(y_{i}\) is used to represent the spike corresponding to the binary number y\({}_{i}\), which will be used in the following proofs. The execution process of \(\mathbf{\Pi}_{BASNP}\) is as follows. 1. \(\mathbf{t}\) = 0, start sending the corresponding spike \(sp\)-\(x_{0}\) of the lowest bit x\({}_{0}\) of X to \(\sigma_{Input}\). 2. From t = 1 to t = k, the regular execution of \(\mathbf{\Pi}_{BASNP}\) and the change of spikes in each neuron include: 1. \(\sigma_{Input}\) accepts sp-x\({}_{i}\) (0 \(\leq i\leq k-1\)) and applies the corresponding rules to send \(sp\)-\(x_{i}\) to \(\sigma_{aux5}\). During this period, \(\sigma_{aux5}\) can only receive the spikes sent by \(\sigma_{Input}\), and apply the rules to send the received spikes to \(\sigma_{num1}\) in turn. Similarly, \(\sigma_{numj}\) (1 \(\leq j\leq\mathrm{k}-2\)) sends the received spikes to \(\sigma_{numj+1}\) in sequence. 2. \(\sigma_{aux6}\) accepts the spikes sent by \(\sigma_{Input}\), if \(sp\)-\(x_{i}\) (0 \(\leq i\leq\mathrm{k}-2\)) = \(\{a\}\), use the rule \(a\)\(\rightarrow\)\(\lambda\) to forget this spike. 3. \(\sigma_{aux1}\) and \(\sigma_{aux2}\) (starting to work at t = 1) each maintain one spike, and \(\sigma_{aux3}\) and \(\sigma_{aux4}\) each maintain k \(-\) 1 spikes at t = k. 4. 4. There is no spike in \(\sigma_{Add}\). 3. At time t = k + 1, the rule execution of \(\mathbf{\Pi}_{BASNP}\) and the change of spikes in each neuron include: 1. \(\sigma_{aux6}\) accepts \(sp\)-\(x_{k-1}\) and forgets \(sp\)-\(x_{k-2}\). \(\sigma_{aux1}\) and \(\sigma_{aux2}\) keep one spike each, \(\sigma_{aux3}\) and \(\sigma_{aux4}\) keep k spikes and apply the rule \(a^{k}\)\(\rightarrow\)\(a^{2}\) to send two spikes to \(\sigma_{aux5}\) and \(\sigma_{aux6}\) respectively. 3. There is no spike in \(\sigma_{Add}\). 4. At time t = k + 2, the rule execution of \(\mathbf{\Pi_{BASNP}}\) and the change of spikes in each neuron include: 1. \(\sigma_{Input}\) accepts \(sp\)-\(y_{1}\) and sends \(sp\)-\(y_{0}\) to \(\sigma_{aux5}\). \(\sigma_{aux5}\) sends \(sp\)-\(x_{k-1}\) to \(\sigma_{num1}\) while receiving \(sp\)-\(y_{0}\) and \(\{a^{2}\}\) from \(\sigma_{aux4}\). \(\sigma_{numj}\) (\(1\leq j\leq k-1\)) accepts \(sp\)-\(x_{k-j}\) and sends \(sp\)-\(x_{k-j-1}\), and \(\sigma_{numk}\) accepts \(sp\)-\(x_{0}\). 2. \(\sigma_{aux6}\) forgets \(sp\)-\(x_{k-1}\) accepts both \(sp\)-\(y_{0}\) (from \(\sigma_{Input}\)) and \(\{a^{2}\}\) (from \(\sigma_{aux3}\)). 3. \(\sigma_{aux1}\) holds one spike, \(\sigma_{aux2}\) gets three spikes (one spike from \(\sigma_{aux1}\) and two spikes from \(\sigma_{aux4}\)), \(\sigma_{aux3}\) and \(\sigma_{aux4}\) hold one spike. 4. There is no spike in \(\sigma_{Add}\). At this point, the augend has been input into the augend cache neuron group and we can obtain Figure 2, which shows the spikes contained in each neuron in the configuration \(C_{k+2}\). 5. From t = k + 3 to t = 2k + 2, the rule execution of \(\mathbf{\Pi_{BASNP}}\) and the change of spikes in each neuron include: 1. \(\sigma_{Input}\) sequentially accepts \(sp\)-\(y_{j}\) (\(2\leq j\leq k-1\)) and simultaneously applies the rules to send \(sp\)-\(y_{j-1}\) to \(\sigma_{aux5}\) and \(\sigma_{aux6}\). When the number of spikes in \(\sigma_{aux5}\) is three, the rule \(a^{3}\)/\(a\)\(\rightarrow\)\(\lambda\) is activated and consumes one spike, so there will always be two spikes in \(\sigma_{aux5}\) and no spikes will be sent. 2. Since \(\sigma_{aux6}\) keeps two spikes, when it receives a spike from \(\sigma_{Input}\), it will apply the rule \(a^{3}\)/\(a\)\(\rightarrow\)\(a\) to consume one spike and send one spike to \(\sigma_{Add}\), and make \(\sigma_{aux6}\) keep two spikes. 3. \(\sigma_{aux1}\) sends 1 spike to \(\sigma_{aux2}\), \(\sigma_{aux2}\) receives one spike, \(\sigma_{aux3}\) and \(\sigma_{aux4}\) keep one spike. 4.