Halakhah Yomit · Techie Talmid · On-Ramp

Shulchan Arukh, Orach Chayim 113:4-6

On-RampTechie TalmidNovember 30, 2025

Problem Statement: The Bowing Bug Report

Bug ID: OC-113-4-5-6-bowing-logic-error

Severity: High (Incorrect execution of core ritualistic movements can lead to unintended spiritual or halachic outcomes.)

Component: Shulchan Arukh, Orach Chayim, Simanim 113:4-6 (Laws of Bowing in the Amidah)

Observed Behavior: The text describes specific instances and methods for bowing during the Amidah prayer. However, the underlying logic governing when and how to bow appears inconsistent across different blessings and situations, leading to potential confusion for the user (the praying individual). Specifically, the interplay between obligatory bows, optional bows, and prohibitions against adding bows creates a complex state machine that is difficult to implement correctly without a clear understanding of the state transitions and conditional logic. The description of the manner of bowing (depth, speed, straightening) further complicates the execution.

Expected Behavior: A clear, deterministic algorithm for bowing during the Amidah, based on the blessings being recited, the specific words being uttered, and external factors. The algorithm should also define the precise physical execution of the bow and straightening.

Environment: Tefillah (Amidah prayer), Hallel, Birkat Hamazon, Rosh Hashanah, Yom Kippur.

Impact: Misapplication of bowing rules could lead to an incomplete or improperly performed prayer, potentially missing the intended spiritual significance or violating halachic norms. The varied customs and opinions (as hinted by the gloss) suggest a need for a robust, unified processing model.

Text Snapshot

Here are the key lines from the Shulchan Arukh that define the bowing logic:

  • 113:4: "These are the blessings in which we bow: in Avot [the first blessing], [at the] beginning and end; in Hoda-a [the second-to-last blessing], [at the] beginning and end."
  • 113:4: "And if one comes to bow at the end of every blessing or at its beginning, we teach [that person] that one does not bow, but in their [i.e. the blessings'] middles, one may bow."
  • 113:4: "Those who have the custom to bow on Rosh Hashana and Yom Kippur when they say "Zokhreinu" ("Remember us") and "Mi Kamokha" ("Who is like You") [the insertions into the first blessing of the Amidah] need to straighten [themselves] up when they reach the end of the blessing. Gloss: And even though in [the blessing of] "Avot", one bows at the end of the blessing, nevertheless, one needs to straighten a little at the end of "Zokhreinu" so that it should be apparent that one is going back and bowing [again] because of the obligation [to bow at the end of the blessing of "Avot"] (His own opinion based on the Tur)"
  • 113:4: "One who bows [when saying] "U'vechol Koma Lefanecha Tishtachaveh" ["and every upright one shall prostrate oneself before You"] or "U'lecha Anachnu Modim" ["and to You [alone] we give thanks"] [both from the "Nishmat Kol Chai" prayer], or [when saying] "Hoda'a" [Thanksgiving] in Hallel or Birkat Hamazon [The Blessings after a Meal], behold this is improper (meaning that one doesn't bow other than in a place that the Sages established)."
  • 113:4: "One who is praying needs to bend until all the vertebrae in one's spine stick out. One should not bow from one's hips with one's head remaining straight, rather one should also bow one's head like a reed. One should not bow so much that one's mouth would be opposite the belt of one's pants."
  • 113:5: "If one is old or sick and cannot bow until [all the vertebrae in one's spine] stick out, since one bends (i.e. lowers) one's head, it is sufficient since it can be recognized that one wished to bow, but rather that [the lack of bowing] is on account of one's pain."
  • 113:6: "When one bows, one should bow quickly and all at once. When one straightens up, one straightens gently, [with] one's head [up] first and then afterwards, one's body, so that it not be burdensome for oneself. When one bows, one bows at [the word] "barukh" and when one straightens up, one straightens at the [Divine] Name."
  • 113:6: "One who is praying, and an idol worshiper came in front of one with a [cross] in hand and [the person praying] arrived at the point at which where one bows, one should not bow, even though one's heart is [directed] toward heaven [i.e worshiping only God]."

