Sayyidina Ali reported that Allah’s Messenger (SAW) said, “The pen is raised concerning three: one who is asleep till he awakes, a child till he attains puberty and an insane person till he regains senses” This means that they are not bound by the commands of Shari’ah.
[Abu Dawud 4402, Ahmed 1327]