This type of argument is well known as “Zhuangzi dreamed he was a butterfly” (莊周夢蝶 Zhuāng Zhōu mèng dié): One night, Zhuangzi (369 BC) dreamed that he was a carefree butterfly, flying happily. After he woke up, he wondered how he could determine whether he was Zhuangzi who had just finished dreaming he was a butterfly, or a butterfly who had just started dreaming he was Zhuangzi. This was a metaphor for what he referred to as a “great dream”:
He who dreams of drinking wine may weep when morning comes; he who dreams of weeping may in the morning go off to hunt. While he is dreaming he does not know it is a dream, and in his dream he may even try to interpret a dream. Only after he wakes does he know it was a dream. And someday there will be a great awakening when we know that this is all a great dream. Yet the stupid believe they are awake, busily and brightly assuming they understand things, calling this man ruler, that one herdsman ‑ how dense! Confucius and you are both dreaming! And when I say you are dreaming, I am dreaming, too. Words like these will be labeled the Supreme Swindle. Yet, after ten thousand generations, a great sage may appear who will know their meaning, and it will still be as though he appeared with astonishing speed.
The most famous of all Zhuangzi stories – “Zhuang Zhou Dreams of Being a Butterfly” – appears at the end of the second chapter, “On the Equality of Things”.
Once, Zhuang Zhou dreamed he was a butterfly, a butterfly flitting and fluttering about, happy with himself and doing as he pleased. He didn’t know that he was Zhuang Zhou.
Suddenly he woke up and there he was, solid and unmistakable Zhuang Zhou. But he didn’t know if he was Zhuang Zhou who had dreamt he was a butterfly, or a butterfly dreaming that he was Zhuang Zhou. Between Zhuang Zhou and the butterfly there must be some distinction! This is called the Transformation of Things.— Zhuangzi, chapter 2 (Watson translation)
The well known image of Zhuangzi wondering if he was a man who dreamed of being a butterfly or a butterfly dreaming of being a man is so striking that whole dramas have been written on its theme. In it Zhuangzi “[plays] with the theme of transformation”, illustrating that “the distinction between waking and dreaming is another false dichotomy. If [one] distinguishes them, how can [one] tell if [one] is now dreaming or awake?”