# Spiking Neural P Systems with Rules Dynamic Generation and Removal
## 4 Small Universal SNP System with Rules Dynamic Generation and Removal
At step \(g(x)\), \(\sigma_{in}\) receives the second spike, so at step \(g(x)+1\), \(\sigma_{in}\) applies \(r_{3}:a\to a\) again, sends one spike to neurons \(\sigma_{in_{1}}\), \(\sigma_{in_{2}}\), \(\sigma_{in_{3}}\), and \(\sigma_{in_{4}}\). Thus, starting at step \(g(x)+2\), these four neurons apply rule \(r_{4}:a^{2}\to a^{2}\) to send two spikes in a cycle, while sending two spikes to their postsynaptic neurons \(\sigma_{in_{5}}\), \(\sigma_{in_{6}}\), and \(\sigma_{in_{7}}\). Similarly, for neuron \(\sigma_{in_{6}}\), starting at step \(g(x)+3\), it applies rule \(r_{7}:a^{8}\to a^{4}\) continuously to send four spikes to the neuron \(\sigma_{2}\), by which the second input number is stored in \(\sigma_{2}\). For neurons \(\sigma_{in_{5}}\) and \(\sigma_{in_{7}}\), they apply rule \(r_{8}:a^{8}\to\lambda\) to forget the spikes. The process continues until \(\sigma_{in}\) receives the third spike. In addition, \(\sigma_{1}\) receives four spikes sent from \(\sigma_{in_{5}}\) at step \(g(x)+2\). Therefore, \(\sigma_{1}\) contains \(4g(x)\) spikes, which corresponds to the number \(g(x)\) in register 1. At step \(g(x)+y\), \(\sigma_{in}\) receives the third spike, so at step \(g(x)+y+1\), \(\sigma_{in}\) applies \(r_{3}:a\to a\) again and sends one spike to \(\sigma_{in_{7}}\), \(\sigma_{in_{7}}\), \(\sigma_{in_{3}}\), and \(\sigma_{in_{4}}\). At step \(g(x)+y+2\), neurons \(\sigma_{in_{1}}\), \(\sigma_{in_{2}}\), \(\sigma_{in_{3}}\), and \(\sigma_{in_{4}}\) all contain three spikes with rules \(r_{1}\), \(r_{3}\), and \(r_{4}\), so they all apply the spiking rule with rules dynamic generation and removal \(r_{1}:a^{3}\to a^{3};r_{2},-r_{1}\), send three spikes to neurons \(\sigma_{in_{5}}\), \(\sigma_{in_{6}}\), and \(\sigma_{in_{7}}\), and add rule \(r_{2}\) and remove rule \(r_{1}\). At step \(g(x)+y+3\), neurons \(\sigma_{in_{1}}\), \(\sigma_{in_{2}}\), \(\sigma_{in_{3}}\), and \(\sigma_{in_{4}}\) all apply the forgetting rule with rules dynamic generation and removal \(r_{2}:a^{3}\to\lambda;r_{1},-r_{2}\), forget three spikes, and remove rule \(r_{2}\) and add rule \(r_{1}\) again. Meanwhile, both neurons \(\sigma_{in_{5}}\) and \(\sigma_{in_{6}}\) contain 12 spikes and apply rule \(r_{10}:a^{12}\to\lambda\) to forget these 12 spikes. Neuron \(\sigma_{in_{7}}\) applies rule \(r_{9}:a^{12}\to a^{4}\) to send four spikes to \(\sigma_{l_{0}}\). In addition, \(\sigma_{2}\) receives four spikes sent by neuron \(\sigma_{in_{6}}\) at step \(g(x)+y+2\), so it has \(4y\) spikes, which corresponds to the number \(y\) in register 2. At step \(g(x)+y+4\), \(\sigma_{l_{0}}\) contains four spikes, simulating the starting instruction \(l_{0}\). Table 6 lists five variants of SNP systems and the number of neurons they need to build the INPUT module in the register machine. From Table 6, it can be seen that DSNP, PASNP, PSNRSP, MPAIRSNP, and SNP-IR require 9, 9, 13, 9, and 9 neurons, respectively, while RDGRSNP requires 11. However, this is acceptable because the INPUT module will be used only once during the simulation of function calculation and will not have a great impact on the overall number of neurons. Figure 11: INPUT module in register machine \(M_{u}\). According to the INPUT, deterministic ADD, SUB, and FIN modules described above, a small universal RDGRSNP system for simulating function \(\theta_{x}(y)=M_{u}(g(x),y)\) consists of 71 neurons, as follows:  
1. Neurons used to start simulating instructions: 25
2. Neurons used to simulate registers: 9
3. Auxiliary neurons in the ADD module: 0
4. Auxiliary neurons in the SUB module: \(2\times 14=28\)
5. The input and auxiliary neurons in the INPUT module: 8
6. The output neuron in the FIN module: 1  
We can also further reduce the number of neurons by compound connections between modules, and the following is the specific structure of compound connections between modules. Figure 12 represents the composite connection of a set of consecutive ADD instructions \(l_{i}:(ADD(r^{\prime}),l_{g})\) and \(l_{g}:(ADD(r^{\prime\prime}),l_{j})\).