Dreams == unit test

Why do we sleep? For millennia, people thought they know the answer. If sleep is a state of inactivity, then it must be for rest.

This is false.

It is known that sleep is far more active state for a brain than solving a math olympiad. It was then suggested that it's a kind of efficient maintenance task. REM Sleep - the dreaming phase - is though less active, comparable to awake. In this phase, the muscle movements are though much smaller, no random violent shakes as in NREM. A human would have 4-5 dreaming phases during normal sleep (statistics from random emergency wake-ups). All funny information obtained during the dream is then recycled, and you are going to remember one if you are lucky.

It seems like while dreaming, the body is forcefully detached from its brain to avoid damage from unconscious mechanical activity. As with any system, internal implementation details leak out thru its bugs ("false on" and "false off"). Sleepwalking and cataplexy are exactly the opposite and not uncommon defects of the same valve. The first makes one walk or talk nonsense during sleep, while the second makes one collapse during wake state. Still, nobody (apart from mysticians like Sigmund Freud, to which we won't listen) seems to have a normal answer - WTF are the dreams?

I had a dream last night. It had to deal with a girl explaining a group about color codes for different failures of a train routing system. Nevermind that part. Then it struck me. This surely must be it. Obviously, it cannot be anything else. Dreams are not for garbage collection. They are not a maintenance task. Dreams are a self-test (aka BIT, QA phase, whatever).

It seems quite natural for researches to miss it. Quality Assurance is counter-intuitive even for software developers. It takes young specialists some time to learn that after development or maintenance on a system you need to fucking test it, because you might have broken something, and to debug it if it's broke. It seems reasonable that this is what a brain does, after an active maintenance cycle, by injecting a funny story called a dream, practicing some thinking and page faults in a test environment, disconnected from dangerous muscle machinery, instead connecting itself to nice visual and audio simulators for test data input.

GH: "This cannot be true. I know many people who like to sleep, but hate to do QA!"