Flow Model: The Amidah Bowing State Machine

This sugya can be modeled as a conditional state machine, where the "state" is the current point in the prayer and the "transitions" are triggered by specific words or blessings, dictating whether a bow action is required, permitted, or prohibited.

  • START_PRAYER:

    • IF CurrentBlessing == Avot THEN State = Avot_Phase
    • ELSE IF CurrentBlessing == Hoda'a THEN State = Hoda'a_Phase
    • ELSE State = General_Prayer
  • Avot_Phase:

    • IF Word == "Baruch" THEN Action = Bow_Start
    • ELSE IF Word == "Zochreinu" THEN Action = Process_Zochreinu_Insertion
      • IF Custom_Rosh_YomKippur == TRUE THEN Action = Bow_Zochreinu_Start
    • ELSE IF Word == "Mi_Kamochah" THEN Action = Process_MiKamochah_Insertion
      • IF Custom_Rosh_YomKippur == TRUE THEN Action = Bow_MiKamochah_Start
    • ELSE IF Word == "Elokei_Avot" THEN Action = Process_End_Avot
      • IF Custom_Rosh_YomKippur == TRUE THEN Action = Straighten_Zochreinu_MiKamochah
      • THEN Action = Bow_Avot_End
    • ELSE Action = No_Action
  • Hoda'a_Phase:

    • IF Word == "Baruch" THEN Action = Bow_Start
    • ELSE IF Word == "Modim_Anachnu_Lach" THEN Action = Process_End_Hoda'a
      • THEN Action = Bow_Hoda'a_End
    • ELSE Action = No_Action
  • General_Prayer:

    • IF CurrentBlessing is one of the 18 blessings AND Word == "Baruch" THEN Action = Bow_Start
    • ELSE IF CurrentBlessing is one of the 18 blessings AND Word is at the end of the blessing THEN Action = Bow_End
    • ELSE IF Word == "U'vechol_Koma_Lefanecha_Tishtachaveh" THEN Action = Prohibited_Bow (External call)
    • ELSE IF Word == "U'lecha_Anachnu_Modim" THEN Action = Prohibited_Bow (External call)
    • ELSE IF CurrentBlessing is Hallel or Birkat Hamazon AND Word == "Hoda'a" THEN Action = Prohibited_Bow (External call)
    • ELSE Action = No_Action
  • Action_Execution:

    • Bow_Start: Execute_Bow(Depth = Full)
    • Bow_End: Execute_Bow(Depth = Full)
    • Bow_Zochreinu_Start: Execute_Bow(Depth = Full)
    • Bow_MiKamochah_Start: Execute_Bow(Depth = Full)
    • Straighten_Zochreinu_MiKamochah: Execute_Straighten(Speed = Gentle, Order = Head_First)
    • Bow_Avot_End: Execute_Bow(Depth = Full)
    • Bow_Hoda'a_End: Execute_Bow(Depth = Full)
    • Prohibited_Bow: Log_Error("Attempted prohibited bow")
    • Execute_Bow(Depth):
      • IF Depth == Full THEN
        • IF User_Condition == Old_or_Sick THEN Bow_Manner = Head_Bend_Only
        • ELSE Bow_Manner = Full_Spine_Bend
        • Execute_Physical_Bow(Manner)
      • ELSE Log_Error("Invalid Bow Depth")
    • Execute_Straighten(Speed, Order):
      • Execute_Physical_Straighten(Speed, Order)
  • Physical_Bow_Execution_Parameters:

    • Depth: Until vertebrae "stick out" (קשרים של החוליות בולטין).
    • Head: Bow head like a reed, not straight.
    • Limit: Mouth should not be opposite the belt.
    • Speed: Quick and all at once.
    • Timing: Bow at "Baruch".
  • Physical_Straighten_Execution_Parameters:

    • Speed: Gently.
    • Order: Head first, then body.
    • Timing: Straighten at the Divine Name.
  • Edge_Case_Handler:

    • IF Idol_Worshiper_Present == TRUE AND Current_Bow_Point == TRUE THEN Action = Skip_Bow

