Abstract: Since the discovery of rapid eye movement (REM) sleep, the nature of the eye movements that characterize this sleep phase has remained elusive. Do they reveal gaze shifts in the virtual environment of dreams or simply reflect random brainstem activity? We harnessed the head direction (HD) system of the mouse thalamus, a neuronal population whose activity reports, in awake mice, their actual HD as they explore their environment and, in sleeping mice, their virtual HD. We discovered that the direction and amplitude of rapid eye movements during REM sleep reveal the direction and amplitude of the ongoing changes in virtual HD. Thus, rapid eye movements disclose gaze shifts in the virtual world of REM sleep, thereby providing a window into the cognitive processes of the sleeping brain.Such coordination between eye movements and virtual HD suggests the involvement of the deep layers of the superior colliculus (dSC), a midbrain motor command center that drives eye and head movement to shift gazes during awake navigation. Here, we show that the dSC issues motor commands during REM sleep, e.g., turn left, that are similar to those issued in the awake behaving animal. Strikingly, these motor commands, despite not being executed, shift the internal representation of HD as if the animal had turned. Thus, during REM sleep, the brain simulates actions by issuing motor commands that, while not executed, have consequences as if they had been. These studies suggest that the sleeping brain, while disengaged from the external world, uses its internal model of the world to simulate interactions with it.