Srinivas Ramanujan famously said he did most of his work at night in dreams.
As a total aside, I've had sleep issues my whole life and can sometimes inadvertently induce lucid dreaming, and then I can think for hours while sleeping; it's amazing. Unfortunately a bit inception-y, but whatever.