Two Implementations: Rishon vs. Acharon as Algorithm A vs. B

Let's analyze two distinct approaches to implementing this bowing logic, drawing inspiration from the Rishonim (early commentators) and Acharonim (later commentators).

Algorithm A: The Rishonim's Procedural Approach (Based on Tur/Rambam)

This algorithm prioritizes a step-by-step, rule-based execution, closely mirroring the explicit instructions found in earlier commentaries like the Tur and Rambam. It's like a procedural macro that executes a sequence of commands based on predefined conditions.

Core Logic:

  1. Initialization: Set bowing_required = FALSE, bowing_permitted = FALSE, bowing_prohibited = FALSE.

  2. Blessing Identification:

    • IF CurrentBlessing == Avot OR CurrentBlessing == Hoda'a THEN
      • bowing_permitted = TRUE
      • bowing_required = TRUE (at beginning/end of these specific blessings)
    • ELSE IF CurrentBlessing is one of the 18 blessings THEN
      • bowing_permitted = TRUE (general allowance within these blessings)
    • ELSE IF CurrentBlessing is Hallel or Birkat Hamazon AND CurrentWord == "Hoda'a" THEN
      • bowing_prohibited = TRUE
    • ELSE
      • bowing_permitted = FALSE
      • bowing_required = FALSE
  3. Word-Specific Checks:

    • IF CurrentWord == "U'vechol_Koma_Lefanecha_Tishtachaveh" OR CurrentWord == "U'lecha_Anachnu_Modim" THEN
      • bowing_prohibited = TRUE
    • IF CurrentWord == "Baruch" THEN
      • bowing_required = TRUE (for start of bowing sequence)
    • IF CurrentWord is at the end of a blessing AND bowing_permitted == TRUE AND CurrentBlessing != Avot AND CurrentBlessing != Hoda'a THEN
      • bowing_required = TRUE (for end of bowing sequence, with exceptions)
  4. Customization & Edge Cases (Rosh Hashanah/Yom Kippur):

    • IF CurrentBlessing == Avot AND CurrentWord == "Zokhreinu" OR CurrentWord == "Mi_Kamochah" AND Is_Rosh_Hashanah_or_Yom_Kippur == TRUE THEN
      • bowing_required = TRUE (for these insertions)
      • NOTE: The gloss suggests a subtle straighten_then_re_bow logic here, which is a procedural override.
  5. Idol Worshiper Check:

    • IF Idol_Worshiper_Present == TRUE AND bowing_required == TRUE THEN
      • bowing_prohibited = TRUE (override)
  6. Execution:

    • IF bowing_required == TRUE AND bowing_prohibited == FALSE THEN
      • Execute_Bow_Sequence()
    • ELSE IF bowing_prohibited == TRUE THEN
      • Log_Error("Attempted prohibited bow.")
    • ELSE
      • Do_Nothing()
  7. Execute_Bow_Sequence() Function:

    • IF CurrentWord == "Baruch" THEN
      • Perform_Bow(Quick, All_At_Once, Full_Depth, Reed_Head)
      • IF CurrentBlessing == Avot AND CurrentWord == "Elokei_Avot" OR CurrentBlessing == Hoda'a AND CurrentWord == "Modim_Anachnu_Lach" THEN
        • Perform_Straighten(Gentle, Head_First, Body_Last)
        • Perform_Bow(Quick, All_At_Once, Full_Depth, Reed_Head) // This is the end-of-blessing bow
        • IF CurrentBlessing == Avot AND Is_Rosh_Hashanah_or_Yom_Kippur == TRUE AND (CurrentWord == "Zokhreinu" or CurrentWord == "Mi_Kamochah") THEN
          • Perform_Straighten(Gentle, Head_First, Body_Last) // Straighten after the insertion bow
          • Perform_Bow(Quick, All_At_Once, Full_Depth, Reed_Head) // Re-bow for the end of Avot
    • ELSE IF CurrentBlessing == Avot AND CurrentWord == "Zokhreinu" OR CurrentWord == "Mi_Kamochah" AND Is_Rosh_Hashanah_or_Yom_Kippur == TRUE THEN
      • Perform_Bow(Quick, All_At_Once, Full_Depth, Reed_Head)
      • IF CurrentWord is at the end of the blessing (e.g., "Elokei Avot") THEN
        • Perform_Straighten(Gentle, Head_First, Body_Last)
        • Perform_Bow(Quick, All_At_Once, Full_Depth, Reed_Head) // This is the end-of-blessing bow
  8. Perform_Bow(...) Function:

    • Handles the physical execution based on Full_Depth, Reed_Head, Quick, All_At_Once.
    • Includes checks for Old_or_Sick user condition (using Head_Bend_Only).
    • Enforces the mouth-belt limit.
  9. Perform_Straighten(...) Function:

    • Handles the physical execution based on Gentle, Head_First, Body_Last.

