---
date: Monday, November 30^th^, 2026
header-includes:
- "`\\newcommand\\Reals{\\mathbb{R}}`{=tex}"
- "`\\newcommand\\Nats{\\mathbb{N}}`{=tex}"
- "`\\newcommand\\Distr[1]{\\Delta\\!\\left(#1\\right)}`{=tex}"
- "`\\newcommand\\Expect[2][]{\\mathbb{E}_{#1}\\!\\left[\\,#2\\,\\right]}`{=tex}"
- "`\\newcommand\\States{\\mathcal{S}}`{=tex}"
- "`\\newcommand\\Actions{\\mathcal{A}}`{=tex}"
- "`\\newcommand\\tuple[1]{\\langle{#1}\\rangle}`{=tex}"
- "`\\newcommand\\Value[2]{v^{#1}_{#2}}`{=tex}"
- "`\\newcommand\\Eval[1][]{\\mathcal{J}^{#1}}`{=tex}"
- "`\\newcommand\\Rewards{\\mathcal{R}}`{=tex}"
- "`\\newcommand\\TPLS{T_{\\text{PLS}}}`{=tex}"
- "`\\newcommand\\TPS{T_{\\text{PS}}}`{=tex}"
- "`\\newcommand\\TDR{T_{\\text{DR}}}`{=tex}"
- "`\\newcommand\\FamPLS{\\mathcal{T}_{\\text{PLS}}}`{=tex}"
- "`\\newcommand\\FamPS{\\mathcal{T}_{\\text{PS}}}`{=tex}"
- "`\\newcommand\\FamDR{\\mathcal{T}_{\\text{DR}}}`{=tex}"
- "`\\newcommand\\id{\\text{id}}`{=tex}"
- "`\\newcommand\\iv[1]{[\\![#1]\\!]}`{=tex}"
- |
  `\newcommand{\barrule}[1]{\mathrlap{\rule[#1]{0.55em}{0em}}}`{=tex}\
  %0em=1px thick, katex quirk
- "`\\newcommand{\\ubar}[1]{\\barrule{-0.31em}#1}`{=tex}"
- "`\\newcommand{\\wbar}[1]{\\barrule{-0.44em}\\ubar{#1}}`{=tex}"
- "`\\renewcommand{\\bar}[1]{\\barrule{0.55em}#1}`{=tex}"
- "`\\newcommand{\\bbar}[1]{\\barrule{0.68em}\\bar{#1}}`{=tex}"
katex-css: true
subtitle: Positive linear scaling, potential shaping, and destination
  redistribution
title: Reward function transformations
---

`\newcommand\Reals{\mathbb{R}}`{=tex}

`\newcommand\Nats{\mathbb{N}}`{=tex}

`\newcommand\Distr[1]{\Delta\!\left(#1\right)}`{=tex}

`\newcommand\Expect[2][]{\mathbb{E}_{#1}\!\left[\,#2\,\right]}`{=tex}

`\newcommand\States{\mathcal{S}}`{=tex}

`\newcommand\Actions{\mathcal{A}}`{=tex}

`\newcommand\tuple[1]{\langle{#1}\rangle}`{=tex}

`\newcommand\Value[2]{v^{#1}_{#2}}`{=tex}

`\newcommand\Eval[1][]{\mathcal{J}^{#1}}`{=tex}

`\newcommand\Rewards{\mathcal{R}}`{=tex}

`\newcommand\TPLS{T_{\text{PLS}}}`{=tex}

`\newcommand\TPS{T_{\text{PS}}}`{=tex}

`\newcommand\TDR{T_{\text{DR}}}`{=tex}

`\newcommand\FamPLS{\mathcal{T}_{\text{PLS}}}`{=tex}

`\newcommand\FamPS{\mathcal{T}_{\text{PS}}}`{=tex}

`\newcommand\FamDR{\mathcal{T}_{\text{DR}}}`{=tex}

`\newcommand\id{\text{id}}`{=tex}

`\newcommand\iv[1]{[\![#1]\!]}`{=tex}

`\newcommand{\barrule}[1]{\mathrlap{\rule[#1]{0.55em}{0em}}}`{=tex}\
%0em=1px thick, katex quirk

`\newcommand{\ubar}[1]{\barrule{-0.31em}#1}`{=tex}

`\newcommand{\wbar}[1]{\barrule{-0.44em}\ubar{#1}}`{=tex}

`\renewcommand{\bar}[1]{\barrule{0.55em}#1}`{=tex}

`\newcommand{\bbar}[1]{\barrule{0.68em}\bar{#1}}`{=tex}

The mapping between reward functions and their induced policies is not
one-to-one. Indeed, a given reward function often has many equally
optimal policies. Moreover, a given ordering over the space of policies
may be induced by many distinct reward functions. In particular, the
ordering induced on the space of policies is invariant to
transformations like the following:

-   scaling a reward function by a positive constant,
-   adding a so-called "potential shaping" term, and
-   redistributing expected reward between transition destinations.

In fact, in an environment with no unreachable states, every two reward
functions that induce the same ordering over the space of policies are
related by the above transformations (or compositions of them; Skalse et
al. 2023, Skalse and Abate, 2023).

This note reviews and expands on the definitions of these reward
function transformations, including their group structure under
composition, and gives a self-contained proof of this invariance
completeness result.

*Contents:*

