All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
An insane person will neither be reckoned nor punished because the fulfillment of Sharee‘ah obligations rests on the assumption of mental sanity. Therefore, if a person is insane their obligations are put aside.
‘Ali and ‘Aa’ishah narrated that the Prophet, sallallaahu ‘alayhi wa sallam, said that Sharee‘ah obligations are not assigned to an insane person until they are sane and aware of their actions, to a child until reaching the age of puberty and to a person who is asleep until they awaken. [Abu Daawood, At-Tirmithi, Ibn Maajah. Ahmad in Al-Musnad. Al-Bukhari, on the authority of ‘Ali]
Allaah Knows best.