Productive sleep and what does it mean?

Last night was the second time where I had a dream about solving a software development problem that I was having. Each time I have had these sorts of dreams I came up with the solution and it worked in my dream. I then woke up, implemented the solution in real life, and it worked there as well.

The first time it happened I thought it was a really neat thing that I was able to do and how awesome it would be if I could do that more often. But I never really thought about what actually happened in my dream. They key part being that I didn’t just come up with a potential solution in my dream. The code actually worked in my dream.

One might just simply assume that the reason it looked like it would work in my dream was because my mind believed it to be correct. So it showed the correct result as a form of confirmation bias.  I believed it should work in my dream so my dream made it appear as if it did work. That it actually worked in real life is just a happy coincidence.

But what if it is more than that? What if the reason that it worked in real life was because my brain did the calculation of that logic while I slept. I developed all of the code for both of these projects. Is it possible that my brain created a simulation based on all it has seen and then produced an end result based on the information it had retained from the development?

Mind blown…