It is narrated from Sayyiduna Ali (may Allah be pleased with him) that he (peace and blessings be upon him) said: "The pen has been lifted from three people: from the one who is asleep until he wakes up, from the child until he reaches puberty, and from the insane until he regains his reason."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 5089