There are those who merit receiving answers to their Torah questions while they sleep. How does one achieve this? When one toils in Torah study while awake, it influences the person’s sleep, as well, for it becomes a “Jewish sleep.” (The Lubavitcher Rebbe, Sipurim V’hora’ot, page 230)
The Rishon Letzion (Sefardi Chief Rabbi), Rabbi Yitzchak Yosef, shlita relates an incident told to him by his father, the renowned Rabbi Ovadia Yosef, zt”l:
Rabbi Ovadia Yosef had completed his regular learning schedule for the day. It was late at night, and he fell asleep, troubled at not having found an answer to a question in Jewish law, regarding the accidental opening of an electronic door on Shabbat.
Suddenly, Rabbi Yosef awoke. As he sat up in bed, he recalled that, just seconds before, he had dreamed about the question which had been plaguing him. In his dream, he had been told that the answer to that question could be found on the third shelf of his bookcase, in the eighth book from the left.
Rabbi Yosef contemplated his dream. He got out of bed, washed his hands, and hurried over to the bookcase. Rabbi Yosef stood in front of the third shelf. He counted eight books from the left side. He eagerly took the book off the shelf, and looked at the title. It was the book Chayei Adam. This book was written more than two hundred years ago. It certainly wouldn’t have any comments on the use of electronic doors.
Disappointed, Rabbi Yosef took the book, and replaced it on the shelf. However, the book did not slide back into place. Again, Rabbi Yosef attempted to return the book to the shelf, without success. Rabbi Yosef looked closely at the shelf. There, he found another book, nestled between the Chayei Adam and the back panel of the bookshelf. Rabbi Yosef took the book off the shelf. It was the book Lev Avraham. Rabbi Yosef swiftly opened the book, and, to his delight, found the answer to the question which had puzzled him. Rabbi Yosef thanked Hashem for providing him the answer in his sleep.
When Rabbi Ovadia Yosef related the story to his son, Rabbi Yitzchak, Rabbi Yitzchak asked his father “is it possible to fulfill the mitzva of learning Torah while one sleeps?”
Answer of Rabbi Ovadia Yosef, zt”l:
What practical difference is there, whether or not one fulfills the mitzva while sleeping? Let’s assume that he fulfilled the mitzva.
Rabbi Yitzchak Yosef, shlita, explained his father’s words as follows:
Rabbi Shlomo Zalman Auerbach, zt”l, (Halichot Shlomo: Sukkot, chapter 9, se’if 17) ruled that, on the holiday of Sukkot, if there is insufficient room for everyone present to sleep in the Sukka, and there is no other option available, it is permissible to take someone who has fallen asleep in the Sukka, and move him outside the Sukka. The reasoning is follows: This person is presently sleeping. While he is sleeping, he has no awareness, and, as a result, he is exempt from fulfilling the mitzvot. Therefore, it is preferable to remove a person who is already sleeping, and, in his place, allow another person to fulfill his own obligation to sleep in the Sukka.
Rabbi Ovadia Yosef ruled differently. He held that it is forbidden to remove a sleeping person from the Sukka, in order to create room for another person to sleep in the Sukka. The reason is that Rabbi Yosef held that even one who is sleeping is obligated in mitzvot. (He proved this from the Shulchan Aruch, siman 63, 65, which says that if someone is sleeping, others should awaken him, until he recites the first verse of Shema.) Because, according to Rabbi Yosef’s understanding, a sleeping person is obligated in mitzvos, therefore, if he dreams about Torah learning while he sleeps, he fulfills the commandment of Torah learning while sleeping. If the rabbis, who establish the law on earth, rule that one who dreams about Torah fulfills a mitzva, Hashem will rule accordingly in Heaven, and will reward the person as if he performed a mitzva.
Summary: One who dreams words of Torah fulfills the mitzva of learning Torah.