# Spiking Neural P Systems with Rules Dynamic Generation and Removal
## 2 SNP Systems with Rules Dynamic Generation and Removal
### Definition and Description
#### 2.1.2 Description  
The definition of RDGRSNP systems proposed above is described here in detail. We mainly describe the process of applying rules in RDGRSNP systems, how the rules are executed in RDGRSNP systems, and the state and graphical definition of RDGRSNP systems.  
When neuron \(\sigma_{i}\) applies a spiking rule with rules dynamic generation and removal, \(r_{i}:E/a^{c}\to a^{p};\alpha_{1}r_{1},\alpha_{2}r_{2},\ldots,\alpha_{i }r_{l}\), \(c\) spikes in \(\sigma_{i}\) are consumed, and \(p\) spikes are sent along synapse \((i,j)\) to postsynaptic neuron \(\sigma_{j}\). Meanwhile, neuron \(\sigma_{i}\) adjusts its rule set \(R_{i}\) as follows. When \(\alpha_{k}=+\), \(\alpha_{k}r_{k}\) can be abbreviated to \(r_{k}\), indicating that rule \(r_{k}\) is added to the rule set \(R_{i}\) of neuron \(\sigma_{i}\). If rule \(r_{k}\) already exists \(R_{i}\), no rule is repeatedly added. When \(\alpha_{k}=-\), it means that rule \(r_{k}\) is removed from the rule set \(R_{i}\) of neuron \(\sigma_{i}\). If rule \(r_{k}\) does not exist in \(R_{i}\), no rule is removed. When \(\alpha_{k}=0\), \(\alpha_{k}r_{k}\) can be omitted and not written, and it means that rule \(r_{k}\) is neither added to nor removed from the rule set \(R_{i}\) of neuron \(\sigma_{i}\).  
When neuron \(\sigma_{i}\) applies a forgetting rule with rules dynamic generation and removal \(r_{i}:a^{s}\to\lambda;\alpha_{1}r_{1},\alpha_{2}r_{2},\ldots,\alpha_{k }r_{k}\), \(s\) spikes in \(\sigma_{i}\) are removed and no spikes are sent. Meanwhile, \(\sigma_{i}\) adjusts its rule set, operating in the same way as when applying the spiking rule with rules dynamic generation and removal.  
Note that an RDGRSNP system \(\Pi\) is parallel on the system level and sequential on the neuron level. There is a global clock used to mark steps throughout the system. When a neuron contains only one applicable rule, the neuron must apply it. When a neuron contains two or more applicable rules, the neuron can only non-deterministically choose one to apply. When no rule is applicable in the neurons of \(\Pi\), the system stops computing.  
In general, the state of the system at each step is represented by the number of spikes in each neuron at that step. However, in the proposed RDGRSNP system \(\Pi\), since rules can be generated and removed dynamically, the rules contained in each neuron should also be included in the state of system \(\Pi\). That is, the state of \(\Pi\) is represented by the number of spikes and the rules in each neuron, symbolized as \(C_{t}=\langle(n_{1},R_{1}),(n_{2},R_{2}),\ldots,(n_{m},R_{m})\rangle\). The initial state of \(\Pi\) is represented by \(C_{0}\). When the number of spikes and the rule sets contained in the neurons of \(\Pi\) do not change, the system stops computing.  
Regarding the graphical definition, rounded rectangles are used to represent neurons, and directed line segments are used to represent synapses between neurons. In an RDGRSNP system, the result of a computation is defined by the time interval between the first two spikes sent to the environment \(env\) by the output neuron \(\sigma_{out}\).