Bechorot 20 - Did This Animal Have Its Firstborn Yet?

If one buys an animal from an idolater and does not know whether she had already borne her first offspring, then Rabbi Ishmael says that the guidelines are as follows: if the animal is a goat and it produces a male offspring within her first year, that animal definitely belongs to the kohen. A goat is capable of kidding once it her first year, but not twice, as she will in the following years. Thus, a kid in her first year is the firstborn. After that, since we don't know if it had offspring while in the possession of the idolater, it is a firstborn out of doubt, that is, it is let to graze until it develops a blemish, and is then consumed by the owner. For an ewe the period is two years, and for a cow - three.

Rabbi Akiva said to Rabbi Ishmael, "If the law was that only actual birth exempts from the law of firstborn, it would be indeed as you say. But since even a miscarriage also exempts from it, it is never a definite firstborn, unless we know for sure."

Art: Edward Atkinson Hornel - The Little Goat Herd