-   [Reinforcement learning
    preliminaries](#reinforcement-learning-preliminaries){#toc-reinforcement-learning-preliminaries}
    -   [Environments and
        reward](#environments-and-reward){#toc-environments-and-reward}
    -   [Policies](#policies){#toc-policies}
    -   [Policy evaluation](#policy-evaluation){#toc-policy-evaluation}
    -   [The value function and the Bellman
        equation](#the-value-function-and-the-bellman-equation){#toc-the-value-function-and-the-bellman-equation}
    -   [Occupancy measures and evaluation
        linearity](#occupancy-measures-and-evaluation-linearity){#toc-occupancy-measures-and-evaluation-linearity}
    -   [Marginal occupancy measures and occupancy
        identities](#marginal-occupancy-measures-and-occupancy-identities){#toc-marginal-occupancy-measures-and-occupancy-identities}
-   [Some reward function
    transformations](#some-reward-function-transformations){#toc-some-reward-function-transformations}
    -   [Positive linear
        scaling](#positive-linear-scaling){#toc-positive-linear-scaling}
    -   [Potential shaping](#potential-shaping){#toc-potential-shaping}
    -   [Destination
        redistribution](#destination-redistribution){#toc-destination-redistribution}
-   [Transformation
    groups](#transformation-groups){#toc-transformation-groups}
    -   [Group structure via
        homomorphism](#group-structure-via-homomorphism){#toc-group-structure-via-homomorphism}
    -   [Invertible indexing via
        isomorphism](#invertible-indexing-via-isomorphism){#toc-invertible-indexing-via-isomorphism}
    -   [Commutation identities for the
        join](#commutation-identities-for-the-join){#toc-commutation-identities-for-the-join}
    -   [Normal form via simplification
        uniqueness](#normal-form-via-simplification-uniqueness){#toc-normal-form-via-simplification-uniqueness}
-   [Some invariances of reinforcement
    learning](#some-invariances-of-reinforcement-learning){#toc-some-invariances-of-reinforcement-learning}
    -   [Invariance to positive linear
        scaling](#invariance-to-positive-linear-scaling){#toc-invariance-to-positive-linear-scaling}
    -   [Invariance to potential
        shaping](#invariance-to-potential-shaping){#toc-invariance-to-potential-shaping}
    -   [Invariance to destination
        redistribution](#invariance-to-destination-redistribution){#toc-invariance-to-destination-redistribution}
-   [All invariances of reinforcement
    learning](#all-invariances-of-reinforcement-learning){#toc-all-invariances-of-reinforcement-learning}
    -   [Policies achieve all intermediate
        evaluations](#policies-achieve-all-intermediate-evaluations){#toc-policies-achieve-all-intermediate-evaluations}
    -   [Preserving the preorder implies positive affine evaluation
        change](#preserving-the-preorder-implies-positive-affine-evaluation-change){#toc-preserving-the-preorder-implies-positive-affine-evaluation-change}
    -   [Positive affine evaluation change implies a joint
        transformation](#positive-affine-evaluation-change-implies-a-joint-transformation){#toc-positive-affine-evaluation-change-implies-a-joint-transformation}
    -   [Characterising all
        invariances](#characterising-all-invariances){#toc-characterising-all-invariances}
-   [Conclusion](#conclusion){#toc-conclusion}
-   [References](#references){#toc-references}

*Word count:* 6350

## Reinforcement learning preliminaries

First, a short primer on reinforcement learning concepts and the
associated formalism (environments, reward functions, policies,
evaluation, and value functions), plus occupancy measures and some
standard identities and results we will use in later proofs.

### Environments and reward

We model an **environment** as a **reward-free Markov decision process
(MDP),** a tuple $\langle{\mathcal{S}, \mathcal{A}, \iota, \tau}\rangle$
where:

-   $\mathcal{S}$ is a non-empty, finite set of environment **states,**
-   $\mathcal{A}$ is a non-empty, finite set of agent **actions,**
-   $\iota \in \Delta\!\left(\mathcal{S}\right)$ is an **initial state
    distribution,** and
-   $\tau : \mathcal{S}\times \mathcal{A}\to \Delta\!\left(\mathcal{S}\right)$
    is a conditional **transition distribution** encoding the
    environment dynamics.

Separately, a **reward function** is a function
$r : \mathcal{S}\times \mathcal{A}\times \mathcal{S}\to \mathbb{R}$
ascribing numerical reward to MDP transitions. The set of all reward
functions is denoted $\mathcal{R}$.

I remark that I separate the reward function from the "environment" for
conceptual clarity:

-   The reward-free MDP defines the space of possible agent--environment
    interactions. Importantly, it is neutral as to which interactions
    are desirable.
-   The reward function is used to quantify how desirable different
    interactions are.

In reward theory, we mainly consider a fixed interaction system from the
perspective of different reward functions. Therefore, it's useful to be
able to refer to the fixed environment separately from the changing
reward function.

### Policies

Speaking of agent--environment interactions, we represent a particular
class of agent behaviours using a **policy.** Formally, a policy is a
conditional action distribution
$\pi : \mathcal{S}\to \Delta\!\left(\mathcal{A}\right)$ describing the
probability that our agent will choose each action when placed in each
state of the environment. The set of all policies is denoted $\Pi$.

Fixing a policy, we can sample **trajectories** of agent--environment
interactions:

1.  First, sample an initial state $s_0 \sim \iota$.
2.  Next, sample an agent action $a_0 \sim \pi(s_0)$.
3.  Then, sample a new environment state $s_1 \sim \tau(s_0, a_0)$.
4.  Repeat from step 2, incrementing all subscripts by one. That is, $$
    a_t \sim \pi(s_t),
    \quad
    s_{t+1} \sim \tau(s_t, a_t).
    \qquad
    \text{($t \in \mathbb{N}_{>0}$)}
    $$

Thus, a choice of policy induces a particular distribution over
state--action trajectories.

### Policy evaluation

If we now bring in a reward function $r \in \mathcal{R}$, we can
quantify the desirability of a policy by the kinds of trajectories it
induces. In particular, fix also a **discount rate** $\gamma \in (0,1)$
(once again, I keep this out of the environment definition for
conceptual reasons---there are other ways to score trajectories). Then
the **evaluation function** $\mathcal{J}^{r} : \Pi \to \mathbb{R}$,
encodes the expected cumulative discounted reward under each policy
$\pi \in \Pi$: $$
  \mathcal{J}^{r}(\pi) = \mathbb{E}_{\pi}\!\left[\,
    \sum_{t=0}^\infty \gamma^t r(s_t, a_t, s_{t+1})
  \,\right],
$$ where $\mathbb{E}_{\pi}\!\left[\,\cdot\,\right]$ denotes expectation
taken over the distribution of trajectories induced by $\pi$.

The objective of reinforcement learning (RL) methods is typically to
find a policy that maximises the evaluation function for the given
reward function. More generally, through the evaluation function, each
reward function induces a total preorder on the space of policies. That
is, given $r \in \mathcal{R}$, we can define a relation
${\preceq_r} \subseteq \Pi \times \Pi$ such that $$
    \pi_ 1 \preceq_r \pi_2
    \qquad
    \text{if and only if}
    \qquad
    \mathcal{J}^{r}(\pi_1) \leq \mathcal{J}^{r}(\pi_2)
  .$$ Call this relation the **policy preorder.** It represents the
ranking of the desirability of all policies under the given reward
function.

### The value function and the Bellman equation

Because of the Markov assumptions, policy evaluation decomposes
recursively into a system of per-state evaluations. First, we define a
per-state evaluation function, called the **value function.** Given a
reward function $r \in \mathcal{R}$, and a policy $\pi \in \Pi$, define
the **value function**, $v^{r}_{\pi} : \mathcal{S}\to \mathbb{R}$, as
the expected discounted cumulative reward achieved by the policy
*assuming trajectories originating in each state $s \in \mathcal{S}$,*
$$
  v^{r}_{\pi}(s) = \mathbb{E}_{\pi}\!\left[\,
    \sum_{t=0}^\infty \gamma^t r(s_t, a_t, s_{t+1})
  \,\middle|\,
    s_0 = s
  \,\right]
$$ (where by conditioning on $s_0=s$, I mean starting the sampling
process in state $s$, even if $\iota(s)=0$). The evaluation function can
then be written succinctly as
$$\mathcal{J}^{r}(\pi) = \mathbb{E}_{s \sim \iota}\!\left[\,v^{r}_{\pi}(s)\,\right].$$

Second, one can show that the value function satisfies a recurrence
relation known as the **Bellman equation,** such that for
$s \in \mathcal{S}$, $$
v^{r}_{\pi}(s)
= \mathbb{E}_{a\sim\pi(s), s'\sim\tau(s,a)}\!\left[\,
    r(s,a,s')
    + \gamma v^{r}_{\pi}(s')
\,\right]
$$ (this is not hard to check by hand). Moreover, for a given
reward--policy pair, the value function is the unique function
satisfying this recurrence relation (this follows because, as an
operator on the space of functions, the RHS is a contraction, and
therefore its fixed point is unique). Many RL algorithms take advantage
of the Bellman equation for finding (or approximating) optimal policies.

### Occupancy measures and evaluation linearity

Another perspective on evaluation is that it display a certain amount of
linear structure. To see this, let's introduce a function encoding the
expected number of times a given policy will enact a given transition
when interacting with the environment.

Formally, fix a policy $\pi \in \Pi$, and define the **discounted
transition occupancy measure,**
$\mu_\pi : \mathcal{S}\times \mathcal{A}\times \mathcal{S}\to \mathbb{R}_{\geq 0}$
by $$
    \mu_\pi(s,a,s') = \mathbb{E}_{\pi}\!\left[\,
      \sum_{t=0}^\infty \gamma^t
      [\![(s_t,a_t,s_{t+1})=(s,a,s')]\!]
    \,\right]
  $$ where $[\![\cdot]\!]$ is an indicator function, here equal to $1$
at timesteps where the particular transition is taken, or $0$ otherwise.
The non-negative number $\mu_\pi(s,a,s')$ counts the average number of
occurrences of the transition $(s,a,s')$ exhibited under the policy
$\pi$, with counts discounted according to their position in time.

By regrouping terms in the definition of the evaluation function, policy
evaluation can be viewed as a policy-dependent linear functional in the
chosen reward function. For $r \in \mathcal{R}$, we see $$
  \mathcal{J}^{r}(\pi) = \sum_{s,a,s'} \mu_\pi(s,a,s') r(s,a,s').
$$ This representation makes explicit that, for a fixed policy,
evaluation is linear in the reward function. Moreover, while neither the
occupancy measure nor the evaluation function is generally linear in the
policy, the evaluation function is linear in the occupancy measure.

### Marginal occupancy measures and occupancy identities

The transition occupancy measure is one of a family of similar occupancy
measures. We can define other occupancy distributions given parts of a
transition by marginalisation. For any policy $\pi$, define four
**marginal occupancy measures:** $$\begin{align*}
  \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_\pi(s,a)
    &= \sum_{s'}\mu_\pi(s,a,s'),
  &\qquad
  \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_\pi(s)
    &= \sum_a\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_\pi(s,a)
    = \sum_a\sum_{s'}\mu_\pi(s,a,s'),
\\
  \mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_\pi(a,s')
    &= \sum_s \mu_\pi(s,a,s'),
  &\qquad
  \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_\pi(s')
    &= \sum_a \mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_\pi(a,s')
    = \sum_s \sum_a \mu_\pi(s,a,s').
\end{align*}$$ These functions have natural interpretations. It is easy
to show that they could alternatively have been defined as follows:
$$\begin{align*}
  \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_\pi(s,a)
    &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty \gamma^t
        [\![(s_t,a_t)=(s,a)]\!]
      \,\right],
  &
  \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_\pi(s)
    &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty \gamma^t
        [\![s_t=s]\!]
      \,\right],
\\
  \mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_\pi(a,s')
    &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty \gamma^t
        [\![(a_t,s_{t+1})=(a,s')]\!]
      \,\right],
  &
  \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_\pi(s')
    &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty \gamma^t
        [\![s_{t+1}=s']\!]
      \,\right].
\end{align*}$$

In other words,

-   $\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi}(s,a)$ is the
    expected discounted number of times the agent takes action $a$ in
    state $s$;
-   $\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_ {\pi}(s)$
    is the expected discounted number of times the agent transitions out
    of state $s$;
-   $\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi}(a,s')$ is the
    expected discounted number of times the agent takes action $a$, from
    any state, and lands in state $s'$; and
-   $\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi}(s')$
    is the expected discounted number of times the agent transitions
    into state $s'$.

The structure of the sampling process gives us the following
**factorisation identities:** $$
  \mu_\pi(s,a,s')
  = \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi}(s,a) \cdot \tau(s'\mid s,a),
  \qquad
  \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_ {\pi}(s, a)
  = \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_ {\pi}(s) \cdot \pi(a\mid s).
$$

Notice also that
$\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_\pi(s)$
and
$\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_\pi(s')$
can be related as follows. Intuitively, for every transition that enters
a state, there must be a transition that leaves it. The converse is true
except at time step $0$, where the initial state distribution decides
the start state without a transition. Thus it is easy to show that we
have the following **flow identity:** for $s
\in \mathcal{S}$, $$
  \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_\pi(s) = \iota(s) + \gamma \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_\pi(s).
$$

## Some reward function transformations

Formally, a **reward function transformation** is a function on the
space of reward functions $T : \mathcal{R}\to \mathcal{R}$. In this
section, we will define the three families of reward function
transformations mentioned in the introduction:

-   scaling a reward function by a positive constant,
-   adding a so-called "potential shaping" term, and
-   redistributing expected reward between transition destinations.

### Positive linear scaling

For each positive constant $\alpha \in \mathbb{R}_{> 0}$, define a
**positive linear scaling** reward function transformation
$T_{\text{PLS}}^\alpha : \mathcal{R}\to \mathcal{R}$ such that for
$r \in \mathcal{R}$, $$
  T_{\text{PLS}}^\alpha (r) = \alpha r.
$$ That's function multiplication:
$(\alpha r)(s,a,s') = \alpha r(s,a,s')$. Denote by
$$\mathcal{T}_{\text{PLS}}= (T_{\text{PLS}}^\alpha)_{\alpha \in \mathbb{R}_{>0}}$$
the family of positive linear scaling transformations.

Intuitively, there's not much to explain here. $T_{\text{PLS}}^\alpha$
simply corresponds to scaling all of the rewards dispensed to an agent
by a constant scale factor $\alpha > 0$.

In practice, if you have two reward functions
$r_1, r_2 \in \mathcal{R}$, how can you tell if there exists a positive
linear scaling transformation that will transform $r_1$ into $r_2$? You
just have to show that you can find a single positive $\alpha$ ratio
between all of the rewards, handling the case of zero carefully. In
particular, the following two conditions suffice:

1.  **Equal support:** for all $s, a, s'$,
    $$r_1(s,a,s') = 0\text{ if and only if }r_2(s,a,s') = 0,$$ and

2.  **Constant ratio:** there is a fixed scalar
    $\alpha \in \mathbb{R}_{>0}$ such that for all $s,a,s'$ where
    $r_1(s,a,s') \neq 0$,
    $$\alpha = \frac{r_ 2(s,a,s')}{r_ 1(s,a,s')}.$$

It's easy to show that these two conditions are equivalent to
$\exists \alpha \in \mathbb{R}_{>0}$ such that $r_2 = \alpha r_1$, or,
in other words, equivalent to $\exists T \in \mathcal{T}_{\text{PLS}}$
such that $r_2 = T(r_1)$.

### Potential shaping

The next family of transformations is a family called potential shaping
transformations, first studied by Ng, Harada, and Russell (1999). It
takes a couple of extra steps to define.

We'll start by defining a **potential function** to be any real function
on the state space: $\varphi : \mathcal{S}\to \mathbb{R}$. We don't
place any restrictions on these functions (in this note's infinite
horizon discounted setting). Call the set of all potential functions
$\Phi$. Intuitively, a potential function is intended to encode some
amount of desirability associated with being in each state.

Secondly, we'll define an auxiliary reward function related to each
potential function. Recall that we fixed a discount rate
$\gamma \in (0,1)$. Given a potential function $\varphi \in \Phi$,
define a **potential difference** reward function
$\partial\varphi \in \mathcal{R}$ such that for $s, a, s'$,
$$\partial\varphi(s, a, s') = \gamma \varphi(s') - \varphi(s).$$

Intuitively, this reward function rewards the agent based on changes in
state potential as it moves through the reward space. For a moment,
ignore discounting (pretend the discount rate is $\gamma=1$).[^1] Upon
leaving state $s$ and entering state $s'$, the agent gains reward
$\varphi(s')$ based on the potential associated to state $s'$ and loses
the potential-based reward $\varphi(s)$ associated to the previous
state. If the agent moves around in a circle and returns to its starting
point, the net reward it will receive is zero. The agent can only
achieve positive reward by moving from states of low potential to states
of high potential.

Before we move on to defining potential shaping transformations
themselves, let's dwell here for a moment and explore some properties of
this kind of reward function.

-   **Potential value telescoping:** The value function corresponding to
    a potential difference reward function is pleasingly simple. Fix any
    policy $\pi$ and let $\varphi \in \Phi$ be a potential function.
    Then $$\begin{align*}
      v^{\partial\varphi}_{\pi}(s)
      &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty \gamma^t \partial\varphi(s_t, a_t, s_{t+1})
      \,\middle|\,
        s_0 = s
      \,\right]
      \\
      &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty 
          \gamma^t \left(
            \gamma\varphi(s_{t+1})
            - \varphi(s_t)
        \right)
      \,\middle|\,
        s_0 = s
      \,\right]
      \\
      &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty \left(
          \gamma^{t+1} \varphi(s_{t+1})
          - \gamma^t \varphi(s_t)
        \right)
      \,\middle|\,
        s_0 = s
      \,\right]
      \\
      &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=0}^\infty \gamma^{t+1} \varphi(s_{t+1})
        - \varphi(s_0)
        - \sum_{t=1}^\infty \gamma^t \varphi(s_t)
      \,\middle|\,
        s_0 = s
      \,\right]
      \\
      &= \mathbb{E}_{\pi}\!\left[\,
        \sum_{t=1}^\infty \gamma^t \varphi(s_t)
        - \varphi(s_0)
        - \sum_{t=1}^\infty \gamma^t \varphi(s_t)
      \,\middle|\,
        s_0 = s
      \,\right]
      \\
      &= \mathbb{E}_{\pi}\!\left[\,
        - \varphi(s_0)
      \,\middle|\,
        s_0 = s
      \,\right]
      \\
      &= - \varphi(s)
    .
    \end{align*}$$

-   **Policy-agnosticism:** Notice that this value function does not
    depend on the choice of policy $\pi$. It follows that for a given
    potential function $\varphi \in \Phi$, the policy evaluation
    function for the associated potential difference reward function
    $\partial\varphi$ is constant with respect to $\pi$: $$
      \mathcal{J}^{\partial\varphi}(\pi)
      = \mathbb{E}_{s \sim \iota}\!\left[\,v^{\partial\varphi}_{\pi}(s)\,\right]
      = \mathbb{E}_{s \sim \iota}\!\left[\,-\varphi(s)\,\right].
    $$ As a consequence, for a given potential difference reward
    function, all policies are considered optimal.

-   **Expressivity:** The above results shed light on the expressivity
    of potential difference reward functions. In a given environment, it
    is typically possible to express reward functions for which not all
    policies are equally optimal. Therefore, there must be reward
    functions in $r\in\mathcal{R}$ that are not expressible as potential
    difference reward functions for any potential function
    $\varphi \in \Phi$.

    Moreover, in our finite-state setting, observe that $\Phi$ is
    isomorphic to $\mathbb{R}^{|\mathcal{S}|}$, whereas $\mathcal{R}$ is
    isomorphic to
    $\mathbb{R}^{|\mathcal{S}\times\mathcal{A}\times\mathcal{S}|}$. The
    map $\varphi \mapsto \partial\varphi$ is from $\Phi$ to
    $\mathcal{R}$, and its image can have dimensionality at most
    $|\mathcal{S}|$.

    On the other hand, our first result shows that for a given policy
    $\pi$, through the choice of the right potential function it is
    possible to create a potential difference reward function for an
    arbitrary value function $v : \mathcal{S}\to \mathbb{R}$. Namely,
    put $\varphi = -v$, then
    $v^{\partial \varphi}_{\pi} = - \varphi = v$.

-   **Constant rewards:** Potential difference reward functions are
    about changes in potential. But due to discounting, it is actually
    possible to define a potential function for which the potential
    difference reward function is any constant. Let $k \in \mathbb{R}$.
    Recall we have assumed $\gamma \in (0,1)$. Set
    $$\varphi_k(s) = \frac{k}{\gamma-1}.$$ Then we have $$\begin{align*}
      \partial\varphi_k(s,a,s')
      &= \gamma\varphi_k(s') - \varphi_k(s)
      \\
      &= \gamma\frac{k}{\gamma-1} - \frac{k}{\gamma-1}
      \\
      &= (\gamma-1)\frac{k}{\gamma-1}
      \\
      &= k
    .\end{align*}$$

Hopefully that gives a richer sense of potential difference rewards. We
will now use them to actually define potential shaping transformations.
Given, a potential function $\varphi \in \Phi$, define the **potential
shaping** reward function transformation
$T_{\text{PS}}^\varphi : \mathcal{R}\to \mathcal{R}$ as the
transformation that adds the corresponding potential difference reward
function to its input reward function:
$$T_{\text{PS}}^\varphi (r) = r + \partial\varphi.$$ That's function
addition, so, spelled out, we have
$$(T_{\text{PS}}^\varphi(r))(s,a,s') = r(s,a,s') + \gamma \varphi(s') - \varphi(s).$$
Denote by
$\mathcal{T}_{\text{PS}}= (T_{\text{PS}}^\varphi)_{\varphi \in \Phi}$
the family of potential shaping reward function transformations.

Intuitively, by adding the potential difference reward function to the
reward signal, in addition to whatever reward signal was in play
beforehand, the new reward function also dispenses rewards based on
changes in state potential as the agent moves through the state space,
as described above.

In practice, if you have two reward functions
$r_1, r_2 \in \mathcal{R}$, how can you tell if there exists a potential
shaping transformation that will transform $r_1$ into $r_2$? If they do,
we'd be able to recover the potential difference reward function as the
difference in reward functions: for all $s,a,s'$, $$
  r_2(s,a,s') - r_1(s,a,s') = \gamma \varphi(s') - \varphi(s).
$$ In the finite-state case, the above specifies a linear system of
equations in $\varphi \in \Phi$ where $\varphi(s)$ for each
$s \in \mathcal{S}$ is an unknown. If this equation has a solution, it's
$\varphi$. Or else, the reward functions can't be related by a potential
shaping transformation.

### Destination redistribution

Last but not least, we have the family of destination redistribution[^2]
transformations introduced in Skalse et al. (2023). I'll introduce a
modified definition for the purposes of this note, which is not exactly
equivalent, but seems to be substantially clearer and preserves the
final result.[^3]

First, let's define another kind of auxiliary reward function. Recall
that we fixed the environment's transition distribution
$\tau : \mathcal{S}\times \mathcal{A}\to \Delta(\mathcal{S})$. With this
in mind, say that a reward function $\omega \in \mathcal{R}$ is
**transition-orthogonal** if for all $s \in \mathcal{S}$,
$a \in \mathcal{A}$, $$
    \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,\omega(s,a,s')\,\right] = 0.
  $$ Denote by $\Omega \subseteq \mathcal{R}$ the set of all
transition-orthogonal reward functions.

Intuitively, transition-orthogonal reward functions have to produce
rewards that average out to zero over the potential destinations of a
random transition starting from a fixed state via a fixed action.

I use the term "orthogonal" for this because the condition amounts to
orthogonality of the probability distribution $\tau(\cdot | s,a)$ and
the restricted reward function $\omega(s,a,\cdot)$ viewed as vectors in
$\mathbb{R}^{|\mathcal{S}|}$: $$
    0
    = \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,\omega(s,a,s')\,\right]
    = \sum_{s' \in \mathcal{S}} \tau(s' | s,a) \cdot \omega(s,a,s')
    = \langle \tau(\cdot | s,a) , \omega(s,a,\cdot) \rangle
  $$ for each fixed $(s, a)$ pair.

A useful basic property of transition-orthogonal reward functions is
that they have zero value. That is, for any policy $\pi \in \Pi$, the
value function for a transition-orthogonal reward function
$\omega \in \Omega$ is always zero. To see this, observe that
$0 : \mathcal{S}\to \mathbb{R}$ solves the Bellman recurrence:
$$\begin{align*}
  \mathbb{E}_{a\sim\pi(s), s'\sim\tau(s,a)}\!\left[\,
      \omega(s,a,s')
      + \gamma 0
  \,\right]
  &= \mathbb{E}_{a\sim\pi(s)}\!\left[\,
      \mathbb{E}_{s'\sim\tau(s,a)}\!\left[\,
        \omega(s,a,s')
      \,\right]
    \,\right]
  \\&= \mathbb{E}_{a\sim\pi(s)}\!\left[\,
      0
    \,\right]
  \\&= 0
\end{align*}$$ for all $s \in \mathcal{S}$. Recall that this recurrence
has a unique solution that coincides with the value function, thus
$v^{\omega}_{\pi} = 0$.

Anyway, having defined this family of reward functions, we can define
destination redistribution. Given a transition-orthogonal reward
function $\omega \in \Omega$, define the **destination redistribution**
reward function transformation
$T_{\text{DR}}^\omega : \mathcal{R}\to \mathcal{R}$ as the
transformation that adds $\omega$ to its input reward function: $$
  T_{\text{DR}}^\omega(r) = r + \omega.
$$ Once again, that's function addition, so, spelled out, we have
$$(T_{\text{DR}}^\omega(r))(s,a,s') = r(s,a,s') + \omega(s,a,s').$$
Denote by
$\mathcal{T}_{\text{DR}}= (T_{\text{DR}}^\omega)_{\omega \in \Omega}$
the family of destination redistribution reward function
transformations.

Intuitively, by adding a transition-orthogonal reward function,
destination redistribution can *redistribute* the immediate reward that
the agent could expect to receive from taking a given action $a$ in a
given state $s$, such that the overall expected reward is preserved but
the amount of reward given for different random destinations is changed.
For example, if there is one rare destination and one common one, it
could add a small amount of positive reward to the common transition if
it adds a proportionally larger amount of negative reward to the rare
transition---enough to make sure the average stays the same.

More formally, we can show that if $r_2 = T_{\text{DR}}^\omega(r_1)$ for
some $\omega \in \Omega$, then for all $s, a$, $$\begin{align*}
    \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_2(s,a,s')\,\right]
    &= \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_1(s,a,s') + \omega(s,a,s')\,\right]
  \\
    &= \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_1(s,a,s')\,\right]
      + \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,\omega(s,a,s')\,\right]
  \\
    &= \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_1(s,a,s')\,\right]
  .
  \end{align*}
  $$

Conversely, suppose we have two reward functions
$r_1, r_2 \in \mathcal{R}$ satisfying $$
  \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_2(s,a,s')\,\right]
  = \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_1(s,a,s')\,\right].
  $$ Then, observe that $\omega = r_2 - r_1$ is transition-orthogonal:
for $s, a$, $$\begin{align*}
  \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,\omega(s,a,s')\,\right]
  &= \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_2(s,a,s') - r_1(s,a,s')\,\right]
  \\
  &= \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_2(s,a,s')\,\right]
      - \mathbb{E}_{s' \sim \tau(s,a)}\!\left[\,r_1(s,a,s')\,\right]
  \\
  &= 0
  .
  \end{align*}$$ Now
$r_2 = r_1 + (r_2 - r_1) = r_1 + \omega = T_{\text{DR}}^\omega(r_1)$, in
other words, we can reach $r_2$ from $r_1$ via the destination
redistribution $T_{\text{DR}}^{r_2-r_1}$.

## Transformation groups

Let's explore how reward function transformations from these families
behave under composition. We'll do so using the framework of group
theory.

-   We will show that each of the three families has the structure of an
    *abelian group.* This means that the transformation families are
    closed under composition and inversion and contain the identity
    transformation, and that composition within each family is
    commutative.

    One particular consequence is that any composition of
    transformations from a given family can always be represented by a
    single composition from the family.

-   In fact, each family is *isomorphic* to its indexing set:

    -   composition of positive linear scaling transformations behaves
        analogously to multiplication in the multiplicative group of
        positive scalars $\mathbb{R}_{>0}$,

    -   composition of potential shaping transformations behaves
        analogously to addition in the additive group of potential
        functions $\Phi$, and

    -   composition of destination redistribution transformations
        behaves analogously to addition in the additive group of
        transition-orthogonal functions $\Omega$.

    One particular consequence is that each transformation (or
    composition of transformations) within each family is represented by
    a *unique* index.

-   The *join* of the three families---containing all finite
    compositions of transformations from any of the three families---is
    not abelian, but it does permit a simple set of commutation
    identities. That is, for any composition of transformations from two
    different families, we find an equivalent composition in the other
    order, but we might have to use a different transformation within
    each family,

    One particular consequence is that we can simplify any finite
    composition of transformations until it is expressed as a sequence
    of three transformations, one of each type, in an arbitrary fixed
    order.

-   In fact, we will show that for a given transformation in the join,
    such a simplification is unique. (Formally, this is essentially to
    say that the join is isomorphic to a *semidirect product* of the
    indexing sets, but explaining that connection is out of scope.)

### Group structure via homomorphism

First, let's show that each of the transformation families is an abelian
group under composition. This means that each family behaves as follows:

1.  **Composition:** for any two transformations contained in the
    family, their composition is also contained in the family.
2.  **Identity:** the identity transformation
    $\text{id}: \mathcal{R}\to \mathcal{R}$ is contained in the family.
3.  **Inverses:** each transformation contained in the family is an
    invertible function and its inverse transformation is also contained
    in the family.
4.  **Commutativity:** for any two transformations contained in the
    family, composition is commutative.

Fortunately, these properties are well known to hold for the groups we
used as indexing sets for defining the function families, with
composition replaced by the appropriate binary operation:

-   The indexing set of positive linear scaling transformations,
    positive reals $\mathbb{R}_{>0}$, is a standard example of an
    abelian group under multiplication.
-   The indexing set of potential shaping transformations, potential
    functions $\Phi$, has a vector space structure and is therefore an
    abelian group under addition.
-   The indexing set of destination redistribution transformations,
    transition-orthogonal reward functions $\Omega$, is the orthogonal
    complement of the transition distribution, and as such it is a
    vector subspace of the space of reward functions and therefore also
    an abelian group under addition.

If we can show that the indexing map for each family is consistent with
these underlying group operations, we can automatically conclude that
the families have similar group structure: the families are
*homomorphic* to their indexing sets. Let us proceed:

1.  **Positive linear scaling and positive reals:** The indexing map is
    $h : \mathbb{R}_{>0} \to \mathcal{T}_{\text{PLS}}$,
    $h(\alpha) = T_{\text{PLS}}^\alpha$. We can easily show that this
    map is consistent. Let $\alpha, \beta \in \mathbb{R}_{>0}$. For
    $r \in \mathcal{R}$, $$\begin{align*}
       \bigl( h(\alpha) \circ h(\beta) \bigr) (r)
       &= \bigl(T_{\text{PLS}}^\alpha \circ T_{\text{PLS}}^\beta\bigr) (r)
       \\
       &= T_{\text{PLS}}^\alpha (T_{\text{PLS}}^\beta (r))
       \\
       &= \alpha \beta r
       \\
       &= T_{\text{PLS}}^{\alpha \beta} (r)
       = \bigl(h(\alpha\beta)\bigr) (r)
     .\end{align*}
     $$ Thus $h(\alpha) \circ h(\beta) = h(\alpha \beta)$.

2.  **Potential shaping and potential functions:** The indexing map is
    $h : \Phi \to \mathcal{T}_{\text{PS}}$,
    $h(\varphi) = T_{\text{PS}}^\varphi$. We can easily show that this
    map is consistent. Let $\varphi, \psi \in \Phi$. For
    $r \in \mathcal{R}$, $$\begin{align*}
       \bigl( h(\varphi) \circ h(\psi) \bigr) (r)
       &= \bigl(T_{\text{PS}}^\varphi \circ T_{\text{PS}}^\psi\bigr) (r)
       \\
       &= T_{\text{PS}}^\varphi (T_{\text{PS}}^\psi (r))
       \\
       &= r + \partial\psi + \partial\varphi
       \\
       &= r + \partial(\varphi + \psi)                           \tag{exercise}
       \\
       &= T_{\text{PS}}^{\varphi + \psi} (r)
       = \bigl(h(\varphi + \psi)\bigr) (r)
     .\end{align*}
     $$ Thus $h(\varphi) \circ h(\psi) = h(\varphi + \psi)$.

3.  **Destination redistribution and transition-orthogonal reward
    functions:** The indexing map is
    $h : \Omega \to \mathcal{T}_{\text{DR}}$,
    $h(\omega) = T_{\text{DR}}^\omega$. We can easily show that this map
    is consistent. Let $\omega, \omicron \in \Omega$. For
    $r \in \mathcal{R}$, $$\begin{align*}
       \bigl( h(\omega) \circ h(\omicron) \bigr) (r)
       &= \bigl(T_{\text{DR}}^\omega \circ T_{\text{DR}}^\omicron\bigr) (r)
       \\
       &= T_{\text{DR}}^\omega (T_{\text{DR}}^\omicron (r))
       \\
       &= r + \omicron + \omega
       \\
       &= r + \omega + \omicron
       \\
       &= T_{\text{DR}}^{\omega + \omicron} (r)
       = \bigl(h(\omega + \omicron)\bigr) (r)
     .\end{align*}
     $$ Thus $h(\omega) \circ h(\omicron) = h(\omega + \omicron)$.

It follows that each family is an abelian group:

-   **Composition:** That the families are closed under function
    composition is implicit in the compatibility proofs, which construct
    the composite transform on the way to showing it's indexed by the
    combination of the indices.

-   **Identity:** Consistency also implies that the families contain the
    identity reward transformation, since this is the only reward
    transformation that could be consistent with the identity index in
    each group. In fact, we can verify directly that
    $$T_{\text{PLS}}^1 = T_{\text{PS}}^0 = T_{\text{DR}}^0 = \text{id}: \mathcal{R}\to \mathcal{R}.$$

-   **Inverses:** given any transformation $h(a)$, we can compute an
    inverse in the indexing group $a^{-1}$ and use consistency to show
    that $h(a^{-1}) = h(a)^{-1}$.

-   **Commutativity:** Function composition is not commutative in
    general. However, consistency allows us to lift commutativity from
    the underlying groups to these transformation groups: $$
      h(a) \circ h(b)
      = h(a \ast b)
      = h(b \ast a)
      = h(b) \circ h(a),
    $$ where $\ast$ is the indexing group's operation (multiplication or
    addition).

### Invertible indexing via isomorphism

The above homomorphism tells us a lot about how the group structure of
the indexing groups is reflected in the structure of the transformation
families. However, so far it's a one-way reflection: we haven't shown
that each of the transformations corresponds to a unique index. Let's
fix this by showing that these indexing maps are *injective.* This gives
us the stronger result that the transformation families are *isomorphic*
to their indexing groups, meaning composition and the multiplication or
addition operation in the underlying group are identical.

Given that we have a group homomorphism $h$, to establish these
isomorphisms it suffices to show that if $h(x) = \text{id}$ for some
index $x$, then $x$ is the identity in the indexing group. This is
easily done:

1.  For positive linear scaling, take $\alpha \in \mathbb{R}_{>0}$ such
    that $h(\alpha) = \text{id}$. Evaluating both sides on the constant
    reward function $1 \in \mathcal{R}$ gives
    $$1 = \text{id}(1) = h(\alpha)(1) = T_{\text{PLS}}^\alpha(1) = \alpha 1.$$
    It follows that $\alpha = 1 \in \mathbb{R}_{>0}$.

2.  For potential shaping, take $\varphi \in \Phi$ such that
    $h(\varphi) = \text{id}$. Evaluating both sides on the null reward
    function $0 \in \mathcal{R}$ gives
    $$0 = \text{id}(0) = h(\varphi)(0) = T_{\text{PS}}^\varphi(0) = 0 + \partial\varphi =
      \partial\varphi.$$ $\partial\varphi = 0$ implies in particular for
    each $s$ and any $a$,
    $$0 = \partial\varphi(s,a,s) = \gamma \varphi(s) - \varphi(s)
      = (\gamma - 1) \varphi(s).$$ Since $\gamma \in (0,1)$,
    $\gamma-1 \neq 0$, and we conclude $\varphi = 0 \in \Phi$.

3.  For destination redistribution, take $\omega \in \Omega$ such that
    $h(\omega) = \text{id}$. Evaluating both sides on the null reward
    function $0 \in \mathcal{R}$ gives
    $$0 = \text{id}(0) = h(\omega)(0) = T_{\text{DR}}^\omega(0) = 0 + \omega = \omega.$$
    Thus $\omega = 0 \in \Omega$.

In particular, this means that each transformation has a unique index
within its family. For example, for each potential shaping
transformation, there is a *unique* potential function to which it
corresponds.

### Commutation identities for the join

What if we compose transformations from different families? Define the
**joined family**
$$\mathcal{T}_{\text{PLS}}\vee \mathcal{T}_{\text{PS}}\vee \mathcal{T}_{\text{DR}}
  = \langle \mathcal{T}_{\text{PLS}}\cup \mathcal{T}_{\text{PS}}\cup \mathcal{T}_{\text{DR}}\rangle$$
as the group generated by the union of the families. This corresponds to
the set of all transformations that can be formed as finite compositions
of transformations from any of the families.

It turns out the resulting group isn't abelian, but there is a simple
set of commutation identities that allows us to exchange transformations
of each family. We already know that transformations from the same
family will commute freely. The same is actually true for potential
shaping and destination redistribution:

-   **Potential shaping and destination redistribution commute:** Let
    $\varphi \in \Phi$, $\omega \in \Omega$. Then for
    $r \in \mathcal{R}$: $$\begin{align*}
        (T_{\text{PS}}^\varphi \circ T_{\text{DR}}^\omega)(r)
        &= r + \partial \varphi + \omega
        \\&= r + \omega + \partial \varphi
        \\&= (T_{\text{DR}}^\omega \circ T_{\text{PS}}^\varphi)(r).
      \end{align*}$$ Thus,
    $T_{\text{PS}}^\varphi \circ T_{\text{DR}}^\omega = T_{\text{DR}}^\omega \circ T_{\text{PS}}^\varphi.$

For the remaining two possible combinations, we can define a commutative
identity:

-   **Positive linear scaling and potential shaping:** Let
    $\alpha \in \mathbb{R}_{>0}$, $\varphi \in \Phi$. Then for
    $r \in \mathcal{R}$: $$\begin{align*}
        (T_{\text{PLS}}^\alpha \circ T_{\text{PS}}^\varphi)(r)
        &= \alpha(r + \partial \varphi)
        \\&= \alpha r + \partial (\alpha \varphi)
        \tag{exercise}
        \\&= (T_{\text{PS}}^{\alpha\varphi} \circ T_{\text{PLS}}^\alpha)(r).
      \end{align*}$$ Thus,
    $T_{\text{PLS}}^\alpha \circ T_{\text{PS}}^\varphi = T_{\text{PS}}^{\alpha\varphi} \circ T_{\text{PLS}}^\alpha.$
    Equivalently,
    $T_{\text{PS}}^\varphi \circ T_{\text{PLS}}^\alpha = T_{\text{PLS}}^\alpha \circ T_{\text{PS}}^{\varphi/\alpha}.$

-   **Positive linear scaling an destination redistribution:**
    Similarly, Let $\alpha \in \mathbb{R}_{>0}$, $\omega \in \Omega$.
    Then for $r \in \mathcal{R}$: $$\begin{align*}
        (T_{\text{PLS}}^\alpha \circ T_{\text{DR}}^\omega)(r)
        &= \alpha(r + \omega)
        \\&= \alpha r + \alpha \omega
        \tag{$\alpha\omega \in \Omega$, vector subspace}
        \\&= (T_{\text{DR}}^{\alpha\omega} \circ T_{\text{PLS}}^\alpha)(r).
      \end{align*}$$ Thus,
    $T_{\text{PLS}}^\alpha \circ T_{\text{DR}}^\omega = T_{\text{DR}}^{\alpha\omega} \circ T_{\text{PLS}}^\alpha.$
    Equivalently,
    $T_{\text{DR}}^\omega \circ T_{\text{PLS}}^\alpha = T_{\text{PLS}}^\alpha \circ T_{\text{DR}}^{\omega/\alpha}.$

### Normal form via simplification uniqueness

Using the above identities, it is possible to dramatically simplify an
arbitrary finite composition of reward function transformations from any
of the families.

1.  First, we can apply the identities to rearrange the sequence so that
    all of the positive linear scaling transformations happen first
    (say), followed by all of the potential shaping transformations,
    followed by all of the destination redistribution transformations.

2.  From there, since the individual groups are closed under
    composition, we can simplify the three segments of the sorted
    sequence of transformations to one transformation each.

So, any finite composition can be achieved with just a single ordered
trio of transformations indexed by a triple
$(\alpha, \varphi, \omega) \in \mathbb{R}_{>0} \times \Phi \times \Omega$.
To close this section, let's prove that such simplifications are unique,
making this a normal form for reward function transformations in the
joined family.

It suffices to show that any trio of transformations that equals the
identity must be a trio of identity transformations: $$
  T_{\text{DR}}^\omega \circ T_{\text{PS}}^\varphi \circ T_{\text{PLS}}^\alpha = \text{id}
  \Longrightarrow 
  \omega = 0,\ \varphi=0,\ \alpha=1.
$$

So, then, suppose
$(\alpha, \varphi, \omega) \in \mathbb{R}_{>0} \times \Phi \times \Omega$
such that
$T_{\text{DR}}^\omega \circ T_{\text{PS}}^\varphi \circ T_{\text{PLS}}^\alpha = \text{id}$.
In other words, for $r \in \mathcal{R}$,
$(T_{\text{DR}}^\omega \circ T_{\text{PS}}^\varphi \circ T_{\text{PLS}}^\alpha)(r) = \text{id}(r)$.
That is, $$
  \alpha r + \partial\varphi + \omega = r.
  \tag{$\ast$}
  $$ In particular this identity holds at $r = 0$, giving us $$
  \partial\varphi + \omega = 0.
  \tag{$\dagger$}
  $$ It follows from ($\ast$) and ($\dagger$) that $\alpha r = r$, which
implies $\alpha = 1$. Moreover, from ($\dagger$) we have that
$\omega = -\partial\varphi$. This is an identity of two reward
functions. Fixing an arbitrary policy $\pi \in \Pi$, we can take the
value functions of both sides to get $$
    v^{\omega}_{\pi} = -v^{\partial\varphi}_{\pi}
    \tag{$\ddagger$}
  $$ where we have used linearity of expectation to extract the
negation. Recall that earlier, we showed that for a potential difference
reward function $\partial\varphi$, the value function is
$v^{\partial\varphi}_{\pi} = -\varphi$. On the other hand, for
transition-orthogonal reward functions, $v^{\omega}_{\pi} = 0$. Using
these two identities together with ($\ddagger$), we conclude that
$\varphi = 0$. It follows that $\partial\varphi = 0$, and then by
($\dagger$), we conclude that $\omega = 0$, as required.

## Some invariances of reinforcement learning

An **invariance** of the policy preorder is a reward function
transformation $T : \mathcal{R}\to \mathcal{R}$ that doesn't change the
policy preorder---for all $r \in \mathcal{R}$, $$
    {\preceq_r} \equiv {\preceq_{T(r)}}.
  $$

In this section, I show that transformations from the three families we
have studied in this note are invariances of the policy preorder. This
also means that any compositions of these transformations are
invariances. In turn, any reward function that can be reached from some
fixed starting reward function $r$ using these transformations has the
same policy preorder as $r$.

### Invariance to positive linear scaling

First, we'll show that the policy preorder is invariant to positive
linear scaling transformations. This is quite straightforward since the
evaluation function itself is linear in the reward.

Let $\alpha \in \mathbb{R}_{>0}$. Then for $\pi \in \Pi$ we have $$
  \mathcal{J}^{T_{\text{PLS}}^\alpha (r)}(\pi)
  = \mathcal{J}^{\alpha r}(\pi)
  = \alpha \mathcal{J}^{r}(\pi).
$$ Thus,
$\mathcal{J}^{T_{\text{PLS}}^\alpha(r)} = \alpha\mathcal{J}^{r}$.
Scaling $\mathcal{J}^{r}$ by a positive factor changes the evaluation
function, but preserves all ordinal comparisons between policies, so we
conclude $${\preceq_r} \equiv {\preceq_{T_{\text{PLS}}^\alpha(r)}}.$$

### Invariance to potential shaping

Next, we'll show that the policy preorder is invariant to potential
shaping transformations. Again, we use the linearity of the evaluation
function in the reward.

Let $\varphi \in \Phi$. Then for $\pi \in \Pi$ we have $$\begin{align*}
  \mathcal{J}^{T_{\text{PS}}^\varphi (r)}(\pi)
  &= \mathcal{J}^{r+\partial\varphi}(\pi)
  \\&= \mathcal{J}^{r}(\pi) + \mathcal{J}^{\partial\varphi}(\pi).
  \\&= \mathcal{J}^{r}(\pi) + \mathbb{E}_{s\sim\iota}\!\left[\,v^{\partial\varphi}_{\pi}(s)\,\right]
  \\&= \mathcal{J}^{r}(\pi) + \mathbb{E}_{s\sim\iota}\!\left[\,-\varphi(s)\,\right].
\end{align*}$$ Thus,
$\mathcal{J}^{T_{\text{PS}}^\varphi(r)} = \mathcal{J}^{r} + \mathbb{E}_{s\sim\iota}\!\left[\,-\varphi(s)\,\right]$.

Note that $\mathbb{E}_{s\sim\iota}\!\left[\,-\varphi(s)\,\right]$ is
constant with respect to the policy. Thus, while potential shaping
changes the evaluation function, it merely adds a constant, which again
preserves all ordinal comparisons between policies. We conclude
$${\preceq_r} \equiv {\preceq_{T_{\text{PS}}^\varphi(r)}}.$$

### Invariance to destination redistribution

Finally, we'll show that the policy preorder is invariant to destination
redistribution transformations. Once more we use linearity of the
evaluation function in the reward.

Let $\omega \in \Omega$. Then for $\pi \in \Pi$ we have $$\begin{align*}
  \mathcal{J}^{T_{\text{DR}}^\omega (r)}(\pi)
  &= \mathcal{J}^{r+\omega}(\pi)
  \\&= \mathcal{J}^{r}(\pi) + \mathcal{J}^{\omega}(\pi).
  \\&= \mathcal{J}^{r}(\pi) + \mathbb{E}_{s\sim\iota}\!\left[\,v^{\omega}_{\pi}(s)\,\right]
  \\&= \mathcal{J}^{r}(\pi) + \mathbb{E}_{s\sim\iota}\!\left[\,0\,\right]
  \\&= \mathcal{J}^{r}(\pi).
\end{align*}$$ Thus,
$\mathcal{J}^{T_{\text{DR}}^\omega(r)} = \mathcal{J}^{r}$.

In other words, destination redistribution doesn't even change the
policy evaluation function. We immediately conclude
$${\preceq_r} \equiv {\preceq_{T_{\text{DR}}^\omega(r)}}.$$

## All invariances of reinforcement learning

To close this note, let's explore a kind of converse result. For this
section, we assume that our fixed MDP has no unreachable states (that
is, we assume that all states have positive occupancy under some
policy).[^4]

Then, if a pair of reward functions $r_1, r_2$ shares a policy preorder,
then it is possible to reach $r_2$ from $r_1$ via some sequence of
transformations from our three families. In light of our normal form
result, this means that there is some $\alpha \in \mathbb{R}_{>0}$,
$\varphi \in \Phi$, $\omega \in \Omega$ such that $$
    r_2 = \alpha r_1 + \partial\varphi + \omega.
  $$

This tells us that any invariance of the policy preorder can be
described as a member of our joined family, or a pointwise selection of
these transformations.

This result needs a more involved proof, but we can break it down into a
sequence of interesting steps.

### Policies achieve all intermediate evaluations

First, we will show that for any two policies $\pi_1, \pi_2 \in \Pi$,
and any interpolation parameter $\lambda \in [0,1]$, there exists a
policy $\pi_\lambda
\in \Pi$ that, for all reward functions $r \in \mathcal{R}$, achieves an
evaluation of exactly $$
    \mathcal{J}^{r}(\pi_\lambda)
    = (1-\lambda) \mathcal{J}^{r}(\pi_1)
    + \lambda \mathcal{J}^{r}(\pi_2).
  $$ Note that the one policy $\pi$ is supposed to interpolate
evaluation for all reward functions, and this result is supposed to hold
despite policy evaluation not generally being linear in the choice of
policy.

We'll show this as a consequence of the linearity of evaluation in the
transition occupancy measure induced by the input policies. In fact, all
we need to prove is that the range of the map from policies to
transition occupancy measures is convex: for any policies
$\pi_1, \pi_2 \in \Pi$ and interpolation parameter $\lambda \in [0,1]$,
we can find a policy $\pi_\lambda \in \Pi$ such that $$
  \mu_{\pi_\lambda}
  = (1-\lambda) \mu_{\pi_1}
  + \lambda \mu_{\pi_2}.
$$ The main result then follows using the same $\pi_\lambda$, because
for any $r
\in \mathcal{R}$, $\mathcal{J}^{r}$ is linear in the induced occupancy
measure.

Without further ado, then, fixing $\pi_1$, $\pi_2$, and $\lambda$, we
must construct a policy $\pi_\lambda \in \Pi$ with the target transition
occupancy measure $$\mu = (1-\lambda)\mu_{\pi_1}+\lambda\mu_{\pi_2}.$$
Note that we don't yet know that this $\mu$ is an occupancy measure for
any policy. However, the definitions and identities of marginal
occupancy measures are linear, so we can coherently define
$\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu = (1-\lambda) \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_1} + \lambda \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_2}$,
and similarly for
$\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu$
and
$\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu$.
Then, we can interpolate the first factorisation identities and the flow
identities from $\mu_{\pi_1}$ and $\mu_{\pi_2}$ to obtain equivalent
identities for our target $\mu$: $$
  \mu(s,a,s') = \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s,a) \cdot \tau(s'\mid s,a),
  \qquad
  \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s) = \iota(s) + \gamma\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu(s).
$$

The second factorisation identities involve the policy, so we can't
interpolate those ones. However, they do inspire us to try putting $$
  \pi_\lambda(a | s)
  = \frac{\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s,a)}{\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s)}
  = \frac{
      (1-\lambda) \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_1}(s,a) + \lambda \mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_2}(s,a)
    }{
      (1-\lambda) \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_1}(s) + \lambda \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_2}(s)
    }
$$ for all $a \in \mathcal{A}$ for those $s \in \mathcal{S}$ such that
$\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s)>0$
(where
$\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s)=0$,
choose any action distribution). This gives us the desired factorisation
identity
$\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s,a) = \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s) \pi_\lambda(a | s)$
by construction (exercise in the case
$\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu(s)=0$).
It is also easy to check that $\pi_\lambda \in \Pi$ (exercise).

It only remains to show that $\mu_{\pi_\lambda} = \mu$, where on the LHS
here we mean the occupancy measure defined directly from $\pi_\lambda$.
This occupancy measure has its own marginals satisfying their own
factorisation and flow identities, from which we derive the equation $$
  \mu_{\pi_\lambda}(s,a,s')
  = (\iota(s)+\gamma\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi_\lambda}(s))
    \cdot \pi_\lambda(a\mid s)
    \cdot \tau(s'\mid s,a).
  \tag{$\ast$}
$$ On the other hand, the factorisation and flow identities we
constructed for our target interpolated occupancy measure $\mu$ give us
a similar equation $$
  \mu(s,a,s')
  = (\iota(s)+\gamma\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu(s))
    \cdot \pi_\lambda(a\mid s)
    \cdot \tau(s'\mid s,a).
  \tag{$\dagger$}
$$

The only difference between ($\ast$) and ($\dagger$) is the occupancy
measure. We'll show that this system of equations has a unique solution,
so the two occupancy measures must coincide. Subtracting
$(\ast) - (\dagger)$ gives us, for each $s,a,s'$, $$
  \mu_{\pi_\lambda}(s,a,s') - \mu(s,a,s')
  = \gamma
    \cdot (\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi_\lambda}(s) - \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu(s))
    \cdot \pi_\lambda(a\mid s)
    \cdot \tau(s'\mid s,a).
$$ Since $\gamma$, $\pi_\lambda$, and $\tau$ are non-negative, taking
absolute values gives us $$
  \left|\mu_{\pi_\lambda}(s,a,s') - \mu(s,a,s')\right|
  = \gamma
    \cdot \left|\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi_\lambda}(s) - \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu(s)\right|
    \cdot \pi_\lambda(a\mid s)
    \cdot \tau(s'\mid s,a).
$$

The above identities hold for all transitions $s,a,s'$. If we sum over
transitions we can unify the probability terms and $$\begin{align*}
  &\hspace{-2em}
  \sum_{s,a,s'}\left|\mu_{\pi_\lambda}(s,a,s') - \mu(s,a,s')\right|
\\
  &= \gamma
    \sum_s \left|\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi_\lambda}(s) - \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu(s)\right|
    \sum_a \pi_\lambda(a\mid s)
    \sum_{s'} \tau(s'\mid s,a)
\\
  &= \gamma
    \sum_s \left|\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi_\lambda}(s) - \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu(s)\right|
  \tag{$\tau,\pi_{\lambda}$ probabilities}
\\
  &= \gamma
    \sum_{s'} \left|\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi_\lambda}(s') - \mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu(s')\right|
  \tag{rename $s$ to $s'$}
\\
  &= \gamma
    \sum_{s'} \left| \sum_s \sum_a (\mu_{\pi_\lambda}(s,a,s') - \mu(s,a,s'))\right|
  \tag{expand $\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu_{\pi_\lambda}$ and $\mathrlap{\rule[-0.44em]{0.55em}{0em}}\mathrlap{\rule[-0.31em]{0.55em}{0em}}\mu$}
\\
  &\leq \gamma
    \sum_{s,a,s'} \left| \mu_{\pi_\lambda}(s,a,s') - \mu(s,a,s')\right|.
  \tag{triangle inequality}
\end{align*}$$

Since $\gamma<1$, this sum of absolute differences between the entries
of $\mu_{\pi_\lambda}$ and of $\mu$ must be zero. Thus
$\mu_{\pi_\lambda} = \mu$, as required.

### Preserving the preorder implies positive affine evaluation change

Next, we'll prove another intermediate result. We previously showed that
our reward function transformations are invariances because their effect
was to positively rescale the evaluation function or shift it by a
constant, preserving the policy preorder. It turns out that any reward
transformation that preserves the policy preorder must only induce a
similar (positive affine) change in the evaluation function.

Formally, let $r_1, r_2 \in \mathcal{R}$. Abbreviate
$J_1 = \mathcal{J}^{r_1}$ and $J_2 = \mathcal{J}^{r_2}$. Then, the claim
is that ${\preceq_{r_2}} \equiv {\preceq_{r_1}}$ implies
$J_2 = a J_1 + b$ for some $a \in \mathbb{R}_{>0}$ and
$b \in \mathbb{R}$.

To show this, define a **best policy** $\pi_{+}$ and a **worst policy**
$\pi_{-}$ by $$
  \pi_{+} \in \argmax_{\pi\in\Pi}J_1(\pi),
  \qquad
  \pi_{-} \in \argmin_{\pi\in\Pi}J_1(\pi).
  $$ Such extremal policies exist because policy space is compact and
evaluation is continuous. Due to the shared policy preorder, these
policies are also extremal for $J_2$.

In case the evaluations of the best and worst policies are equal, it
must be that $J_1$ is constant. Since $J_2$ has the same preorder, it
must also be constant. Then, set $$
  b = J_2(\pi_{+}) - J_1(\pi_{+}),
  \qquad
  a = 1.
  $$

Otherwise, $J_1(\pi_{+}) > J_1(\pi_{-})$ (and
$J_2(\pi_{+}) > J_2(\pi_{-})$). Let $\pi \in \Pi$. Its evaluation lies
somewhere between those of the worst and best policies. Let
$\lambda \in [0,1]$ be the interpolation constant such that $$
  J_1(\pi) = (1-\lambda) J_1(\pi_{-}) + \lambda J_1(\pi_{+}).
  \tag{$\ast$}
$$ By our previous interpolation result, there exists a policy
$\pi' \in \Pi$ achieving this same interpolation of the worst and best
policies under all reward functions, including in particular $r_1$ and
$r_2$: $$\begin{align*}
  J_1(\pi')
  &= (1-\lambda)J_1(\pi_{-}) + \lambda J_1(\pi_{+}),
  \tag{$\dagger$}
  \\
  J_2(\pi')
  &= (1-\lambda)J_2(\pi_{-}) + \lambda J_2(\pi_{+}).
  \tag{$\ddagger$}
\end{align*}$$ By ($\ast$) and ($\dagger$), we have
$J_1(\pi) = J_1(\pi')$, an evaluation tie under $r_1$. Since $r_2$
induces the same policy preorder, the same must be true under $r_2$,
that is, $J_2(\pi) = J_2(\pi')$. By ($\ddagger$) we then conclude $$
  J_2(\pi) = (1-\lambda)J_2(\pi_{-}) + \lambda J_2(\pi_{+}).
  \tag{$\star$}
$$ In other words, the evaluation of $\pi$ occupies the same relative
position between that of the worst and best policies under $r_2$ as it
did under $r_1$. We can rearrange ($\ast$) and ($\star$) to eliminate
$\lambda$ and solve for $J_2(\pi)$ in terms of $J_1(\pi)$ in order to
identify the appropriate positive affine transformation, resulting in:
$$
  a = \frac{J_2(\pi_{+}) - J_2(\pi_{-})}{J_1(\pi_{+}) - J_1(\pi_{-})},
  \qquad
  b = J_2(\pi_{-}) - a J_1(\pi_{-}).
$$

### Positive affine evaluation change implies a joint transformation

We conclude that ${\preceq_{r_2}} \equiv {\preceq_{r_1}}$ implies
$\mathcal{J}^{r_2} = a \mathcal{J}^{r_1} + b$ for some
$a \in \mathbb{R}_{> 0}$, $b \in \mathbb{R}$. Finally, in this section,
we show that if all states are reachable, then
$\mathcal{J}^{r_2} = a \mathcal{J}^{r_1} + b$ implies we can find
$\alpha \in \mathbb{R}_{>0}$, $\varphi \in \Phi$, and
$\omega \in \Omega$ such that
$r_2 = \alpha r_1 + \partial\varphi + \omega$.

Let's try the following construction. Let $\tilde\pi \in \Pi$ be the
uniform policy, and then set $$\begin{align*}
  \alpha
    &= a \in \mathbb{R}_{>0},
  &&&
  \varphi
    &= -v^{r_2-\alpha r_1}_{\tilde\pi} \in \Phi
  &&&
  \omega
    &= r_2 - \alpha r_1 - \partial\varphi \in \mathcal{R}.
\end{align*}$$ Note that $r_2 = \alpha r_1 + \partial\varphi + \omega$
by construction. Thus, it only remains to show transition-orthogonality
of $r_2 - \alpha r_1 - \partial\varphi$ (which we have called $\omega$
in anticipation of this property). That is, we must show that for all
$s,a$, we have
$\mathbb{E}_{s'\sim\tau(s,a)}\!\left[\,\omega(s,a,s')\,\right] = 0$.

First, let us explore the reward and potential function from which
$\omega$ is constructed. Abbreviating $r_2 - \alpha r_1 = r_3$, note
that this scaled difference reward function isolates the evaluation
constant: $$
    \mathcal{J}^{r_3}
    = \mathcal{J}^{r_2 - \alpha r_1}
    = \mathcal{J}^{r_2} - \alpha \mathcal{J}^{r_1}
    = a \mathcal{J}^{r_1} + b - a \mathcal{J}^{r_1}
    = b.
  $$

Moreover, our potential function $\varphi$ is defined as the negative
value of states for the uniform policy under this reward function $r_3$.
The value of the corresponding potential difference reward
$\partial\varphi$ is then equal to this reference value function, $$
    v^{\partial\varphi}_{\pi}
    = -\varphi
    = v^{r_3}_{\tilde\pi},
  $$ and its evaluation function is itself constant: for $\pi \in \Pi$,
$$
    \mathcal{J}^{\partial\varphi}(\pi)
    = \mathbb{E}_{s\sim\iota}\!\left[\,v^{\partial\varphi}_{\pi}(s)\,\right]
    = \mathbb{E}_{s\sim\iota}\!\left[\,-\varphi(s)\,\right]
    = \mathbb{E}_{s\sim\iota}\!\left[\,v^{r_3}_{\tilde\pi}(s)\,\right]
    = \mathcal{J}^{r_3}(\tilde\pi)
    = b.
  $$

Turning to $\omega = r_3 - \partial\varphi$, the above properties plus
linearity of value/evaluation in the reward allow us to conclude two
things. First, the uniform policy's value function is zero at every
state. Second, the evaluation function is zero for every policy. To wit:
$$\begin{align*}
  v^{\omega}_{\tilde\pi}
  &=v^{r_3-\partial\varphi}_{\tilde\pi}
  &\qquad
  \mathcal{J}^{\omega}(\pi)
  &=\mathcal{J}^{r_3-\partial\varphi}(\pi)
  \\
  &=v^{r_3}_{\tilde\pi} - v^{\partial\varphi}_{\tilde\pi}
  &
  &=\mathcal{J}^{r_3}(\pi)-\mathcal{J}^{\partial\varphi}(\pi)
  \\
  &=v^{r_3}_{\tilde\pi} -v^{r_3}_{\tilde\pi}
  &
  &=b-b
  \\
  &=0;
  &
  &=0.
\end{align*}$$

The vanishing value function for the uniform policy is helpful because
we can combine this with the Bellman equation to conclude that for every
state $s \in \mathcal{S}$, $$
  \mathbb{E}_{a\sim\tilde\pi(s)}\!\left[\,
    \mathbb{E}_{s'\sim\tau(s,a)}\!\left[\,\omega(s,a,s')\,\right]
  \,\right]=0.
  \tag{$\ast$}
$$ This ($\ast$) is not quite enough: we still need to remove the
averaging over actions and show that the inner expectation is zero for
every state--action pair. But it will help when combined with the zero
evaluation for all policies. Now we can isolate the contribution to the
evaluation of increasingly taking an arbitrary action
$a_\star \in \mathcal{A}$ in an arbitrary state
$s_\star \in \mathcal{S}$. Define $\pi_\star \in \Pi$ to agree with
$\tilde\pi$ in all other states, but mix the action distribution in
state $s_\star$ towards $\delta_{a_\star}$ by some
$\varepsilon \in (0,1)$: $$
  \pi_\star(s_\star)
  = (1-\varepsilon)\tilde\pi(s_\star)
  + \varepsilon \delta_{a_\star}.
$$

Because the uniform policy has zero value, the difference in evaluating
this policy compared to the uniform policy comes from the expected
immediate reward of the chosen action
$\mathbb{E}_{s' \sim \tau(s_\star,a_\star)}\!\left[\,\omega(s_\star,a_\star,s')\,\right]$.
Because the evaluation nevertheless remains zero, this expected reward
must vanish. Formally, $$\begin{align*}
  0
  &=\mathcal{J}^{\omega}(\pi_\star)
  \\
  &= \sum_{s,a,s'} \mu_{\pi_\star}(s,a,s') \omega(s,a,s')
  \\
  &= \sum_{s,a,s'}
    \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s)
    \pi_\star(a|s)
    \tau(s'|s,a)
    \omega(s,a,s')
  \tag{factorisation}
  \\
  &= \sum_s
    \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s)
    \mathbb{E}_{a\sim\pi_\star(s)}\!\left[\,
      \mathbb{E}_{s'\sim\tau(s,a)}\!\left[\,\omega(s,a,s')\,\right]
    \,\right]
  \\
  &= \sum_{s\neq s_\star}
    \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s)
    \mathbb{E}_{a\sim\tilde\pi(s)}\!\left[\,
      \mathbb{E}_{s'\sim\tau(s,a)}\!\left[\,\omega(s,a,s')\,\right]
    \,\right]
  \\
  &\qquad
    + (1-\varepsilon)
      \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s_\star)
      \mathbb{E}_{a\sim\tilde\pi(s_\star)}\!\left[\,
        \mathbb{E}_{s'\sim\tau(s_\star,a)}\!\left[\,\omega(s_\star,a,s')\,\right]
      \,\right]
  \\[1ex]&\qquad
    + \varepsilon
      \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s_\star)
        \mathbb{E}_{s'\sim\tau(s_\star,a_\star)}\!\left[\,\omega(s_\star,a_\star,s')\,\right]
  \\[1ex]
  &= \sum_{s\neq s_\star}
    \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s) \cdot 0
    + (1-\varepsilon)
      \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s_\star)
      \cdot 0
  \tag{by $\ast$}
  \\[1ex]&\qquad
    + \varepsilon
      \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s_\star)
        \mathbb{E}_{s'\sim\tau(s_\star,a_\star)}\!\left[\,\omega(s_\star,a_\star,s')\,\right]
  \\[1ex]
  &=\varepsilon
    \mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s_\star)
    \mathbb{E}_{s'\sim\tau(s_\star,a_\star)}\!\left[\,\omega(s_\star,a_\star,s')\,\right].
\end{align*}$$ Note that reachability and $\gamma > 0$ ensure that
$\mathrlap{\rule[0.68em]{0.55em}{0em}}\mathrlap{\rule[0.55em]{0.55em}{0em}}\mu_{\pi_\star}(s_\star) > 0$,
since this mixture policy takes all actions with positive probability.
Therefore, since also $\varepsilon > 0$, we must have $$
  \mathbb{E}_{s'\sim\tau(s_\star,a_\star)}\!\left[\,\omega(s_\star,a_\star,s')\,\right]=0.
$$ Since $s_\star, a_\star$ were arbitrary, we conclude
$\omega \in \Omega$.

### Characterising all invariances

The above result shows that any two reward functions sharing a policy
preorder can be related by a joint transformation. However, an
invariance of the policy preorder need not apply the same joint
transformation to all input reward functions. If not, the invariance
might fail to equal any single joint transformation for all reward
functions.

However, we have effectively shown that any invariant transform will
equal a joint transformation *pointwise.* Formally, we have the
following characterisation of the invariances of the policy preorder.
Assume, again, that our fixed MDP has no unreachable states. Then
$T : \mathcal{R}\to \mathcal{R}$ is an invariance of the policy preorder
*if and only if* there exists a per-reward scalar
$\alpha : \mathcal{R}\to \mathbb{R}_{>0}$, a per-reward potential
function $\varphi : \mathcal{R}\to \Phi$, and a per-reward
transition-orthogonal reward function $\omega : \mathcal{R}\to \Omega$
such that for all $r \in \mathcal{R}$, $$
    T(r) = \alpha(r) \cdot r + \partial \bigl(\varphi(r)\bigr) + \omega(r).
  $$

The forward proof follows by applying the pointwise result to every
input reward function $r_1 = r$ and the corresponding $r_2 = T(r)$,
which share a policy preorder as $T$ is an invariance.

Conversely, any such $T$ is an invariance, because invariance is defined
pointwise and for $r \in \mathcal{R}$, the concrete joint transformation
indexed by $(\alpha(r), \varphi(r), \omega(r))
  \in \mathbb{R}_{>0} \times \Phi \times \Omega$ preserves the policy
preorder. (This direction doesn't require reachability.)

## Conclusion

That's probably much more detail than you needed about reward function
transformations. I will close briefly with some notes on why I cared
enough to write this.

First, my colleague Miguel and I have been studying the related topic of
*reward function canonicalisation,* which is the study of maps that
standardise reward functions to remove the effects of the above reward
function transformations. This matters for all sorts of things; if you
think you have two different reward functions, you ought to know if they
have real differences that would affect their preferences between
different policies, or if they only differ by positive linear scaling,
potential shaping, or destination redistribution. We're gearing up to
write some results about this, and I wanted to review what we know about
these transformations to begin with before tackling that writeup.

Second, ever since I wrote that first paper on characterising
invariances with Joar Skalse, I haven't been at ease with the way we set
up the definition of reward function transformations. In this note,
several years later, I feel immense satisfaction that I finally got to
the bottom of my unease by realising that it was about the difference
between explicit and implicit definitions of the transformations. This
time, I put a name on the data of the transformations, especially the
data specifying a destrination redistribution transformation (the
transition-orthogonal reward function; it's fairly commonplace to refer
to the scale factor or the potential function), as well as naming the
potential difference function as a reward function in its own right. I
feel like this move immediately levelled up my ability to understand
these transformations and their properties. Names are power. Or, you
could say, infrastructure is everything.

On a somehow-related note, I should acknowledge that some parts of the
proofs in this post, especially in the final section, were developed
with the assistance of ChatGPT 6 Astra. I am happy to admit that it
saved me a lot of trouble understanding the space of possible arguments,
and proud to say that I was still able to contribute a lot to refining
the proofs into their present, fairly direct form with minimal,
carefully-chosen notation. Any remaining mistakes are my own.

## References

Ng, Harada, and Russell, 1999, "Policy invariance under reward
transformations: Theory and application to reward shaping," ICML.

Skalse, Farrugia-Roberts, Russell, Abate, and Gleave, 2023, "Invariance
in Policy Optimisation and Partial Identifiability in Reward Learning,"
ICML.

Skalse and Abate, 2023, "Misspecification in Inverse Reinforcement
Learning," AAAI.

[^1]: This intuition ignores the inclusion of the discount rate in the
    expression $\gamma \varphi(s') - \varphi(s)$. This is the same
    intuitive motivation as Ng, Harada, and Russell (1999) in the
    original paper. Unfortunately, they don't seem to offer an intuitive
    reason why the discount rate should be there. Mathematically, it
    clearly needs to be there for everything to work out (as we'll see
    when discussing the properties of these terms). It also pleasingly
    mirrors the value function difference expression in the temporal
    difference error: $$
      \delta = r(s,a,s') + \gamma v(s') - v(s).
    $$ Regrettably, I don't actually have a great intuition for this
    inclusion myself.

[^2]: In Skalse, Farrugia-Roberts, et al. (2023), we introduced this
    family of transformations under the name *$S'$-redistribution.* I
    regret that choice of name: I am more cautious about including
    mathematical expressions in terminology I want to use beyond one
    paper, because terminology should be agnostic to notation choices
    and self-documenting. So, I now propose to call this family
    *destination redistribution.*

[^3]: Indeed, I *also regret* the way we defined destination
    redistribution transformations in the original paper. I think we
    should have used the definition I use in this note, because it's
    more explicit about what different transformations are possible.

    Translating into the notational conventions of this note, here's how
    we wrote the definition:

    > **Definition 2.6** ($S'$-Redistribution)**.** Let $r_1$ and $r_2$
    > be reward functions. Given transition dynamics $\tau$, we say that
    > $r_2$ is produced by *$S'$-redistribution* of $r_1$ if
    > $$\mathbb{E}_{S' \sim \tau(s,a)}\!\left[\,r_1(s,a,S')\,\right]
    > = \mathbb{E}_{S' \sim \tau(s,a)}\!\left[\,r_2(s,a,S')\,\right].$$
    >
    > $S'$-redistribution is simply any transformation that preserves
    > $\mathbb{E}_{S' \sim \tau(s,a)}\!\left[\,r(s,a,S')\,\right]$.

    This definition makes it easy to check if two reward functions can
    be related by an destination redistribution, but leaves the actual
    transformations entirely implicit. In this note, I prefer to start
    with the redistribution scheme and explicitly define the
    transformations and the family in these terms, and then from that
    derive the conditions under which you can see that two reward
    functions are relatable. This then mirrors the situation for
    positive linear scaling and potential shaping, and makes it easier
    later to talk about canonicalisation.

    The definition for destination redistribution I propose in this note
    is actually subtly different than the implicit definition in the
    original paper. There, you can have transformations that use
    different ways of redistributing reward for different reward
    functions. In my new definition, you insist that a given
    transformation redistributed reward the same way regardless of which
    reward functions it is being applied to. This is actually also the
    case for the paper's implicit definitions of potential shaping and
    positive linear scaling, compared to the definitions I give here.
    This means that the paper's definitions are more expressive.

    Fortunately, from the perspective of characterising the sets of
    reward functions that have equivalent policy preorders, this
    difference doesn't matter. Both the implicit, more expressive
    definitions and the explicit, less expressive definitions of the
    family of transformations induce the same partitions on the space of
    reward functions, because these partitions only depend on pointwise
    transformability. I touch on this in the penultimate section of the
    post.

[^4]: It is fairly common for an MDP to have unreachable states,
    particularly before a distribution shift. This may create additional
    invariances since rewards in unreachable states do not affect the
    evaluation function. Skalse et al. (2023) characterise these
    invariances by a mask operation that can pin the reward assigned to
    any unreachable transition to any fixed value. I omit treatment of
    this kind of invariance because I think it's less interesting than
    the three families we have studied. However, that's not to say it
    isn't practically relevant: if there are parts of your environment
    that are unreachable, then you have no control over the reward
    function there, and this can matter if those parts of the
    environment eventually become reachable.