Strengths: Directly translates the textual commands into actions. Easy to follow the explicit rules.

Weaknesses: Becomes very verbose due to nested conditionals and repeated logic for similar actions. The gloss's nuance about straightening and re-bowing on Rosh Hashanah/Yom Kippur is hard to integrate cleanly without procedural overrides, making it feel like a patch. The "don't bow in the middle" rule is handled implicitly by only requiring bows at specific points.


Algorithm B: The Acharonim's State-Driven, Data-Centric Approach (Inspired by Mishnah Berurah/Kaf HaChayim)

This approach views the bowing process as a dynamic system with distinct states and transitions, driven by events (words, blessings). It's more like a finite state machine (FSM) where the current state determines the valid actions and the next state. Later commentators often refine and clarify the underlying logic, creating a more robust and predictable system.

Core Logic:

  1. State Definitions:

    • STATE_IDLE: No bowing action relevant.
    • STATE_INIT_BOW_AVOT: Initiating bow for the start of Avot.
    • STATE_BOWING_AVOT: Currently bowing at the start of Avot.
    • STATE_INSERTION_AVOT_RH_YK: Handling RH/YK insertions in Avot.
    • STATE_BOWING_INSERTION_RH_YK: Currently bowing for RH/YK insertions.
    • STATE_STRAIGHTEN_INSERTION_RH_YK: Straightening after RH/YK insertion bow.
    • STATE_END_BOW_AVOT: Initiating bow for the end of Avot.
    • STATE_BOWING_AVOT_END: Currently bowing at the end of Avot.
    • STATE_INIT_BOW_HODA_A: Initiating bow for the start of Hoda'a.
    • STATE_BOWING_HODA_A: Currently bowing at the start of Hoda'a.
    • STATE_END_BOW_HODA_A: Initiating bow for the end of Hoda'a.
    • STATE_BOWING_HODA_A_END: Currently bowing at the end of Hoda'a.
    • STATE_GENERAL_BOW_PERMITTED: General bowing is allowed within certain blessings.
    • STATE_PROHIBITED_ACTION: An action is explicitly forbidden.
  2. Event Definitions:

    • EVENT_ENTER_BLESSING(BlessingName)
    • EVENT_RECEIVE_WORD(Word)
    • EVENT_USER_CONDITION(Condition) (e.g., OLD_OR_SICK)
    • EVENT_EXTERNAL_FACTOR(Factor) (e.g., IDOL_WORSHIPPER_PRESENT)
  3. Transition Table (Simplified):

    | Current State | Event | Next State | Action

Shulchan Arukh, Orach Chayim 113:4-6 — Halakhah Yomit (Techie Talmid voice) | Derekh Learning