Skip to content
advanced

Deriving Semi-Markov Bellman Equations for Options

An option that runs for five steps collects five rewards. The primitive Bellman backup discounts one. That single mismatch is the whole reason the…

Published 2026-10-02Updated 2026-10-0411 min read
Elegant black and white image of crystal chess pieces arranged on a board, showcasing clarity and sophistication.
Elegant black and white image of crystal chess pieces arranged on a board, showcasing clarity and sophistication. Photo by Ömer Gülen on Pexels.

An option that runs for five steps collects five rewards. The primitive Bellman backup discounts one. That single mismatch is the whole reason the semi-Markov backup exists.

If you already know what options are and how the one-step Bellman backup is derived, the next question is mechanical: what changes when the decision unit is a policy that runs for a random number of steps? The answer is not a cosmetic tweak. The reward term becomes an accumulated sum, the continuation discount becomes a random exponent, and the model becomes a joint distribution over next state and transit time. Let's derive each piece.

Why the One-Step Backup Breaks for Options

The primitive backup for a policy π is:

Vπ(s)=∑aπ(a∣s)[r(s,a)+γ∑s′p(s′∣s,a) Vπ(s′)]V^\pi(s) = \sum_a \pi(a \mid s) \left[ r(s,a) + \gamma \sum_{s'} p(s' \mid s,a)\, V^\pi(s') \right]

Read it as: expected immediate reward plus the discounted value of the successor state. Two assumptions are baked in. The transition consumes exactly one time step. The reward is a single scalar, not a sum over a trajectory.

Both assumptions fail the moment you substitute an option o=⟨I,πo,β⟩o = \langle \mathcal{I}, \pi_o, \beta \rangle for a primitive action. Suppose the option's internal policy runs for kk steps before its termination condition β\beta fires. It collects rewards rt+1,rt+2,…,rt+kr_{t+1}, r_{t+2}, \dots, r_{t+k}. The naive substitution credits one reward and applies γ\gamma once. You undercount the reward stream and you undercount the elapsed time. The discount on the continuation term should be γk\gamma^k, not γ\gamma, and kk is a random variable.

The repair is to describe the option's outcome with a joint distribution over three things: the terminal state s′s', the accumulated discounted reward rr collected along the way, and the duration kk. Once that distribution exists, the backup can be written cleanly.

Knowledge check

Check your understanding

Answer this question before you continue.

An option runs for exactly three time steps before terminating. Which correction is needed to the primitive one-step backup's continuation term?
Misconception Check

Focus: Explain why substituting an option into a primitive one-step backup misdiscounts continuation when the option lasts multiple steps.

Notation and Assumptions

Before the derivation, pin down every symbol.

An option is a triple o=⟨I,πo,β⟩o = \langle \mathcal{I}, \pi_o, \beta \rangle: an initiation set I⊆S\mathcal{I} \subseteq \mathcal{S}, an internal policy πo\pi_o, and a termination condition β\beta. The internal policy is what generates the intermediate rewards — it is not a single action but a distribution over actions at each internal step.

When option oo is initiated in state ss, three random variables describe its outcome:

  • s′s' — the state in which the option terminates
  • rr — the cumulative discounted reward collected during execution, r=∑j=1kγj−1rt+jr = \sum_{j=1}^{k} \gamma^{j-1} r_{t+j}
  • kk — the number of time steps between initiation and termination

The option model is the joint distribution over next state and transit time, p(s′,k∣s,o)p(s', k \mid s, o). From it, define the discounted transition probability:

pss′o=∑k=1∞γk p(s′,k∣s,o)=E ⁣[γk1{st+k=s′}∣E(o,s)]p^o_{ss'} = \sum_{k=1}^{\infty} \gamma^k \, p(s', k \mid s, o) = \mathbb{E}\!\left[\gamma^k \mathbb{1}\{s_{t+k} = s'\} \mid \mathcal{E}(o,s)\right]

This folds the discount into the state prediction so the backup can be written as a single sum. The expected cumulative reward is rso=E[r∣E(o,s)]r^o_s = \mathbb{E}[r \mid \mathcal{E}(o,s)], where E(o,s)\mathcal{E}(o,s) denotes the event of initiating oo in ss.

Three assumptions make this valid. Time is discrete. The option's policy and termination condition are stationary. And the semi-Markov property holds: the outcome depends only on the initiating state and the option, not on the history before initiation.

Warning: History-dependent termination conditions — timeouts, or β\beta that depends on the trajectory so far — break the state-only form. You then need a history-indexed value function Qμ(h,o)Q^\mu(h, o), and the compact backup below no longer applies.

Knowledge check

Check your understanding

Answer this question before you continue.

An option lasts two steps and produces rewards x on the first step and y on the second. Using the article's definition, what is its cumulative discounted reward r?
Single Choice

Focus: Compute the cumulative discounted reward collected during a two-step option.

Deriving the Option Value Backup

Start from the return, conditioned on initiating oo in ss:

Qμ(s,o)=E ⁣[rt+1+γrt+2+⋯+γk−1rt+k+γkVμ(st+k)  |  E(o,s)]Q^\mu(s, o) = \mathbb{E}\!\left[ r_{t+1} + \gamma r_{t+2} + \cdots + \gamma^{k-1} r_{t+k} + \gamma^k V^\mu(s_{t+k}) \;\middle|\; \mathcal{E}(o,s) \right]

The first kk terms are the within-option reward stream. The last term is the continuation. Notice that kk appears in the exponent of the continuation discount and as the upper limit of the reward sum — it is a random variable living inside the expectation.

Group the reward stream into rr and apply the tower property by conditioning on the option's outcome (s′,k)(s', k):

Qμ(s,o)=E ⁣[r+γkVμ(s′)  |  E(o,s)]Q^\mu(s, o) = \mathbb{E}\!\left[ r + \gamma^k V^\mu(s') \;\middle|\; \mathcal{E}(o,s) \right]

Now substitute the definition of Vμ(s′)V^\mu(s') — the value of the state under the policy over options μ\mu:

Vμ(s′)=∑o′∈Os′μ(s′,o′) Qμ(s′,o′)V^\mu(s') = \sum_{o' \in \mathcal{O}_{s'}} \mu(s', o')\, Q^\mu(s', o')

This closes the recursion. Expanding the expectation over the joint distribution gives the summed form:

Qμ(s,o)=rso+∑s′pss′o∑o′∈Os′μ(s′,o′) Qμ(s′,o′)Q^\mu(s, o) = r^o_s + \sum_{s'} p^o_{ss'} \sum_{o' \in \mathcal{O}_{s'}} \mu(s', o')\, Q^\mu(s', o')

And the state-value backup follows by marginalizing over the option choice:

Vμ(s)=∑o∈Osμ(s,o)[rso+∑s′pss′o Vμ(s′)]V^\mu(s) = \sum_{o \in \mathcal{O}_s} \mu(s, o) \left[ r^o_s + \sum_{s'} p^o_{ss'}\, V^\mu(s') \right]

The action-value version comes from the same route, replacing Vμ(s′)V^\mu(s') with the max over options for the optimality variant. One identity is worth keeping: Qμ(s,o)=Voμ(s)Q^\mu(s, o) = V^{o\mu}(s) — the option value at a state equals the state value under the flat policy that the option induces. That identity is what lets you move between the two views without re-deriving anything.

Where the Discount Exponent Comes From

The continuation term carries γk\gamma^k, and kk is random. That means the effective discount applied to the successor value is E[γk]\mathbb{E}[\gamma^k], not γ\gamma. Since 0<γ<10 < \gamma < 1, E[γk]<γ\mathbb{E}[\gamma^k] < \gamma whenever the option can last more than one step. The gap widens as the option's expected duration grows.

This is a real effect, but it is narrower than it first looks. The duration discount lowers the continuation contribution — the discounted value of whatever state the option hands off to. It does not by itself make a longer option worse overall. A longer option also accumulates more within-option reward, and it may terminate in a better state. Those two effects can easily outweigh the extra discounting and reverse the ranking.

So the honest statement is conditional: hold the terminal-state distribution and the continuation values fixed, and a longer duration lowers the continuation term. Change the rewards or the terminal states and the comparison can flip. If you want to see this, take the worked example below and raise the slow outcome's cumulative reward from 1.5 to 2.5. The slow option now wins despite paying γ2\gamma^2 instead of γ1\gamma^1.

The discounted transition probability pss′op^o_{ss'} is exactly this discount folded into the state prediction. That is why the compact backup has no visible γ\gamma in the continuation term: the discount has been absorbed into the model. When you estimate pss′op^o_{ss'} from data, you are estimating a quantity that already contains the duration-weighted discount, which is why duration estimation error propagates directly into the value.

Knowledge check

Check your understanding

Answer this question before you continue.

Two outcomes lead to the same successor state and continuation value: duration 1 occurs with probability 0.5 and duration 2 with probability 0.5. For 0 < γ < 1, what discount factor multiplies that fixed continuation value in expectation?
Scenario Interpretation

Focus: Interpret how random option duration affects the expected continuation discount when successor values are held fixed.

Worked Example: A Two-Step Option Backup

From state A, option o branches to B with probability 0.6, duration 1, reward 1.0, and continuation factor γ; or to C with probability 0.4, duration 2, reward 1.5, and continuation factor γ². With successor values 2 and 3, the weighted contributions plus expected reward produce Q(A,o) = 3.252.
Each outcome contributes its own accumulated reward and duration-dependent continuation term to the option value.

Take a three-state environment {A,B,C}\{A, B, C\} with γ=0.9\gamma = 0.9. One option oo is initiated in AA. Its internal policy and termination condition produce two possible outcomes:

OutcomeTerminal state s′s'Duration kkProbabilityCumulative reward rr
FastBB10.61.0
SlowCC20.41.5

The cumulative reward for the slow case already includes the discount on the second reward: r=rt+1+γrt+2r = r_{t+1} + \gamma r_{t+2}.

Compute the expected cumulative reward:

rAo=0.6(1.0)+0.4(1.5)=0.6+0.6=1.2r^o_A = 0.6(1.0) + 0.4(1.5) = 0.6 + 0.6 = 1.2

Compute the discounted transition probabilities:

pABo=0.6⋅γ1=0.6⋅0.9=0.54p^o_{AB} = 0.6 \cdot \gamma^1 = 0.6 \cdot 0.9 = 0.54 pACo=0.4⋅γ2=0.4⋅0.81=0.324p^o_{AC} = 0.4 \cdot \gamma^2 = 0.4 \cdot 0.81 = 0.324

Note that pABo+pACo=0.864<1p^o_{AB} + p^o_{AC} = 0.864 < 1. The mass that "disappeared" is the duration discount — it is not a probability leak, it is the discount doing its job.

Now suppose Vμ(B)=2.0V^\mu(B) = 2.0 and Vμ(C)=3.0V^\mu(C) = 3.0. The backup gives:

Qμ(A,o)=1.2+0.54(2.0)+0.324(3.0)=1.2+1.08+0.972=3.252Q^\mu(A, o) = 1.2 + 0.54(2.0) + 0.324(3.0) = 1.2 + 1.08 + 0.972 = 3.252

Compare against the naive one-step substitution, which would treat oo as a single action with expected reward 1.2 and a plain transition to a blended successor:

Qnaive=1.2+0.9[0.6(2.0)+0.4(3.0)]=1.2+0.9(2.4)=3.36Q_{\text{naive}} = 1.2 + 0.9\big[0.6(2.0) + 0.4(3.0)\big] = 1.2 + 0.9(2.4) = 3.36

The naive backup overestimates by about 0.11. The error is small here because the durations are short and γ\gamma is close to 1, but the direction is consistent for this outcome distribution: the naive version under-discounts the continuation, so it overvalues the option relative to the correct backup. The error grows with duration and with the gap between the two successor values.

Common mistake: Reading the 0.11 gap as a general rule that "longer options are worse." The gap here is a comparison between two backups of the same option, not a comparison between two different options. Ranking options requires comparing their full rso+∑s′pss′oVμ(s′)r^o_s + \sum_{s'} p^o_{ss'} V^\mu(s') values, not their durations.

Knowledge check

Check your understanding

Answer this question before you continue.

Using the worked example's outcomes and values, what is Qμ(A, o) under the semi-Markov backup?
Output Prediction

Focus: Apply the discounted transition probabilities and expected cumulative reward to calculate an option-value backup.

γ = 0.9
Fast: probability 0.6, duration 1, reward 1.0, terminal value Vμ(B) = 2.0
Slow: probability 0.4, duration 2, cumulative reward 1.5, terminal value Vμ(C) = 3.0

Primitive Backup vs Option Backup

PropertyPrimitive actionOption
Decision unitSingle actionPolicy with termination condition
Reward termSingle expected reward r(s,a)r(s,a)Expected accumulated discounted reward rsor^o_s
Continuation discountγ\gamma, applied onceγk\gamma^k, kk random
Model requirementp(s′∣s,a)p(s' \mid s, a)Joint p(s′,k∣s,o)p(s', k \mid s, o)
Backup formr+γ∑s′pV(s′)r + \gamma \sum_{s'} p V(s')rso+∑s′pss′oV(s′)r^o_s + \sum_{s'} p^o_{ss'} V(s')

The reduction check matters: when the option always terminates in one step, k=1k = 1 deterministically, pss′o=γ p(s′∣s,o)p^o_{ss'} = \gamma\, p(s' \mid s, o), and the option backup collapses exactly to the primitive backup. If your derivation does not pass this check, something is wrong.

When the Semi-Markov Backup Applies and When It Does Not

The backup is valid when options are treated as opaque, indivisible units and their outcomes depend only on the initiating state and the option. That is the semi-Markov property, and it is the load-bearing assumption.

It breaks in three places. History-dependent termination — timeouts, or β\beta that inspects the trajectory — requires a history-indexed value function. A non-stationary option policy invalidates the fixed pss′op^o_{ss'}. And if the option can be interrupted mid-execution and the interruption changes the value, the opaque-unit assumption fails: you are no longer backing up over a single indivisible transition.

Two costs are worth naming. Planning over a fixed option set yields the best value achievable with those options, which is generally below the optimal value over primitive actions — the option set constrains what you can express. And the joint distribution over next state and duration is harder to estimate than a plain transition probability; duration error feeds straight into the discount term.

My rule: use the semi-Markov backup whenever you are evaluating or improving a policy whose decisions are temporally extended. That is the modeling choice the equation was built for, and it is exact under the semi-Markov assumption regardless of how short or long the options happen to be. Reach for a primitive-action backup when your decision unit really is one step, or when you have deliberately chosen a one-step approximation and can state what you are giving up. Do not assume the approximation is harmless just because durations are short or noisy — a short option still carries a duration-dependent discount, and a noisy duration estimate corrupts the model without making the one-step equation the right substitute.

What to Check Next

Whenever you see an option backup in a paper or write one in code, verify three things. The reward term is accumulated over the option's internal steps, not a single scalar. The continuation discount is raised to the random duration, not applied once. And the model is a joint distribution over next state and transit time, not a plain transition probability. If any of the three is missing, the backup is silently assuming the option ends in one step.

The natural next step is to drop this backup into a value-iteration loop over options and watch how the option set constrains the achievable value. Change the termination conditions. Add a longer option. Observe how the discounted transition probabilities shift and how the value ceiling moves. Then run the controlled comparison the equation actually supports: hold the terminal-state distribution fixed, vary only the duration, and confirm that the continuation term shrinks while the total option value may still rise. The equation stops being notation the moment you watch it rank two options differently — and can explain exactly which term did the ranking.

Knowledge check

Final check

Finish the article by checking the ideas you just learned.

In the compact option backup, why does the continuation sum use pᵒ_ss′ without showing a separate γᵏ factor?
Question 1 of 2Comparison Reasoning

Focus: Explain how the discounted transition model encodes duration discounting in the compact option backup.

Which setup satisfies the article's conditions for using the compact state-only semi-Markov backup?
Question 2 of 2Scenario Interpretation

Focus: Identify when the state-only semi-Markov option backup is valid from the option model's assumptions.

References

  1. Improved Switching among Temporally Abstract Actionspapers.nips.cc
  2. Between MDPs and Semi-MDPs: Learning, Planning, and ...www.incompleteideas.net
Practical resource

Build a stronger RL mental model

Use structured resources to connect equations, algorithms, and observable agent behavior.

Browse resources
Related sites

Continue across related AI foundations

Use LearnPyFast for Python foundations and LearnLLMFast for practical language-model and agent application concepts.

Python tutorialstutorial

LearnPyFast

Beginner-friendly Python tutorials, examples, and learning paths for practical programming foundations.

PythonProgrammingBeginners
Visit LearnPyFast
LLM tutorialstutorial

LearnLLMFast

Practical LLM tutorials for builders who want to understand prompting, workflows, agents, and AI applications.

LLMAIBuilders
Visit LearnLLMFast

Keep learning

Related reinforcement learning tutorials

Continue with nearby RL concepts, algorithms, and experiments that build on the same decision process.