Chullin, Chapter 4, Mishnah 1. This chapter turns to the status of a fetus found inside a slaughtered animal, and it opens with a case in which part of that fetus had already made its way out of the womb before the mother was slaughtered.
The starting point is a halachah we already know. A pregnant animal that receives a valid shechitah brings its fetus along with it. The ubar, the unborn young, needs no shechitah of its own. Since at that moment it is regarded as a limb of its mother, her shechitah renders it kosher and fit to eat with no further act performed on it at all.
Our mishnah asks what happens when that unity is disturbed: the fetus stuck out a limb, or its head, or a piece of it was cut away while it was still inside.
The limb that came out and went back in
"Behemah hamakshah leiled," an animal that was having a hard, drawn out labor, "vehotziah ha'ubar et yado vehechezirah," and the fetus extended its foreleg outside the womb and then drew it back in, and afterward the mother was slaughtered: "mutar ba'achilah," the fetus may be eaten.
Even though a limb had already emerged before the shechitah, the fetus itself is still classified as unborn, still counted as part of its mother, and therefore the mother's shechitah takes effect on it.
The protruding foreleg, by contrast, may not be eaten, and the fact that it was drawn back in before the knife touched the mother changes nothing. Chazal derive this from the Torah's words "uvasar basadeh", and flesh in the field, "tereifah lo tocheilu", torn, you shall not eat. In its plain sense the verse addresses a beast savaged by a predator out in the open, a beast that has become a tereifah. Read more closely, the reference to the field points to flesh that has crossed outside the boundary meant to contain it. For a fetus that boundary is the mother's womb, and the leg crossed it.
Once the limb has gone out, its return cannot restore it. It carries the status of a tereifah, and a tereifah has no remedy; once it is torn it can never be made permitted again. So too here. The mother's shechitah can no longer reach that limb, even though it lies back inside her at the moment of slaughter. Once it left, it left for good.
Had the fetus emerged fully, it would be able to receive a shechitah of its own, and then all would be well. What can never happen is for the mother's shechitah to permit a part that has already left her body.
The head that came out
"Hotzi et rosho", should the fetus push its head out of the womb, then "af al pi shehechziro", even if it pulled that head back inside, "harei zeh keyalud", halachah treats it exactly as a newborn. The appearance of the head is itself the moment of birth, and from then on the fetus no longer counts as a portion of its mother.
The consequence is that the entire fetus, including all the parts that never left the womb, is not permitted by the mother's shechitah. It is now viewed as an independent animal. If it is later found dead inside her, it is a neveilah. If it emerges alive, one may perform shechitah on it and then it may be eaten.
Cutting a piece from inside
"Chotech me'ubar shebeme'eha," if a person reaches inside the mother and severs a piece from the fetus in her womb, leaving the severed piece inside her, and then she is slaughtered: "mutar ba'achilah," that piece becomes permitted through the mother's shechitah. It never left her body, and the fetus is not her own flesh but a separate entity resting within her.
"Min hatechol umin haklayot," but if he cut away part of the mother's own spleen or her kidneys and left those pieces lying inside her, "asur ba'achilah," they are forbidden, even though they were inside her when the shechitah was performed.
Zeh haklal
"Zeh haklal", and here the mishnah supplies the governing principle. "Kol davar shehu gufah", anything belonging to her own body, the kidney of the previous case being the example, stays prohibited once it has been detached, and the slaughter will not help it. "She'eino gufah, mutar": an item lodged within her that is not her own body, such as the fetus, is rendered permitted by her shechitah.
This is learned from the words "babehemah otah tocheilu". The verse teaches that whatever is contained within a properly slaughtered beast is included in the permission that the slaughter creates. Note, though, the added word "otah", her, meaning the animal as she stands complete. "Babehemah" therefore describes something housed inside a beast whose body remains whole, something whose presence within her subtracts nothing from her. A piece severed from her own flesh does diminish her, and about such a piece the phrase "babehemah otah" cannot be said, so it stays forbidden.
The upshot: only that which is separate from the animal yet situated inside her becomes permitted through her shechitah.