Ali ibn Abu Talib passed by and said: What is the matter with this (woman)? They said: This is a lunatic woman belonging to a certain family. She has committed adultery. Umar has given orders that she should be stoned.
He said: Take her back. He then came to him and said: Commander of the Faithful, do you not know that there are three people whose actions are not recorded: a lunatic till he is restored to reason, a sleeper till he awakes, and a boy till he reaches puberty?
He said: Yes. He then asked: Why is it that this woman is being stoned?
He said: There is nothing. He then said: Let her go. He (Umar) let her go and began to utter: Allah is most great.
In-book : Book 40, Hadith 49
English translation : Book 39, Hadith 4385