Reference for Gittin 7:1
מִי שֶׁאֲחָזוֹ קֻרְדְּיָקוֹס, וְאָמַר, כִּתְבוּ גֵט לְאִשְׁתִּי, לֹא אָמַר כְּלוּם. אָמַר, כִּתְבוּ גֵט לְאִשְׁתִּי, וַאֲחָזוֹ קֻרְדְּיָקוֹס, וְחָזַר וְאָמַר, אַל תִּכְתֹּבוּ, אֵין דְּבָרָיו הָאַחֲרוֹנִים כְּלוּם. נִשְׁתַּתֵּק, וְאָמְרוּ לוֹ נִכְתֹּב גֵּט לְאִשְׁתֶּךָ, וְהִרְכִּין בְּרֹאשׁוֹ, בּוֹדְקִין אוֹתוֹ שְׁלֹשָׁה פְעָמִים, אִם אָמַר עַל לָאו לָאו וְעַל הֵן הֵן, הֲרֵי אֵלּוּ יִכְתְּבוּ וְיִתֵּנוּ:
If one were seized by kordyakos [If his mind were unhinged by a demon potent against one who drinks new wine], and he said: "Write a get to my wife," he has said nothing. If he said: "Write a get to my wife," and then he were seized by kordyakos, and then he said: "Do not write it," there is nothing in his last words. [And it is not necessary to ask him again (if he wishes to divorce her) after he came to his senses, but we rely on his first words. In any event, so long as his mind is unhinged, the get is not written.] If he became mute, and they said to him: "We shall write a get to your wife," and he nodded his head, he is "examined" [by other questions] three times. If he responds (rationally) to no (i.e., something calling for a negative response), no; and to yes, yes, the get is written and given to her, [if he nodded "yes" to the get.]