How action potential is generated while dreaming
There's a lot to unpack here, but maybe a good place to start is looking at the difference between an action potential and a brainwave. An action potential is the abrupt change in voltage of a single neuron in response to a pre-synaptic stimulus. Brainwaves are measured by EEG. They represent the sum of many neurons' activity.
If I understand the gist of your question, you want to know where the brain activity &quot;comes from&quot; during sleep/dreaming since there are no sensory stimuli. It's a good question, and a topic of research. Check out this article or any of Gyorgy Buzsaki's work. Also, you may be interested in the Default mode network.