Avodah Zarah 63 - Learning Shemittah Laws from Harlot's Payment
They asked Rabbi Yochanan if this was done correctly, and he proved that it was, based on the laws regarding a harlot's payment. The rule is that if one gave the harlot an animal in payment and afterward cohabited with her, or if he cohabited with her, and afterward gave her an animal in payment, her payment is permitted, and she can bring it on the Altar. Why? Because at the time she acquires the animal, the cohabitation is no longer extant - and the case of shemittah produce is the same.
Art: Peasant Woman with a Goat by Camille Pissarro
