Jami` at-Tirmidhi #1423
The Book on Legal Punishments (Al-Hudud) 17:1
Narrated 'Ali:
That the Messenger of Allah (ﷺ) said: "The pen has been lifted from three; for the sleeping person until he awakens, for the boy until he becomes a young man and for the mentally insane until he regains sanity."