Narrated Ali ibn AbuTalib :ra: : The Prophet :saws: said:
There are three (persons) whose actions are not recorded: a sleeper till he awakes, a boy till he reaches puberty, and a lunatic till he comes to reason.
Abu Dawud said: Ibn Juraij has transmitted it from Al-Qasim b. Yazid on the authority of 'Ali from the Prophet :saws:. This version adds: "and an old man who is feeble-minded."( Abi Dawud)
Marwan ibn al-Hakam wrote to Muawiya ibn Abi Sufyan :ra: that a madman was brought to him who had killed a man. Muawiya :ra: wrote to him, "Tie him up and do not inflict any retaliation on him. There is no retaliation against a madman."(Muwatta)