וְהֻֽגַּד־לְךָ֖ וְשָׁמָ֑עְתָּ וְדָרַשְׁתָּ֣ הֵיטֵ֔ב וְהִנֵּ֤ה אֱמֶת֙ נָכ֣וֹן הַדָּבָ֔ר נֶעֶשְׂתָ֛ה הַתּוֹעֵבָ֥ה הַזֹּ֖את בְּיִשְׂרָאֵֽל׃
and you have been informed or have learned of it, then you shall make a thorough inquiry. If it is true, the fact is established, that abhorrent thing was perpetrated in Israel,
Torah Temimah points to Sifrei Devarim.
בישראל. אין לי אלא בישראל, גרים ועבדים מניין, ת״ל (פ׳ ה׳) והוצאת את האיש ההוא או את האשה ההוא אשר עשו את הדבר הרע הזה.
English: “In Israel.” I know only concerning an Israelite; from where [do I know that the law applies] to converts and slaves? From the verse (in the next verse) “you shall take out that man or that woman who did this evil thing.”
The phrase “in Israel” might have been read as excluding non-Israelites; the wording of the following verse is used to include converts and slaves among those liable for idolatry.
Derash on the verse (Sifrei) — not a formal named middah of the 13. The seemingly superfluous language of the next verse is taken as an inclusion of converts and slaves.
The death penalty for idolatry applies not only to born Israelites but also to converts and slaves who commit the same act.