The Talmud asks: But why not say that each one is as it is written, and conclude that the Torah requires, respectively, 3, two, and two interrogations in the 3 cases of idol worship, an idolatrous city, and conspiring witnesses, discussed in those verses? As, if it is so, i.e., if there is a requirement of 7 interrogations in all cases of capital law, let God write them in one place, and it would be derived from there to other cases. The Talmud answers: Since they are all written together, i.e., they all employ analogous terminology, one learns the halakhot of one from the other, and once one learns the halakhot of one from the other, they are considered as if they are written in one place.
והא לא דמיאן להדדי? (סימן: פלט, סייף, התראה.)
The Talmud asks: But those 3 instances of idol worship, an idolatrous city, and conspiring witnesses are not similar to each other, so how can one derive the halakhot of one from the other? The Talmud records a mnemonic device for the following terms: Escapes, sword, forewarning.
עיר הנדחת להנך תרתי לא דמיא, שכן ממונן פלט. עבודה זרה להנך תרתי לא דמיא, שכן בסייף. עדים זוממין להנך תרתי לא דמיא, שכן צריכים התראה.
What are the differences? The case of an idolatrous city is not similar to those two, i.e., idol worship and conspiring witnesses, because for the others their money escapes their fate. Although the court executes those transgressors, their money is not confiscated. By contrast, in the case of an idolatrous city, not only are the residents executed, all of their property is destroyed. Idol worship is not similar to those two, as the other two transgressions are judged by the sword, while the punishment for idol worship is death by stoning. The case of conspiring witnesses is not similar to those two, as those who transgress the two other transgressions require forewarning in order to be liable for the transgression, while conspiring witnesses are not forewarned before they testify.