MISHNA: Rabbi Akiva said: From where is it derived that idolatry, e.g., a statue of a deity, transmits impurity imparted by carrying even when the person who carries it does not come into contact with it, just as a menstruating woman does? As it is stated: “And you will defile the silver overlays of your statues, and the golden plating of your idols, you will cast them away as you would a menstruating woman [dava], you will tell it, get out” (Isaiah 30:22). Just as a menstruating woman transmits impurity imparted by carrying, so too, idolatry transmits impurity imparted by carrying. מַתְנִי׳ אָמַר רַבִּי עֲקִיבָא: מִנַּיִין לַעֲבוֹדָה זָרָה שֶׁמְּטַמְּאָה בְּמַשָּׂא כְּנִדָּה, שֶׁנֶּאֱמַר: ״תִּזְרֵם כְּמוֹ דָוָה צֵא תֹּאמַר לוֹ״ — מָה נִדָּה מְטַמְּאָה בְּמַשָּׂא, אַף עֲבוֹדָה זָרָה מְטַמְּאָה בְּמַשָּׂא.
GEMARA: Since the halakhot of idolatry and the impurity it causes are beyond the scope of tractate Shabbat, the fundamentals of this halakha are cited from tractate Avoda Zara. We learned in a mishna there: One whose house was adjacent to a house of idolatry, sharing a common wall, and the dividing wall fell, it is prohibited to rebuild it as he would thereby have built a wall for idol worship. What should one do? He moves four cubits into his own land and builds the wall there. גְּמָ׳ תְּנַן הָתָם: מִי שֶׁהָיָה בֵּיתוֹ סָמוּךְ לַעֲבוֹדָה זָרָה וְנָפַל, אָסוּר לִבְנוֹתוֹ. כֵּיצַד יַעֲשֶׂה? כּוֹנֵס לְתוֹךְ שֶׁלּוֹ אַרְבַּע אַמּוֹת וּבוֹנֶה.