Daily Mishnah · Techie Talmid · On-Ramp

Mishnah Bekhorot 9:7-8

On-RampTechie TalmidJanuary 2, 2026

Ah, Mishnah Bekhorot 9:7-8! A truly elegant piece of code, this sugya. We're going to unpack it, not just as a list of rules, but as a complex system with inputs, processes, and outputs. Think of it as a legacy system that's been running for millennia, and we're about to reverse-engineer its core logic. Let's dive in!

Problem Statement – The "Bug Report" in the Sugya

Bug Report: Mishnah_Bekhorot_9_7_8_Tithing_Logic_Error

Severity: High. Affects the correct application of a crucial mitzvah.

Description: The Mishnah describes the process of separating animal tithes (ma'aser behemah). However, the logic governing when animals join together for tithing, and the precise mechanism of counting, seems to contain several potential failure points. Specifically:

  1. Conditional Aggregation Logic: The criteria for animals being considered "together" for tithing (distance, shared shepherd, etc.) appear to have some ambiguities, particularly with geographical dividers like rivers and intermediary groups of animals. This could lead to incorrect pooling or separation of herds, resulting in either under-tithing or over-tithing.
  2. Counting Protocol Ambiguities: The method of counting (passing under a rod, narrow opening, painting the tenth) has several defined exceptions and "after-the-fact" solutions. If these protocols are not followed precisely, the system can enter an error state where the tithe is invalidated or animals are incorrectly consecrated.
  3. State Management Failures: Scenarios where a counted animal rejoins the uncounted group, or a tithed animal rejoins the uncounted, cause a cascading failure, leading to the entire group becoming untithed. This suggests a lack of robust state tracking or a poorly defined "reset" mechanism.

Impact: Incorrectly applied tithes can lead to the consumption of unconsecrated animals as consecrated, or vice-versa, violating the sanctity of the tithe and potentially incurring spiritual penalties. The system needs a clear, deterministic flow for accurate execution.

Text Snapshot

Let's pull some key lines of code, with line numbers for precise referencing:

  • 9:7a: "The mitzva of animal tithe is in effect both in Eretz Yisrael and outside of Eretz Yisrael, in the presence of, i.e., in the time of, the Temple and not in the presence of the Temple. It is in effect with regard to non-sacred animals but not with regard to sacrificial animals."
  • 9:7b: "And it is in effect with regard to the herd and the flock, but they are not tithed from one for the other; and it is in effect with regard to sheep and goats, and they are tithed from one for the other."
  • 9:7c: "Animals subject to the obligation of animal tithe join together if the distance between them is no greater than the distance that a grazing animal can walk and still be tended by one shepherd. And how much is the distance that a grazing animal walks? It is sixteen mil. If the distance between these animals and those animals was thirty-two mil they do not join together."
  • 9:7d: "If he also had animals in the middle of that distance of thirty-two mil they bring all three flocks to a pen and tithes them in the middle."
  • 9:7e: "Rabbi Meir says: The Jordan River divides between animals on two sides of the river with regard to animal tithe, even if the distance between them is minimal."
  • 9:7f: "All cattle, sheep, and goats enter the pen to be tithed, except for an animal crossbred from diverse kinds... a tereifa; an animal born by caesarean section; one whose time has not yet arrived... and an orphan."
  • 9:7g: "In what manner does one tithe the animals? He gathers them in a pen and provides them with a small, i.e., narrow, opening, so that two animals will not be able to emerge together. And he counts them as they emerge: One, two, three, four, five, six, seven, eight, nine; and he paints the animal that emerges tenth with red paint and declares: This is tithe."
  • 9:7h: "But if he had one hundred animals and he took ten as tithe, or if he had ten animals and he simply took one as tithe, that is not tithe, as he did not count them one by one until reaching ten."
  • 9:7i: "Rabbi Yosei, son of Rabbi Yehuda, says: In that case too, it is tithe."
  • 9:7j: "If before the owner completed tithing his animals, one of those already counted jumped back into the pen among the animals that had not yet been counted, all those in the pen are exempt from being tithed..."
  • 9:7k: "If one of those animals that had been tithed, i.e., designated as the tenth, jumped back into the pen among the animals that had not yet been counted, creating uncertainty with regard to all the animals there which was the animal tithe, all the animals must graze until they become unfit for sacrifice, and each of them may be eaten in its blemished state by its owner..."
  • 9:8a: "If two animals emerged as one, one counts them as twos, i.e., as though they came out one after the other."
  • 9:8b: "If he mistakenly counted two of the animals at the beginning or in the middle of the ten as one, and then continued his count, the ninth and the tenth are flawed..."
  • 9:8c: "If he mistakenly called the ninth: Tenth, and the tenth: Ninth, and the eleventh: Tenth, the three of them are sacred..."

Flow Model – The Decision Tree

Let's map out the core logic of ma'aser behemah as a decision tree. Think of each node as a conditional check or an action.

  • START: Is animal subject to Ma'aser Behemah?

    • YES:
      • Is it in the time of the Temple? (9:7a)
        • YES:
          • Is it non-sacred? (9:7a)
            • YES:
              • Is it part of the same species group (e.g., sheep OR goats, NOT herd/flock mixed)? (9:7b)
                • YES:
                  • Determine Grouping for Tithing:
                    • Are animals within 16 mil distance and tended by one shepherd? (9:7c)
                      • YES: Treat as a single group. -> Process Tithing
                      • NO:
                        • Are there intermediary groups within 32 mil? (9:7d)
                          • YES: Group all via middle pen. -> Process Tithing
                          • NO: Treat as separate groups. -> Process Tithing (individually)
                    • Special Case (Rabbi Meir): Is there a geographical barrier like the Jordan River? (9:7e)
                      • YES: Treat as separate groups, regardless of distance. -> Process Tithing (individually)
                      • NO: (Follow standard distance/shepherd logic)
                • NO: (Herd/flock are not tithed from each other, so they are separate processing units.) -> Process Tithing (individually)
            • NO: (Sacrificial animals are not subject to this tithe.) -> END
        • NO: (Mitzvah not in effect outside Temple times.) -> END
      • NO: (Not an animal subject to this mitzvah.) -> END
  • PROCESS TITHING:

    • Gather animals into a pen. (9:7g)
    • Check for Exclusions: (9:7f)
      • Is it a hybrid (diverse kinds)? -> EXCLUDE
      • Is it a tereifa? -> EXCLUDE
      • Was it born by Caesarean section? -> EXCLUDE
      • Is it younger than 8 days old? -> EXCLUDE
      • Is it an orphan (mother died/slaughtered during birth)? -> EXCLUDE
      • If EXCLUDED, this animal is not tithed. -> END
    • If NOT EXCLUDED, proceed to Counting Protocol:
      • Create a narrow exit from the pen. (9:7g)
      • Count animals as they exit.
        • Initialize count = 0.
        • For each animal exiting:
          • Increment count.
          • If count is a multiple of 10:
            • Designate animal as Tithe. (e.g., paint red) (9:7g)
            • Reset count for next ten. (Implicit)
          • Else if count is NOT a multiple of 10:
            • This animal is regular.
      • Validation Checks (Post-Counting):
        • Scenario 1: Counting Errors (9:8b)
          • Mistake: Counted two animals as one during the sequence. -> Flawed Count: 9th and 10th are compromised.
        • Scenario 2: Incorrect Designation (9:8c)
          • Mistake: Called 9th '10th', 10th '9th', 11th '10th'. -> All three (9th, 10th, 11th) are consecrated. (With specific halakhic statuses)
        • Scenario 3: Rejoining Uncounted Animal (9:7j)
          • A counted animal jumps back into uncounted group. -> ALL animals in pen are EXEMPT. (System reset/failure)
        • Scenario 4: Rejoining Tithed Animal (9:7k)
          • A designated tithed animal jumps back into uncounted group. -> ALL animals must graze until blemished and eaten by owner. (System reset/failure)
        • Scenario 5: Double Counting/Simple Selection (9:7h, 9:7i)
          • Did not count one-by-one up to ten, e.g., took 10 from 100 or 1 from 10. -> NOT Tithe (Rabbi Yehuda: It IS tithe).

Two Implementations – Algorithm A vs. Algorithm B

Let's compare how a Rishon (early commentator) and an Acharon (later commentator) might represent the implementation of this tithing system, looking at their underlying algorithmic approaches.

Algorithm A: The Rambam's Procedural Approach (Rishon)

The Rambam, in his Mishneh Torah, often presents a highly structured, step-by-step procedural algorithm. His commentary on the Mishnah here (9:7:1) reflects this. He breaks down the process into clear, executable steps, focusing on the how-to.

Algorithm A: PerformMaaserBehemah (Animals)

  1. Input: Animals (list of eligible animals)
  2. State: CurrentTitheBatch = []
  3. State: GroupingLogic = DetermineGrouping(Animals) (This would internally call logic from 9:7b, 9:7c, 9:7d, 9:7e).
    • DetermineGrouping returns a list of TithingGroups.
  4. FOR EACH TithingGroup in GroupingLogic:
    • Input: CurrentGroup = TithingGroup
    • FilteredGroup = FilterExclusions(CurrentGroup) (Applies logic from 9:7f).
      • FilterExclusions removes hybrids, tereifot, etc.
    • IF FilteredGroup IS EMPTY THEN CONTINUE (No animals to tithe).
    • PenSetup(FilteredGroup) (Creates the narrow exit).
    • CountingProtocol(FilteredGroup)
      • Initialize count = 0
      • Output: DesignatedTitheAnimal = NULL
      • FOR EACH Animal in FilteredGroup (in order of exit):
        • count = count + 1
        • IF count % 10 == 0 THEN
          • Animal.MarkAsTithe()
          • DesignatedTitheAnimal = Animal
        • ELSE:
          • Animal.MarkAsRegular()
      • IF count < 10 AND count > 0 THEN (Handles cases where fewer than 10 animals are in the group. The Mishnah implies this might be handled by the next year, but the core logic is about the count. The Rambam's commentary on 9:7:1 mentions "what is left over remains for the next year," suggesting a batch processing approach.)
        • HandleIncompleteBatch(FilteredGroup, count)
    • PostCountValidation(FilteredGroup, DesignatedTitheAnimal)
      • Check for Rejoining Uncounted (9:7j): If AnimalRejoinedUncounted(FilteredGroup) is TRUE, then MarkGroupAsExempt(FilteredGroup).
      • Check for Rejoining Tithed (9:7k): If AnimalRejoinedTithed(FilteredGroup) is TRUE, then MarkGroupForGrazing(FilteredGroup).
      • Check for Counting Errors (9:8b): If CountingMistake9_8b(FilteredGroup) is TRUE, then FlagNinthTenthFlawed(FilteredGroup).
      • Check for Designation Errors (9:8c): If DesignationMistake9_8c(FilteredGroup) is TRUE, then MarkConsecratedAccordingToList(FilteredGroup).
      • Check for Simple Selection (9:7h): If SimpleSelectionMethod(FilteredGroup) is TRUE, then MarkAsInvalidTithe(FilteredGroup) (unless Rabbi Yosei's override).
  5. Output: ProcessedGroups (list of groups with tithe status applied)

The Rambam's approach is very imperative. It's about executing a sequence of commands, checking conditions at each step, and applying specific subroutines. The focus is on the procedure and its exceptions.

Algorithm B: The Tosafot's Analytical Approach (Acharon)

Tosafot, known for their deep analytical approach, often engage in dialectical reasoning, questioning assumptions and exploring the underlying principles. Their commentary on this sugya (e.g., on 9:7:2, 9:7:3, 9:7:5) reveals a more declarative and rule-based system, where they're trying to define the conditions under which a certain outcome occurs, often by synthesizing different verses or opinions.

Algorithm B: DefineMaaserBehemahStatus(Animal, Context)

  1. Input: Animal (single animal), Context (e.g., herd location, time, owner status)

  2. Output: AnimalStatus (e.g., Tithe, Regular, Exempt, Grazing, Invalid)

  3. Rule Set: MaaserBehemahRules (This is a collection of declarative rules, derived from the sugya and the commentaries).

    • Rule 1: Basic Applicability (9:7a)
      • IF Context.Time != TempleTime OR Context.Sacredness == Sacred THEN RETURN Exempt
    • Rule 2: Species Grouping (9:7b)
      • IF Animal.SpeciesGroup != Context.TargetSpeciesGroup THEN RETURN ExemptFromThisGroup
    • Rule 3: Group Formation Logic (9:7c, 9:7d, 9:7e)
      • Define MaxJoinDistance = 16_mil``
      • Define IntermediaryThreshold = 32_mil``
      • Define GeographicBarrier = JordanRiver (Rabbi Meir's override)
      • GroupedAnimals = DetermineGroupMembership(Animal, Context.AllAnimals, MaxJoinDistance, IntermediaryThreshold, GeographicBarrier)
      • IF Animal NOT IN GroupedAnimals THEN RETURN ExemptFromThisGroup
    • Rule 4: Individual Animal Exclusion (9:7f)
      • IF Animal.IsHybrid OR Animal.IsTereifa OR Animal.IsCaesarean OR Animal.IsTooYoung OR Animal.IsOrphan THEN RETURN Exempt
    • Rule 5: Tithing Protocol Application (9:7g, 9:7h)
      • Sub-Process: ApplyCountingProtocol(GroupedAnimals)`
        • IF SimpleSelectionMethod(GroupedAnimals) THEN RETURN InvalidTithe (Unless Rabbi Yosei's rule applies, which might infer a tithe, but still needs careful handling of the "counting" aspect).
        • Initialize TenthAnimal = NULL``
        • Initialize Count = 0``
        • FOR EACH AnimalInstance in OrderedExit(GroupedAnimals):
          • Count = Count + 1
          • IF Count % 10 == 0 THEN
            • IF AnimalInstance.Status == TitheDesignated THEN RETURN AnimalStatus.Tithe (This is where the system handles previous designations)
            • IF AnimalInstance.Status == Regular THEN
              • AnimalInstance.Status = TitheDesignated
              • TenthAnimal = AnimalInstance
              • RETURN AnimalStatus.Tithe
          • ELSE:
            • IF AnimalInstance.Status == TitheDesignated THEN RETURN AnimalStatus.Regular (This animal was already designated as tithe but is not the 10th of a new sequence)
            • AnimalInstance.Status = Regular
            • RETURN AnimalStatus.Regular
        • IF TenthAnimal IS NOT NULL THEN (This handles cases where the last animal is the 10th)
          • RETURN AnimalStatus.Tithe
        • IF Count < 10 AND Count > 0 THEN (Incomplete batch, likely handled by next year's aggregation, but the individual animal's status is still 'Regular' for now)
          • RETURN AnimalStatus.Regular
    • Rule 6: Post-Count State Corruption (9:7j, 9:7k)
      • IF AnimalInstance.Status == TitheDesignated AND AnimalInstance.RejoinedUncountedGroup THEN RETURN AnimalStatus.Exempt (This rule applies to the entire group).
      • IF AnimalInstance.Status == TitheDesignated AND AnimalInstance.RejoinedUncountedGroup THEN RETURN AnimalStatus.GrazingRequired (This rule applies to the entire group).
    • Rule 7: Counting Error Handling (9:8b, 9:8c)
      • IF CountingMistake9_8b(GroupedAnimals) THEN (This implies a re-evaluation of status for the 9th and 10th, making them "flawed"). The status becomes complex here.
      • IF DesignationMistake9_8c(GroupedAnimals) THEN (This implies a complex re-assignment of status for the 9th, 10th, and 11th).

The Tosafot's approach is more about defining the properties and relationships within the system. They're building a knowledge graph of halakhic rules. The "status" of an animal is determined by querying this rule set against its context.

Edge Cases – Inputs That Break Naïve Logic

Let's identify two tricky inputs that would stump a simple, linear processor.

Edge Case 1: The "Floating" Tenth

Input:

  • A group of 10 sheep are in a pen.
  • The owner begins the tithing process:
    • Animals 1-8 exit and are marked as "regular."
    • Animal #9 exits. The owner mistakenly calls it the "tenth."
    • Animal #10 exits. The owner mistakenly calls it the "ninth."
    • Animal #11 exits (from the same pen, implying a larger group was present or there was a mistake in the initial count). The owner calls this the "tenth."

Naïve Logic Output: The 10th animal is the tithe. The 11th is just another regular animal.

Expected Output (Based on Mishnah 9:8b-c): This is where the system gets extremely interesting and complex.

  • The 9th animal (which was called "tenth") is consecrated as tithe.
  • The 10th animal (which was called "ninth") is flawed and becomes a regular animal, potentially eaten in its blemished state if it develops a blemish.
  • The 11th animal (which was called "tenth") is consecrated as a peace offering (according to Rabbi Meir) and also renders a potential substitute animal consecrated as well.

Why it breaks naïve logic: A simple "count to ten and mark the tenth" algorithm fails because it doesn't account for the semantic error in naming. The Mishnah introduces a layer of meta-cognition to the counting process, where the label applied to an animal during counting has independent halakhic consequences, even if the sequence is disrupted. The system must parse the intent and label alongside the physical sequence.

Edge Case 2: The "Unseen" Intermediary

Input:

  • A shepherd has two groups of sheep.
  • Group A is at location X, and Group B is at location Z.
  • The distance between X and Z is 30 mil.
  • Crucially, the shepherd also has a third, smaller group of sheep (Group C) located exactly in the middle of the 30 mil distance, at location Y (15 mil from X, 15 mil from Z).
  • All three groups are of the same species (sheep).

Naïve Logic Output:

  • The distance between Group A and Group B is 30 mil. Since this exceeds the 16 mil "joining" distance, and there's no mention of a shared shepherd for A and B directly, they would be treated as separate tithe batches. The presence of Group C is irrelevant.

Expected Output (Based on Mishnah 9:7d):

  • The presence of Group C in the middle, within the 32 mil radius, means that all three groups (A, B, and C) are unified into a single tithe batch.
  • The owner must bring all three flocks to a single pen, and tithe them together in the middle (location Y, or any designated central point).

Why it breaks naïve logic: A simple distance-based IF distance > 16 THEN separate rule is insufficient. The logic needs to incorporate a "connected components" or graph-traversal element. The intermediary group acts as a bridge, altering the connectivity of the entire system, even if the direct connection between the outer two groups is too large. The system must understand that proximity isn't just pairwise; it's about the reachability and connectivity of the entire set of animals through intermediary points.

Refactor – One Minimal Change That Clarifies the Rule

The most significant point of potential confusion and error in the current "code" of the sugya relates to the conditions under which tithe batches fail or become exempt due to errors in the counting process. The cases of animals rejoining the pen (9:7j, 9:7k) and counting mistakes (9:8b, 9:8c) introduce non-determinism and complex state management.

The Refactor: Introduce a clear "Transaction Rollback" mechanism for tithing.

Minimal Change:

Modify the core tithing loop (9:7g) to include explicit state checks and rollback conditions before designating any animal as tithe.

Proposed Refactored Rule:

"In what manner does one tithe the animals? He gathers them in a pen and provides them with a small, i.e., narrow, opening. He counts them as they emerge: One, two, three... up to nine. Before designating the tenth:

  • Check for State Corruption:
    • IF any animal previously counted (1-9) has rejoined the uncounted group:
      • ROLLBACK TRANSACTION: All animals in the pen are exempt.
      • EXIT TITHING PROCESS.
    • IF the animal *about to be designated* as the tenth has rejoined the uncounted group:
      • ROLLBACK TRANSACTION: All animals in the pen must graze until blemished.
      • EXIT TITHING PROCESS.
  • Perform Designation:
    • If no corruption detected:
      • He paints the animal that emerges tenth with red paint and declares: This is tithe.

Impact: This refactor explicitly prioritizes the integrity of the counting state before committing to a tithe designation. It transforms the post-hoc error handling into a proactive validation step. This makes the system more robust by preventing the "commit" of a tithe designation if the underlying state is compromised, mirroring how databases handle transactions. It clarifies that the entire batch is invalidated if the integrity of the count is broken at critical junctures. The complexities of 9:8b and 9:8c would then be handled as separate, subsequent validation rules applied only to the successfully designated batch, rather than as conditions that prevent designation altogether.

Takeaway

This sugya is a masterclass in designing a robust, albeit complex, data processing pipeline. The mitzvah of ma'aser behemah is not just about a simple division; it's a sophisticated algorithm that considers:

  • Global Context: Time (Temple era), Location (Eretz Yisrael vs. Diaspora).
  • Data Preprocessing: Filtering out non-eligible animal types (sacrificial, hybrids, etc.).
  • Data Aggregation: Complex rules for grouping animals based on physical proximity, shared management, and even geographical features.
  • Core Processing: A precise counting and designation mechanism.
  • Error Handling & State Management: Sophisticated rollback and recovery procedures for various failure modes in the counting process, leading to total batch invalidation or modified outcomes.

By viewing this sugya through a systems thinking lens, we see that the halakha isn't just a set of static rules, but a dynamic system designed to maintain integrity and purity. The Rishonim and Acharonim, in their commentaries, are essentially debugging, refactoring, and optimizing this ancient code, ensuring its accurate execution across countless generations. It's a beautiful example of how logic, precision, and layered complexity are woven into the fabric of Torah.