Counterfactual reasoning (asking what would have happened, had a decision been different) is a powerful tool for identifying causes of failure and explaining the behaviour of AI systems in sequential decision-making tasks. In Markov Decision Processes (MDPs), two sources of uncertainty complicate counterfactual inference: statistical uncertainty in the MDP transitions when the MDP is estimated from trajectory data, and uncertainty about the unknown causal model, as there are multiple structural causal models (SCMs) compatible with each MDP. Existing work addresses these two challenges in isolation. We address both simultaneously by introducing a framework for partial counterfactual inference in MDPs that is robust to both statistical and causal uncertainty. Our approach provides: 1) closed-form analytical bounds for the counterfactual probabilities that are valid across all SCMs entailed by a given interval MDP (IMDP); 2) a method to compute minimal robust interventions to achieve a desired counterfactual outcome via pessimistic value iteration on the induced counterfactual IMDP. Since the latter is constructed using our analytical bounds, our approach remains efficient and scalable to realistic MDP environments. Experiments across multiple case studies demonstrate our method's robustness and practical utility for identifying minimal sets of actions that, if changed, would have led to improved outcomes.
Markov Decision Processes (MDPs) are a fundamental model for describing sequential decision-making processes under uncertainty, including reinforcement learning (RL) problems. Counterfactual reasoning for MDPs is central to policy evaluation, explanation, and accountability. Given an observed MDP path, i.e., a state-action sequence, one may ask: Would a different sequence of actions have led to a different outcome? Such questions arise in numerous applications, such as generating counterfactual explanations [23, 29, 30], facilitating policy transfer [15], data augmentation with counterfactual paths [18, 28], as well as LLM counterfactuals [4, 25].
However, two distinct sources of uncertainty complicate counterfactual reasoning for MDPs. First, counterfactuals in MDPs are generally not point-identified: many structural causal models (SCMs) can be compatible with the MDP, each yielding different counterfactual outcomes. We call this causal uncertainty. Yet, many approaches assume a fixed SCM, typically a Gumbel-max SCM [2, 14, 15, 22, 29, 33], potentially leading to invalid counterfactual conclusions. Second, the transition probabilities of an MDP are often estimated from finite trajectory data. Yet, most counterfactual analyses treat these point estimates as precise probabilities, ignoring statistical uncertainty in the learned MDP.
Recent work by Lally et al. [17] addresses the causal uncertainty problem by bounding counterfactual probabilities across all SCMs consistent with the MDP. Also, there is a well-established line of research (e.g., [21, 26, 27]) on capturing statistical uncertainty by using uncertain MDPs, where each transition probability lies within a data-derived confidence set, most often an interval (yielding interval MDPs).
However, there is no work to date that addresses both kinds of uncertainty, even though both matter for identifying robust interventions and explanations. Consider a learned model for sepsis treatment. Suppose that, under a nominal transition estimate, changing the dosage at step t prevents an adverse outcome. So we would conclude that action at is a sufficient intervention to prevent that outcome, but only if the transition probabilities were precise. Since these are learned from data and subject to sampling variability, there could be alternative models supported by the data where the adverse outcome would have occurred regardless of the dosage at t, i.e., where intervening on at alone is not enough. Thus, we seek counterfactual interventions that are robust to statistical uncertainties, i.e., valid across all MDP models entailed by some data-derived confidence set. For a similar reason, since there are many SCM models compatible with an MDP, we want such interventions to be robust to causal uncertainty, because each SCM can yield different counterfactual probabilities and thus different counterfactual policies that would have led to the patient's recovery.
In this paper, we develop a framework for robust counterfactual reasoning in uncertain MDPs. Our contributions span two main areas:
Counterfactual bounds for uncertain MDPs. We derive analytical bounds for the counterfactual transition probabilities of a given interval MDP (IMDP). Our bounds are robust to both sources of uncertainty in this setting: they are guaranteed to include the true (unknown) counterfactual probabilities for every MDP M entailed by the IMDP, and every SCM compatible with M. To achieve this, we build on the work of Lally et al. [17], who derived bounds on counterfactual probabilities for standard (certain) MDPs, and extend it – for the first time – to the uncertain MDP setting. Crucially, without our analytical characterisation, computing robust counterfactual probabilities becomes prohibitive, as it entails solving an optimisation problem with a number of constraints exponential in the size of the MDP [7, 31, 32]. Finally, we prove that our analytical bounds are exact (i.e., tight) in all but one case. For this remaining case, we provide conservative (i.e., sound) bounds that remain empirically efficient. As a contribution of independent interest, we further derive conservative bounds for the special (parametric) case of Gumbel-max causal models.
Minimal robust counterfactual interventions. Building on these bounds, we define the notion of a minimal robust counterfactual intervention as an MDP policy that performs the smallest set of action changes to induce a desired counterfactual outcome across all the causal models induced by statistical and causal uncertainty. In our MDP setting, w.l.o.g., we define outcomes as constraints over the (counter)factual path's expected return. Given an IMDP estimated from data and an observed path, to derive such robust interventions, our method first constructs a counterfactual IMDP by computing bounds for all its transitions; then, interventions are found as solutions to a robust value iteration procedure [20] modified so that its value function keeps track of the allowed number of action changes. Finally, we evaluate our approach on a variety of MDP environments to investigate sources of failure in suboptimal RL policies, demonstrating that our method remains accurate and robust to uncertainty in both the MDP transitions and the causal model.
2 Background
In this section, we outline the background connecting Markov Decision Processes (MDPs), structural causal models (SCMs), and counterfactual inference.
2.1 Markov Decision Processes
MDPs model sequential decision-making under uncertainty: at each time t, an agent in state st selects an action at via a policy π, transitions to st+1∼P(⋅∣st,at), and receives reward R(st,at). Formally, an MDP is a tuple M=(S,A,P,PI,R), where S is the discrete state space, A the set of actions, P:(S×A)→Δ(S) the transition probability function, PI∈Δ(S) the initial state distribution, and R:(S×A)→R the reward function.
A (deterministic) policy π for M is a function π:S→A. A path τ of M under policy π is a sequence τ=(s0,a0,s1,a1,…,sT−1,aT−1,sT) where T=∣τ∣ is the path length, PI(s0)>0, at=π(st) for all t=0,…,T−1, and P(st+1∣st,at)>0 for all t=0,…,T−1.
While MDPs can model a wide range of real-world decision-making problems [8], it is often challenging to determine the transition probability function P exactly. To address this, uncertain MDPs allow us to explicitly account for uncertainty in the transition dynamics. In particular, interval MDPs represent this uncertainty through lower and upper bounds on the transition probabilities.
Definition 2.1 (Interval MDP [6]). An Interval Markov Decision Process (IMDP) is a tuple M↑=(S,A,P↑,PI,R), where S,A,PI, and R are as in a standard MDP, and P↑ is an uncertain transition function: for all s,s′∈S and a∈A there exist bounds 0≤PM↑LB(s′∣s,a)≤PM↑UB(s′∣s,a)≤1 such that P↓(s′∣s,a)=[PM↑LB(s′∣s,a),PM↑UB(s′∣s,a)].
2.2 Counterfactual Inference
Structural causal models (SCMs) [12, 24] provide a mathematical framework for reasoning about causality and counterfactual inference. Formally, a SCM is a tuple C=(U,V,F,P(U)), where
Figure 1: MDP causal graph. White nodes are the endogenous variables; grey nodes are the exogenous variables.
V is the set of endogenous (observed) variables, U is a set of exogenous (unobserved) variables, P(U) is a joint distribution over each U∈U, and F is a set of structural equations such that each fV∈F determines the value of variable V∈V as a function of UV∈U and of V's endogenous parents PAV⊆V. An intervention (denoted do(X=x)) modifies the SCM by fixing one or more variables X⊆V to specific values x and severing their dependence on their respective parents PAX in the causal graph; combined with the original P(U) this yields an interventional distribution over the remaining variables. Counterfactual inference follows the same procedure, except it infers a posterior P(U∣v) over the values of the exogenous variables consistent with a given observation v, and then applies the intervention do(X=x) using P(U∣v) in place of P(U), yielding a distribution over the counterfactual outcomes.
2.3 Counterfactual Inference in MDPs
An MDP can be represented as an SCM with the causal graph of Figure 1 and the following structural equations:
The exogenous variables Ut capture all sources of randomness in the MDP, rendering the structural equations deterministic (given Ut). In this setting, the interventional distribution P(St+1(St←s,At←a)=s′) corresponds to the MDP's transition probabilities P(⋅∣s,a) and observations are paths τ=(s0,a0,…,sT−1,aT−1,sT) of length T.
Counterfactual inference is applied at the level of the individual timesteps: given the observed transition st,at→st+1 at time t, we first infer the posterior distribution over the exogenous variable Ut consistent with this observation, P(Ut∣St=st,At=at,St+1=st+1). We then use this posterior to evaluate the counterfactual probability of reaching outcome St+1=s~′, had we been in state St=s~, and instead performed action At=a~. Formally, we define this counterfactual probability as P~t(s~′∣s~,a~)=P(St+1(St←s~,At←a~)=s~′∣St=st,At=at,St+1=st+1) where St+1(St←s~,At←a~) denotes variable St+1 in the SCM after the intervention St←s~ and At←a~.
These single-timestep counterfactual probabilities can be combined across all timesteps to construct a non-stationary counterfactual MDP [29], allowing us to reason about counterfactual outcomes over an entire trajectory.
Definition 2.2 (Counterfactual MDP (CFMDP)). Given an MDP M, a corresponding SCM C of the form (1) (i.e., one whose interventional distribution matches the transition probabilities of M), and an observed path τ=(s0,a0,s1,a1,…,sT−1,aT−1,sT), the corresponding counterfactual MDP is a non-stationary MDP M~τ=
(S,A,P~,P~I,R) where P~I(s0)=1 and the time-dependent transition kernel is given, for any t∈{0,…,∣τ∣−1}, by P~t(s′∣s~,a~)=P(St+1(St=s~,At=a~)=s~′∣St=st,At=at,St+1=st+1).
In addition to enabling predictions under hypothetical scenarios, counterfactual inference lets us identify the factors that were causally responsible for an observed outcome. In an MDP, an RL agent controls the outcome through its actions, so these factors correspond to the actions selected by the agent's policy. The CFMDP M~τ lets us evaluate how the outcome would have changed under different actions, and therefore identify the fewest changes to the observed actions that would have led to a better outcome. However, constructing M~τ requires knowing both the MDP M and its corresponding SCM C, which is rarely the case; most often we face both statistical and causal uncertainty, which we address in the following sections.
3 Counterfactual Inference in Uncertain MDPs
We first review how Zhang et al. [32]'s partial counterfactual inference approach applies to MDPs, and how Lally et al. [17] build on this to derive closed-form bounds on counterfactual MDP probabilities. We then extend these bounds to IMDPs, forming the basis of our robust counterfactual inference framework.
3.1 Canonical SCMs
To address the problem of causal model unidentifiability, Zhang et al. [32] introduce a family of canonical SCMs that can simultaneously capture all possible counterfactual probability distributions across all compatible causal models. They show how to optimise over these canonical SCMs to find the SCMs that minimise and maximise counterfactual probabilities, yielding tight bounds.
Lally et al. [17] construct canonical SCMs for MDPs. Specifically, given a known MDP M (with a known transition function PM), the first step is to associate each value of the exogenous variable ut∈Ut with a unique deterministic mapping f:S×A×U→S that defines the next state for every state-action pair. Since there are finitely many such mappings 1, this gives ∣Ut∣=∣S∣∣S∣×∣A∣. This mapping is represented by an indicator variable μ∈{0,1}∣S∣×∣A∣×∣Ut∣×∣S∣ such that, for any s,a,ut,s′:
μs,a,ut,s′={10iff(s,a,ut)=s′otherwise.
That is, μs,a,ut,s′=1 when the mapping associated with ut leads to the next state s′ from state-action pair (s,a). Next, we define a vector θ∈R∣Ut∣, where each θut represents the probability P(Ut=ut). Each instantiation of θ defines a unique SCM. Given an observed transition st,at→st+1, we can express the counterfactual probability P~M,t(s′∣s,a) of any transition s,a→s′ in terms of μ and θ as follows:
To obtain bounds [P~M,tLB(s′∣s,a),P~M,tUB(s′∣s,a)] on the counterfactual transition probabilities, we optimise over all values of θ (note that μ is fixed and is not optimised over) consistent with the observed transition and interventional data (i.e., the MDP transition probabilities). This results in the following optimisation problem (omitting the constant denominator in (2) from the objective):
Lally et al. [17] prove that, in MDP settings, this optimisation problem reduces to exact, closed-form expressions. These bounds also incorporate two key assumptions, counterfactual stability and counterfactual monotonicity, to avoid unintuitive counterfactual probabilities. Without these assumptions, the optimisation in (3)-(5) tends to produce loose or trivial [0, 1] bounds, which compound over multiple transitions in sequential decision-making and reduce the usefulness of counterfactual inference.
Counterfactual stability is a standard assumption in the literature [23, 29] and states that the outcome under an intervention changes only if the relative probability of some other outcome increases relative to the observed outcome. Counterfactual monotonicity ensures that observing an outcome cannot make it less likely in the counterfactual setting, and that unobserved (but possible) outcomes cannot become more likely. Formal definitions and the resulting bounds are in Appendix A.
3.3 Extending the Bounds to IMDPs
To extend these counterfactual probability bounds to IMDPs, we generalise the optimisation problem in (3)-(5) as follows. Let M↑ denote an arbitrary IMDP. For a given counterfactual transition s,a→s′ and observed transition st,at→st+1, the upper and lower bounds P~M↑,tUB(s′∣s,a) and P~M↑,tLB(s′∣s,a) are obtained by solving
subject to constraints (4) and (5), and crucially ensuring that M is a valid MDP within the IMDP's uncertainty set, i.e., ∀s,a,∑s′∈SPM(s′∣s,a)=1. Since closed-form expressions for the counterfactual bounds are already available for a fixed MDP M, the optimisation over the IMDP reduces to optimising these bounds over all admissible MDPs:
This formulation enables us to derive closed-form expressions for the counterfactual probability bounds. Without it, computing these bounds would require solving (6) directly: a joint optimisation over admissible MDPs M∈M↑, and over θ (whose cardinality is exponential in the size of the state and action spaces). However, deriving these closed-form expressions requires more than simply optimising the closed-form MDP bounds of Lally et al. [17] independently over each probability interval: the resulting extremal values must
1Wlog, Zhang et al. [32] prove that for SCMs with categorical endogenous variables, the exogenous distributions can be represented by discrete, finite variables.
also be simultaneously achievable by a single, valid MDP M∈M↑, which makes extending their bounds to IMDPs non-trivial.
The exact closed-form expression depends on whether the counterfactual state-action pair (s,a) and the observed state-action pair have disjoint or overlapping support: in the IMDP setting, we say (s,a) has disjoint support from the observed (st,at) if their supports are disjoint for every admissible MDP M∈M↑; otherwise, they have overlapping support. The resulting closed-form bounds are summarised in Table 1, using ps,aLB(s′) as shorthand for PM↑LB(s′∣s,a) and ps,aUB(s′) for PM↑UB(s′∣s,a), for all s,a,s′; full theorem statements and proofs are given in Appendix B.
Proof Sketch. Consider an observed transition st,at→st+1 and counterfactual transition s,a→s′. From (2), for a fixed MDP M and exogenous distribution θ, we see that the counterfactual probability P~M,t(s′∣s,a) depends only on the subset of exogenous values ut consistent with both transitions, since PM(st+1∣st,at), the denominator in (2), is fixed. Therefore, the optimisation involves identifying the θ that maximises/minimises the following sum:
Importantly, Lally et al. [17] prove that the bounds for each (s,a) depend only on the probability distribution of this state-action pair and the observed state-action pair (st,at), so we can decompose the optimisation problem. Since the bounds proven by Lally et al. [17] are tight, extending these bounds from MDPs to IMDPs (6) reduces to (7) and (8), where we aim to identify, for each transition, the max/min possible counterfactual upper/lower bound across all admissible MDPs within the IMDP. In the proofs, we search over the interval probabilities for (s,a) and (st,at) to obtain these bounds, while ensuring that a valid MDP exists (i.e., where the probability distribution for each state-action pair sums to 1) that results in these bounds. Intuitively, each case reflects a different way probability mass can be distributed between the transitions from (s,a) and (st,at) under this constraint: when (s,a)=(st,at), the bounds are immediate (the same (st,at) under the same context ut must yield the same outcome); when the supports are disjoint, the counterfactual stability and counterfactual monotonicity assumptions are vacuously satisfied, and do not constrain how (s,a) and (st,at) behave under the same ut, so the bound depends only on their marginal probabilities; and when the supports are overlapping, these assumptions constrain how probability mass can be distributed across the shared support of (s,a) and (st,at).
Proposition 3.1 (Tightness of the Counterfactual IMDP Bounds). The upper bounds P~M↑,tUB(s′∣s,a) are tight for all s,a,s′. The lower bounds P~M↑,tLB(s′∣s,a) are tight for all s,a,s′, except when (s,a)=(st,at), the counterfactual and observed transitions have overlapping support, and the counterfactual stability constraint does not force the bound to 0 for all admissible MDPs M∈M↑, i.e., Cases 1 and 3 of Theorem B.7.
Remark. In every case where a tight bound can be obtained (Theorems B.3, B.4, B.5, B.6, and Case 2 of B.7, each closed-form bound can be expressed as a function of a small, fixed set of individual transition probabilities. This lets us explicitly construct a single admissible MDP that sets each of these probabilities to its IMDP-level extremal (upper or lower) value, thereby minimising or maximising the overall expression. However, Cases 1 and 3 of B.7 differ structurally, as the bound depends on the sum of the upper-bound probabilities of alternative outcomes ∑s′′∈S∖{s′}P~M,tUB(s′′∣s,a), each term of which is itself the result of a separate optimisation over M↑. This leaves us with two options: (i) solving the nested optimisation when necessary to obtain the true maximum of ∑s′′∈S∖{s′}P~M,tUB(s′′∣s,a) achievable by a single admissible MDP, giving a tight bound, or (ii) computing a conservative lower bound by replacing this sum with the sum of the individually-optimised IMDP-level upper bounds ∑s′′∈S∖{s′}P~M↑,tUB(s′′∣s,a), which need not be jointly achievable. We compare these two approaches in our experiments.
Bounds for Gumbel-max SCMs. While this is not the main focus of our work, we also extend the Gumbel-max SCM counterfactual inference approach [15, 23, 29] from MDPs to IMDPs and, to our knowledge, provide the first bounds on Gumbel-max counterfactual probabilities for IMDPs. Although these bounds are not tight in general, they may be of independent interest given the popularity of Gumbel-max SCMs; we also use them in our experimental evaluation (Section 5) as a baseline to assess the robustness of our approach. The bounds and their proof are given in Appendix C.
4 Methodology
We first describe how to derive an IMDP from paths sampled from the unknown MDP, and how to construct a counterfactual IMDP (CFIMDP) for a given observed path. We then formalise the notion of minimal robust counterfactual interventions and show how to compute them via robust value iteration over the CFIMDP.
4.1 Learning IMDPs from Data
We begin by collecting observed trajectories of length ∣τ∣ (an environment-specific hyperparameter) from either the initial state, if defined, or any non-sink state. Following the standard approach [21, 26, 27], we estimate the IMDP by computing a confidence interval for each transition probability from these observations, assuming that the MDP's topology is known (the so-called grey-box setting) 2. We use the Clopper-Pearson method [5], with an overall confidence level 1−α distributed evenly across all nondeterministic transitions (see Appendix D for more details). We assign a minimum probability ϵ to all possible transitions ( ϵ=0.01, or 10−4 for Sepsis, whose smallest transition probability is approximately 10−4) to ensure that observed transitions have strictly positive lower bounds, as required for valid counterfactual inference. We note our framework is agnostic to the estimation method: more sample-efficient methods than Clopper-Pearson may yield tighter IMDP bounds from the same data, and hence tighter CFIMDP bounds.
2The black-box alternative, where the topology is instead inferred from data by assuming a lower bound on the minimum transition probability [21], is also compatible with our framework.
Table 1: Closed-form counterfactual probability upper and lower bounds. For s′=st+1 in the overlapping case, the upper and lower bound conditions are each applied in order, where CS always holds if pst,atLB(s′)>0 and pst,atUB(st+1)ps,aLB(st+1)≥pst,atLB(s′)ps,aUB(s′), and CS sometimes holds if pst,atUB(s′)>0 and pst,atLB(st+1)ps,aUB(st+1)≥pst,atUB(s′)ps,aLB(s′). Psum=∑s′=st+1P~M↕,tUB(s′∣s,a) for the closed-form but conservative lower bound; for the tight, optimisation-based bound, Psum=maxM∈M↕∑s′′∈S∖{s′}P~M,tUB(s′′∣s,a).
Given the counterfactual probability bounds in Table 1, we can compute a non-stationary counterfactual interval MDP (CFIMDP) for any given IMDP M↕ and observed path τ. For each transition observed in τ, we compute the counterfactual probability bounds for all possible transitions in the IMDP. These bounds are then combined to form a non-stationary CFIMDP by concatenating the time-dependent counterfactual transition probability bounds across time steps. Formally, a CFIMDP is defined as follows:
Definition 4.1 (Counterfactual Interval MDP (CFIMDP) [17]). Given an observed path τ and IMDP M↕, the counterfactual probability for each transition in the CFIMDP M~τ↕ is defined, for t=0,…,∣τ∣−1, as p~t↕(s′∣s,a)=[p~tLB(s′∣s,a),p~tUB(s′∣s,a)].
Proposition 4.2 (Confidence propagation). Let M↕ be a data-driven IMDP, which contains the true MDP with probability at least 1−α. Then the CFIMDP derived from M↕ contains the true CFMDP with probability at least 1−α (proof in Appendix D).
4.3 Minimal Robust Counterfactual Interventions
The CFIMDP we just introduced allows us to systematically reason about counterfactual outcomes. Specifically, given an observed trajectory whose cumulative reward falls below a threshold λ, we seek an intervention that guarantees an expected counterfactual cumulative reward ≥λ. Using the CFIMDP, we can identify interventions that would have improved on the factual outcome in a robust way w.r.t. all models induced by statistical and causal uncertainties. Moreover, we are interested in minimal interventions, i.e., policies that require the fewest action changes to achieve this. Given our RL context, we focus on the expected cumulative reward. Properties like reach-avoid can be captured this way via a suitable Bellman recursion [1]; more complex temporal logic properties can be encoded as reachability by taking the product of the CFIMDP with a reward machine [13], which we leave for future work.
Let τ=(s0,a0,…,s∣τ∣−1,a∣τ∣−1,s∣τ∣) be an observed path, and let G(τ)=∑t=0∣τ∣−1R(st,at) denote its cumulative reward. A counterfactual policy π chooses an action π(t,s) for each time step t and state s. We write M~τ∈M~τ↕ for any CFMDP within the CFIMDP, i.e., any non-stationary MDP whose transition probabilities satisfy P~tLB(s′∣s,a)≤P~t(s′∣s,a)≤P~tUB(s′∣s,a) for all t,s,a and s′. Following π in M~τ induces a distribution M~τ(π) over counterfactual paths τ~=(s~0,a~0,…,s~∣τ∣), and we define the worst-case expected counterfactual cumulative reward of π from the initial state s0 as
The set M~τ↕ contains the CFMDP of every MDP in the IMDP under every corresponding SCM. Since the CFIMDP bounds each counterfactual transition probability separately, it may also contain CFMDPs that combine probabilities induced by different MDPs or SCMs, and so do not correspond to any single causal model compatible with the IMDP. As is standard for IMDPs [9], taking the worst case over this larger set yields conservative, but efficiently computable, guarantees.
For k∈{0,…,∣τ∣}, we denote with Πτ,k the set of counterfactual policies that change no more than k actions from τ, i.e.,
where 1{⋅} denotes the indicator function, a~t=π(t,s~t) is the action taken by π at time t along τ~ and supp(M~τ(π)) denotes the set of admissible paths of M~τ(π).
Definition 4.3 (Minimal Robust Counterfactual Intervention). A counterfactual policy π∗ is a minimal robust counterfactual intervention for a path τ and threshold λ if, for some k∗∈{0,…,∣τ∣}:
(1) π∗∈Πτ,k∗ and V⊥,π∗(s0)≥λ, and
(2) for all k<k∗, maxπ∈Πτ,kV⊥,π(s0)<λ.
Conversely, if the observed cumulative reward is at least λ, we can identify the minimal interventions that would have robustly led to a cumulative reward below λ, i.e., the observed actions responsible for the success, by reversing the inequalities and replacing the V⊥,π with the corresponding best-case (optimistic) value V⊤,π.
Computing minimal robust counterfactual interventions. We compute minimal robust counterfactual interventions via pessimistic value iteration [20], which maximises the expected cumulative reward under the worst-case CFMDP within the CFIMDP. To restrict the search to π∈Πτ,k, we augment the state with a counter k that tracks the remaining allowed number of action changes, and define
where V∗(s,∣τ∣,k)=0 for all s and k, and, for k=0, the maximum is restricted to π(t,s)=at. Since the CFIMDP selects transition probabilities independently for each (t,s,a), the worst case can be computed one step at a time [9], so V∗(s0,0,k)=maxπ∈Πτ,kV⊥,π(s0). Let k∗ be the smallest k with V∗(s0,0,k)≥λ, and πk∗∗ the corresponding maximising policy. Then πk∗∗∈Πτ,k∗ achieves V⊥,πk∗∗(s0)≥λ, and no policy that changes fewer actions does, so πk∗∗ is a minimal robust counterfactual intervention (see Appendix E for the full algorithm). With the conservative lower bounds, πk∗∗ is still guaranteed to achieve V⊥,πk∗∗(s0)≥λ, but k∗ may be larger than with the tight bounds.
Relation to actual causation. Minimal robust counterfactual interventions are closely related to the notion of actual causes [11]. Informally, a set of observed actions is an actual cause of an outcome if changing those actions, while keeping all other actions at their observed values, would have changed the counterfactual outcome, and no strict subset of these actions has this property. Identifying an actual cause requires knowing the SCM and the context (the exogenous noise values), which together determine a single counterfactual path. In our setting, neither is known: we only know that the true CFMDP lies within the CFIMDP, and each CFMDP induces a distribution over counterfactual paths. We therefore require the change in outcome to hold robustly and in expectation, making our interventions a robust, policy-based analogue of actual causes.
Table 2: Average lower (V⊥,π∗(s0)) and upper (V⊤,π∗(s0)) bounds on the counterfactual value of π∗ over 100 randomly sampled observed paths, under the exact CFIMDP and data-driven CFIMDPs whose IMDPs are learnt from N simulated paths. The true interventional value is Vπ∗(s0)=333.
Lower Bound
Upper Bound
Exact Bounds
249±118
387±39
Data-driven Bounds
N=10,000
183±104
398±36
N=100,000
228±114
392±37
N=1,000,000
241±117
389±38
Table 3: Average worst-case counterfactual value V⊥,πk∗(s0) on the exact CFIMDP of policies derived from data-driven CFIMDPs (N=100,000, α=0.1) and of the exact CFIMDP's pessimistic optimal policy, over 100 observed trajectories τ with k=∣τ∣−1. Values are mean ± standard deviation.
Environment
Exact CFIMDP
Data-driven CFIMDP (Cons. LB)
Data-driven CFIMDP (Gumbel-max)
GridWorld (p=0.9)
283±104
283±104
227±233
GridWorld (p=0.4)
−21.1±138
−21.9±139
−56.6±165
Frozen Lake
34.7±18.5
34.6±18.5
−4.80±49.5
Aircraft
−11.1±326
−24.6±344
−78.3±408
5 Evaluation
We evaluate our approach along five axes: (1) its accuracy in off-policy evaluation tasks; (2) how its policies compare against those obtained from the exact CFIMDP (i.e., the CFIMDP derived from the true MDP); (3) its robustness relative to the Gumbel-max approach; (4) how well it identifies minimal action changes to achieve a desired counterfactual value; and (5) the trade-off of using conservative vs. tight lower bounds. We evaluate our approach on a range of MDP tasks, ranging from simple models (GridWorld and Frozen Lake) to more complex clinical and navigation tasks (Sepsis and Aircraft). Full descriptions of the MDP environments and system details can be found in the Appendix F. The code is available at: https://github.com/jessicalally/robust-cf-inference-beyond-mdps.
5.1 Off-Policy Evaluation
We first check the correctness of our counterfactual inference method for IMDPs in an off-policy evaluation (OPE) setting [3, 23], estimating the expected return of an optimal target policy π∗ using trajectories generated by a suboptimal behavioural policy π. We construct a data-driven IMDP given a fixed number N of observed trajectories and confidence α=0.1, sample 100 trajectories from the true MDP under π, build a CFIMDP for each, and compute upper and lower bounds on the expected counterfactual return from the initial state. The counterfactual value averaged over observed trajectories should equal the interventional value. Hence, if the method
(a) GridWorld (p=0.9)
(b) GridWorld (p=0.4)
(c) Frozen Lake
(d) Sepsis
(e) Aircraft
Figure 2: Average pessimistic counterfactual value V∗(s0,0,k) over 100 randomly sampled observed trajectories, on the data-driven CFIMDP ( N=100,000,α=0.1) ( ∙) vs. the exact CFIMDP ( ■), for each k. The data-driven value is a certified lower bound, so the gap to the exact curve is the price of learning the model from data. Error bars show standard deviation.
is unbiased, the average bounds should contain the true interventional value Vπ∗(s0). Table 2 shows the results for the GridWorld (p=0.9) MDP (similar results for GridWorld (p=0.4) can be found in Appendix G), alongside the exact bounds from the true MDP following Lally et al. [17]. The results confirm that our approach is valid and unbiased: the data-driven CFIMDP bounds consistently contain the true expected return, and converge towards the exact bounds as the number N of trajectories increases.
5.2 Evaluating Performance
Next, we evaluate the impact of learning the model from data by comparing the performance of the counterfactual policies derived from our data-driven IMDP (with conservative lower bounds) against those derived from the exact CFIMDP. We use a suboptimal observational policy π that selects a random action over the optimal action with probability 0.5, construct an IMDP with hyperparameters ( N=100,000,α=0.1), and derive CFIMDPs for 100 paths sampled under π using both approaches. We then compare the average values V∗(s0,0,k) of the resulting pessimistic optimal policies, where s0 is the MDP's initial state, for each maximum number of action changes k.
For GridWorld and Frozen Lake (Figures 2a-2c), our approach yields estimates of V∗(s0,0,k) close to those obtained from the exact CFIMDP, showing that the statistical uncertainty in the MDP has little impact on the robust counterfactual policies. For Sepsis and Aircraft (Figures 2d and 2e), V∗(s0,0,k) is slightly lower, as the larger state spaces require wider bounds in the IMDP to maintain an overall significance level of α=0.1; with more data, these estimates would tighten. The resulting policies may therefore identify more conservative interventions, i.e., change more actions than strictly necessary. However, since the statistical guarantees on the IMDP carry over to the CFIMDP, these interventions remain valid at the stated confidence level. Finally, as shown in Section 5.3, policies derived from data-driven IMDPs tend to exceed their estimated performance when evaluated on the true CFIMDP, suggesting that these policies are generally accurate and close to the optimal policy obtained without statistical uncertainty.
5.3 Evaluating Robustness
To evaluate robustness, we compare the counterfactual policies generated by our approach (with conservative lower bounds) and from the data-driven Gumbel-max approach on the exact CFIMDP, i.e., by their worst-case counterfactual value across all causal models compatible with the true MDP (Table 3) 3. Our policies perform close to the optimal policies learned from the true CFIMDP, showing little impact from statistical uncertainty in these examples. In contrast, the Gumbel-max CFIMDP policies perform suboptimally, suggesting that committing to a specific causal model (even when accounting for uncertainty in the transition dynamics) can be unreliable if the assumed model is misspecified.
5.4 Computing Robust Interventions
We now evaluate how well our approach identifies minimal action changes that achieve a counterfactual value ≥λ. To do so, we use the same 100 observed trajectories as before. For each trajectory and k∈{0,…,∣τ∣−1}, we compute the pessimistic policy πk∗ and its value V∗(s0,0,k) under the exact CFIMDP, our data-driven CFIMDPs (conservative and tight lower bounds), and the Gumbel-max CFIMDP, and report the smallest k∗ such that V∗(s0,0,k)≥λ. Figure 3 shows that both data-driven approaches identify interventions involving similar numbers of action changes to the exact CFIMDP, being only slightly more conservative, whereas Gumbel-max often underestimates k∗, particularly in GridWorld ( p=0.9) and Aircraft, so its interventions may be unreliable. Figure 4 visualises the identified interventions for one catastrophic trajectory. In GridWorld, with k=1 the policy changes the second action to move back towards the start, so most counterfactual paths avoid the fire, but none reach the goal; with k=2, it instead changes the action that led into the fire, allowing over 60% of counterfactual paths to reach the goal. The size of a robust intervention thus depends on the outcome compared against: avoiding catastrophe requires one change, while reaching the goal requires two. Similarly, in Sepsis, mortality falls, and recovery rises as k grows. Appendix G shows these counterfactual paths in more detail, plotting each vital sign and treatment over time for every k.
5.5 Execution Times and Bound Widths
Finally, we assess the impact of using conservative lower bounds (closed-form, efficient) instead of tight lower bounds (optimisation-based, expensive). For the same 100 paths, we derive the CFIMDPs
3We omit Sepsis, as generating its Gumbel-max CFIMDPs is computationally prohibitive.
(a) GridWorld (p=0.9)
(b) GridWorld (p=0.4)
(c) Frozen Lake
(d) Aircraft
Figure 3: Minimum number of action changes k∗ needed for V∗(s0,0,k) to reach a threshold λ, averaged over 100 randomly sampled observed trajectories. We compare the exact CFIMDP (black, solid) with data-driven CFIMDPs using conservative lower bounds (dashed), tight lower bounds (dotted), and the Gumbel-max model (dash-dot). 3
(i) k=0
(ii) k=1
(iii) k=2
(iv) k=5
(v) k=8
(a) GridWorld: distribution of counterfactual trajectories. The observed path is shown in black, and counterfactual paths in blue where the observed action is taken and in red where the action has been changed.
(i) k=0
(ii) k=1
(iii) k=2
(iv) k=5
(v) k=8
(b) Sepsis: share of counterfactual paths at each time step where the patient has recovered (green), remains in treatment (grey), or has died (red).
Figure 4: Behaviour of the data-driven counterfactual policy for a single observed catastrophic path, with varying k, under a CFMDP adversarially chosen from the exact CFIMDP.
with both approaches and measure the percentage of transitions whose lower bound changes when the tight bound is used, both across all transitions and across non-zero probability transitions only, together with the average change in bound width. The full results are reported in Table 5 in Appendix G. The overall effect is small: at most 4.4% of all transitions change, and among non-zero probability transitions, at most 21% in GridWorld (p = 0.9) and at most 6% elsewhere, with an average width change of at most 0.06 for the transitions that change. As the previous experiments show, this has little impact on the derived policies, and since tight lower bounds require solving an additional optimisation problem and are slower to compute, the conservative approach is preferable in practice. While comparable in the smaller environments, the Gumbel-max approach scales poorly with the MDP state space, taking 293s on average for Aircraft compared with 10s for our conservative bounds, and is computationally prohibitive for Sepsis.
6 Conclusion
We have presented a counterfactual inference approach for MDPs that is robust to both uncertainty in the underlying transition dynamics and the unknown causal model. We derived closed-form bounds on counterfactual transition probabilities, enabling scalable inference in larger MDPs. Building on these bounds, we introduced minimal robust counterfactual interventions: non-stationary policies that guarantee a desired expected return under all admissible counterfactual dynamics, while minimising the maximum number of action changes. Experiments across diverse MDP environments demonstrate the robustness and scalability of our approach, with counterfactual interventions closely tracking those of the exact counterfactual MDP. Future work will address unobserved confounding in offline trajectory datasets and extend our approach to continuous and partially-observable environments.
References
[1] Alessandro Abate, Maria Prandini, John Lygeros, and Shankar Sastry. 2008. Probabilistic reachability and safety for controlled discrete time stochastic hybrid systems. Automatica 44, 11 (2008), 2724–2734. doi:10.1016/j.automatica.2008.03.027
[2] Nina L Corvelo Benz and Manuel Gomez Rodriguez. 2022. Counterfactual inference of second opinions. In Uncertainty in Artificial Intelligence. PMLR, 453–463.
[3] Lars Buesing, Theophane Weber, Yori Zwols, Sébastien Racanière, Arthur Guez, Jean-Baptiste Lespiau, and Nicolas Heess. 2019. Woulda, coulda, shoulda: Counterfactually-guided policy search. In International Conference on Learning Representations (ICLR).
[4] Ivi Chatzi, Nina Corvelo Benz, Eleni Straitouri, Stratis Tsirtsis, and Manuel Gomez Rodriguez. 2025. Counterfactual token generation in large language models. In Proceedings of the Fourth Conference on Causal Learning and Reasoning (Proceedings of Machine Learning Research, Vol. 275). PMLR, 1291–1315.
[5] Charles J Clopper and Egon S Pearson. 1934. The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika 26, 4 (1934), 404–413.
[6] Rudi Coppola, Andrea Peruffo, Licio Romao, Alessandro Abate, and Manuel Mazo Jr. 2024. Data-driven interval MDP for robust control synthesis. arXiv preprint arXiv:2404.08344 (2024).
[7] Guilherme Duarte, Noam Finkelstein, Dean Knox, Jonathan Mummolo, and Ilya Shpitser. 2024. An automated approach to causal inference in discrete settings. J. Amer. Statist. Assoc. 119, 547 (2024), 1778–1793. doi:10.1080/01621459.2023.2216909
[8] Eugene A Feinberg and Adam Shwartz. 2012. Handbook of Markov decision processes: methods and applications. Vol. 40. Springer Science & Business Media.
[9] Robert Givan, Sonia Leach, and Thomas Dean. 2000. Bounded-parameter Markov decision processes. Artificial Intelligence 122, 1 (2000), 71–109. doi:10.1016/S0004-3702(00)00047-3
[10] Dennis Gross, Nils Jansen, Sebastian Junges, and Guillermo A Pérez. 2022. COOL-MC: a comprehensive tool for reinforcement learning and model checking. In Dependable Software Engineering. Theories, Tools, and Applications: 8th International Symposium, SETTA 2022, Beijing, China, October 27-29, 2022, Proceedings. Springer, 41–49.
[11] Joseph Y Halpern. 2016. Actual causality. MIT Press.
[12] Joseph Y. Halpern and Judea Pearl. 2005. Causes and explanations: A structural-model approach. Part I: Causes. The British Journal for the Philosophy of Science 56, 4 (2005), 843–887.
[13] Rodrigo Toro Icarte, Toryn Q Klassen, Richard Valenzano, and Sheila A McIlraith. 2022. Reward machines: Exploiting reward function structure in reinforcement learning. Journal of Artificial Intelligence Research 73 (2022), 173–208.
[14] Milad Kazemi, Jessica Lally, Ekaterina Tishchenko, Hana Chockler, and Nicola Paoletti. 2025. Counterfactual influence in Markov decision processes. In Proceedings of the Fourth Conference on Causal Learning and Reasoning (Proceedings of Machine Learning Research, Vol. 275), Biwei Huang and Mathias Drton (Eds.). PMLR, 792–817. https://proceedings.mlr.press/v275/kazemi25a.html
[15] Taylor W Killian, Marzyeh Ghassemi, and Shalmali Joshi. 2022. Counterfactually guided policy transfer in clinical settings. In Conference on Health, Inference, and Learning. PMLR, 5–31.
[16] M. Kwiatkowska, G. Norman, and D. Parker. 2011. PRISM 4.0: Verification of probabilistic real-time systems. In Proc. 23rd International Conference on Computer Aided Verification (CAV'11) (LNCS, Vol. 6806), G. Gopalakrishnan and S. Qadeer (Eds.). Springer, 585–591.
[17] Jessica Lally, Milad Kazemi, and Nicola Paoletti. 2026. Robust counterfactual inference in Markov decision processes. In Proceedings of the 25th International Conference on Autonomous Agents and Multiagent Systems (Paphos, Cyprus) (AAMAS '26). International Foundation for Autonomous Agents and Multiagent Systems, Richland, SC, 1527–1535. doi:10.65109/TXUQ4572
[18] Chaochao Lu, Biwei Huang, Ke Wang, José Miguel Hernández-Lobato, Kun Zhang, and Bernhard Schölkopf. 2020. Sample-efficient reinforcement learning via counterfactual-based data augmentation. arXiv preprint arXiv:2012.09092 (2020).
[19] Chris J Maddison, Daniel Tarlow, and Tom Minka. 2014. A* sampling. Advances in Neural Information Processing Systems 27 (2014).
[20] Frederik Baymler Mathiesen, Morteza Lahijanian, and Luca Laurenti. 2024. IntervalMDP.jl: Accelerated value iteration for interval Markov decision processes. IFAC-PapersOnLine 58, 11 (2024), 1–6. 8th IFAC Conference on Analysis and Design of Hybrid Systems (ADHS 2024). doi:10.1016/j.ifacol.2024.07.416
[21] Tobias Meggendorfer, Maximilian Weininger, and Patrick Wienhöft. 2024. What are the odds? Improving the foundations of statistical model checking. arXiv preprint arXiv:2404.05424 (2024).
[22] Kimia Noorbakhsh and Manuel Gomez Rodriguez. 2022. Counterfactual temporal point processes. Advances in Neural Information Processing Systems 35 (2022), 24810–24823.
[23] Michael Oberst and David Sontag. 2019. Counterfactual off-policy evaluation with Gumbel-max structural causal models. In Proceedings of the 36th International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 97), Kamalika Chaudhuri and Ruslan Salakhutdinov (Eds.). PMLR, 4881–4890. https://proceedings.mlr.press/v97/oberst19a.html
[25] Edoardo Pona, Milad Kazemi, Yali Du, David Watson, and Nicola Paoletti. 2025. Abstract counterfactuals for language model agents. In Advances in Neural Information Processing Systems, D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen (Eds.), Vol. 38, Main Conference. Curran Associates, Inc., 87484–87509. doi:10.52202/085713-2925
[26] Yannik Schnitzer, Alessandro Abate, and David Parker. 2025. Certifiably robust policies for uncertain parametric environments. In Tools and Algorithms for the Construction and Analysis of Systems, Arie Gurfinkel and Marijn Heule (Eds.). Springer Nature Switzerland, Cham, 63–83.
[27] Marnix Suilen, Thiago D Simão, David Parker, and Nils Jansen. 2022. Robust anytime learning of Markov decision processes. Advances in Neural Information Processing Systems 35 (2022), 28790–28802.
[28] Yuewen Sun, Erli Wang, Biwei Huang, Chaochao Lu, Lu Feng, Changyin Sun, and Kun Zhang. 2024. ACAMDA: improving data efficiency in reinforcement learning through guided counterfactual data augmentation. In Proceedings of the AAAI Conference on Artificial Intelligence, Vol. 38. 15193–15201.
[29] Stratis Tsirtsis, Abir De, and Manuel Gomez Rodriguez. 2021. Counterfactual explanations in sequential decision making under uncertainty. Advances in Neural Information Processing Systems 34 (2021), 30127–30139.
[30] Stratis Tsirtsis and Manuel Gomez Rodriguez. 2023. Finding counterfactually optimal action sequences in continuous state spaces. In Advances in Neural Information Processing Systems, A. Oh, T. Naumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine (Eds.), Vol. 36. Curran Associates, Inc., 3220–3247.
[31] Marco Zaffalon, Alessandro Antonucci, Rafael Cabañas, David Huber, and Dario Azzimonti. 2024. Efficient computation of counterfactual bounds. International Journal of Approximate Reasoning 171 (2024), 109111. Synergies between Machine Learning and Reasoning. doi:10.1016/j.ijar.2023.109111
[32] Junzhe Zhang, Jin Tian, and Elias Bareinboim. 2022. Partial counterfactual identification from observational and experimental data. In Proceedings of the 39th International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 162), Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvari, Gang Niu, and Sivan Sabato (Eds.). PMLR, 26548–26558.
[33] Qingfu Zhu, Weinan Zhang, Ting Liu, and William Yang Wang. 2020. Counterfactual off-policy training for neural dialogue generation. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP). 3438–3448.
Robust Counterfactuals for Markov Decision Processes under Statistical and Causal Uncertainties (Supplementary Material)
A Counterfactual Probability Bounds for MDPs
We copy the counterfactual probability bounds proven by Lally et al. [17] below, under the assumptions of counterfactual stability and counterfactual monotonicity:
Definition A.1 (Counterfactual stability). An MDP SCM (1) satisfies counterfactual stability if, given we observed the transition st,at→st+1 at time t, the counterfactual outcome under a different state-action pair (s,a) will not change to some St+1=s′=st+1 unless P(st+1∣st,at)P(st+1∣s,a)<P(s′∣st,at)P(s′∣s,a).
Definition A.2 (Counterfactual monotonicity). An MDP SCM (1) satisfies counterfactual monotonicity if, upon observing the transition st,at→st+1, then, ∀s∈S,a∈A:
(Mon1) P~t(st+1∣s,a)≥P(st+1∣s,a) (i.e., observing an outcome cannot make it less likely in the counterfactual world), and
(Mon2) ∀s′=st+1 with P(s′∣st,at)>0, P~t(s′∣s,a)≤P(s′∣s,a) (i.e., not observing a possible outcome cannot make it more likely in the counterfactual world).
For any MDP M and observed transition st,at→st+1, we can bound the counterfactual probability of any transition s,a→s′ as follows.
Theorem A.3. When the counterfactual state-action pair is the observed state-action pair, (s,a)=(st,at), the counterfactual probability bounds are as follows:
Theorem A.4. When the counterfactual state-action pair (s,a)=(st,at) and has disjoint support from the observed (st,at), the counterfactual probability bounds are as follows, ∀s′∈S:
Theorem A.5. When the counterfactual state-action pair (s,a)=(st,at) and has overlapping support with the observed (st,at), the counterfactual probability bounds are as follows, ∀s′∈S:
where the counterfactual stability (CS) conditions are P(s′∣st,at)>0 and P(st+1∣st,at)P(st+1∣s,a)≥P(s′∣st,at)P(s′∣s,a)
B Proofs
Let M↕ be an arbitrary IMDP. For a given counterfactual transition s,a→s′ and observed transition st,at→st+1, the optimisation problems defined in (7) and (8) yield the upper and lower bounds on the counterfactual probability of s,a→s′ respectively, under the following assumptions.
Assumption B.1 (Normalisation). For any IMDP M↕, we assume the transition bounds have been normalised in the sense that, ∀s,a,s′:
This is not a strong assumption, because any feasible MDP M∈M↕ must have transition probabilities that sum to 1, so any IMDP can be tightened to meet the above conditions without altering the set of compatible MDPs.
Assumption B.2 (Non-zero Lower Bounds of Observed Transitions). Given any arbitrary IMDP M↕, we assume that, for any feasible M∈M↕, PM(st+1∣st,at)>0, i.e., we assume PM↕LB(st+1∣st,at)>0.
This assumption must hold, because we observed the transition st,at→st+1, hence the true MDP must have PM(st+1∣st,at)>0.
B.1 Observed (st,at)
Theorem B.3. Assume (s,a)=(st,at). For outgoing transitions from the observed state-action pair (st,at), the optimisation problem in (7) will produce an upper bound of:
P~M⇑UB(s′∣s,a)={10ifs′=st+1otherwise
and the optimisation problem in (8) will produce a lower bound of:
P~M⇑LB(s′∣s,a)={10ifs′=st+1otherwise
across all M∈M↑.
Proof. For all MDPs M∈M↑, we know that the counterfactual probability for all transitions from the observed state-action pair (st,at) will be:
Theorem B.4. Assume (s,a)=(st,at), and assume that the support of (s,a) is disjoint from the support of (st,at) in the IMDP M↑. In this case, the optimisation problem in (7) will produce an upper bound of:
Proof. Because the supports of (s,a) and (st,at) are disjoint in the IMDP M↑, this means that ∀s′∈S,PM↑UB(s′∣s,a)>0⇒PM↑UB(s′∣st,at)=0, and ∀s′∈S,PM↑UB(s′∣st,at)>0⇒PM↑UB(s′∣s,a)=0. Therefore, in any MDP M∈M↑, the supports of (s,a) and (st,at) are guaranteed to be disjoint as well.
For any MDP M∈M↑, the proven closed-form solution to the upper bound P~M,tUB(s′∣s,a) is:
Therefore, to identify the upper bound, we need to maximise this over all MDPs M∈M↑. Clearly, if there exist MDPs M∈M↑ where PM(s′∣s,a)<PM(st+1∣st,at), then PM(st+1∣st,at)PM(s′∣s,a)<1, so the absolute maximum value of P~M,tUB(s′∣s,a) across all MDPs cannot be greater than 1.
(1) If PM↑UB(s′∣s,a)≥PM↑LB(st+1∣st,at), then, because of Assumption B.1, there must exist an MDP M∈M↑ where PM(st+1∣st,at)=PM↑LB(st+1∣st,at) and PM(s′∣s,a)=PM↑UB(s′∣s,a). Because PM↑UB(s′∣s,a)≥PM↑LB(st+1∣st,at), we know that in MDP M, the upper bound counterfactual probability P~M,tUB(s′∣s,a)=1. Since this is the maximum possible counterfactual probability, this means that P~M↑,tUB(s′∣s,a)=1.
(2) Otherwise, if PM↑UB(s′∣s,a)<PM↑LB(st+1∣st,at), then, for every MDP M∈M↑, PM(s′∣s,a)<PM(st+1∣st,at). Therefore, for every MDP, the upper bound counterfactual probability for the transition will be P~M,tUB(s′∣s,a)=PM(st+1∣st,at)PM(s′∣s,a). Therefore, the maximum upper bound counterfactual probability is:
Because of Assumption B.1, there must exist an MDP M where PM(st+1∣st,at)=PM↑LB(st+1∣st,at) and PM(s′∣s,a)=PM↑UB(s′∣s,a). Also, note that because of Assumption B.2, PM↑LB(st+1∣st,at)>0.
Therefore, the maximum upper bound counterfactual probability in this case is
Theorem B.5. Assume (s,a)=(st,at), and assume that the support of (s,a) is disjoint from the support of (st,at) in the IMDP M↑. In this case, the optimisation problem in (8) will produce a lower bound of:
Proof. Because the supports of (s,a) and (st,at) are disjoint in the IMDP M↑, this means that ∀s′∈S,PM↑UB(s′∣s,a)>0⇒PM↑UB(s′∣st,at)=0, and ∀s′∈S,PM↑UB(s′∣st,at)>0⇒PM↑UB(s′∣s,a)=0. Therefore, in any MDP M∈M↑, the supports of (s,a) and (st,at) are guaranteed to be disjoint as well.
For any MDP M∈M↑, the proven closed-form solution to the lower bound P~M,tLB(s′∣s,a) is:
Therefore, the absolute minimum value of P~M,tLB(s′∣s,a) across all MDPs cannot be less than 0. Consider whether PM↑LB(s′∣s,a)>1−PM↑LB(st+1∣st,at):
(1) If PM↑LB(s′∣s,a)≤1−PM↑LB(st+1∣st,at), then, because of Assumption B.1, there must exist an MDP M where PM(st+1∣st,at)=PM↑LB(st+1∣st,at) and PM(s′∣s,a)=PM↑LB(s′∣s,a). Because PM↑LB(s′∣s,a)≤1−PM↑LB(st+1∣st,at), we know that in this MDP M, the lower bound counterfactual probability P~M,tLB(s′∣s,a)=0. Since this is the minimum possible counterfactual probability across all MDPs, this means that P~M↑,tLB(s′∣s,a)=0.
(2) Otherwise, if PM↑LB(s′∣s,a)>1−PM↑LB(st+1∣st,at), then, for every MDP M∈M↑, PM(s′∣s,a)>1−PM(st+1∣st,at). Therefore, for every MDP, the lower bound counterfactual probability for the transition will be P~M,t(s′∣s,a)=PM(st+1∣st,at)PM(s′∣s,a)−(1−PM(st+1∣st,at)). Therefore, the minimum lower bound counterfactual probability will be:
Clearly, this formula will be minimal when PM(s′∣s,a)=PM↑LB(s′∣s,a) and PM(st+1∣st,at)=PM↑LB(st+1∣st,at). Because of Assumption B.1, there must exist an MDP M where PM(s′∣s,a)=PM↑LB(s′∣s,a) and PM(st+1∣st,at)=PM↑LB(st+1∣st,at). Also, note that because of Assumption B.2, PM↑LB(st+1∣st,at)>0.
Therefore, the minimum lower bound counterfactual probability in this case is:
Theorem B.6. Assume (s,a)=(st,at), and assume that the support of (s,a) overlaps with the support of (st,at) in the IMDP M↑. In this case, the optimisation problem in (7) will produce an upper bound of:
Therefore, we need to maximise this over all MDPs M∈M↑. Clearly, for any MDP M where PM(st+1∣s,a)<PM(st+1∣st,at), PM(st+1∣st,at)PM(st+1∣s,a)<1, so the maximum possible value of P~M,tUB(s′∣s,a) across all MDPs is 1. Consider now whether PM↑UB(st+1∣s,a)<PM↑LB(st+1∣st,at):
(1) If PM↑UB(st+1∣s,a)≥PM↑LB(st+1∣st,at), then, because of Assumption B.1, we know there exists an MDP M∈M↑ where PM(st+1∣s,a)=PM↑UB(st+1∣s,a) and PM(st+1∣st,at)=PM↑LB(st+1∣st,at). Also, note that because of Assumption B.2, PM↑LB(st+1∣st,at)>0. In this MDP M, we know PM(st+1∣s,a)≥PM(st+1∣st,at), therefore, the upper bound counterfactual probability P~M,t(s′∣s,a)=PM(st+1∣st,at)PM(st+1∣st,at)=1, and since this is the maximum possible counterfactual probability, P~M↑,tUB(st+1∣s,a)=1.
(2) Otherwise, if PM↑UB(st+1∣s,a)<PM↑LB(st+1∣st,at), then, for every MDP M∈M↑, PM(st+1∣s,a)<PM(st+1∣st,at). Therefore, for every MDP, the upper bound counterfactual probability for the transition will be P~M,tUB(s′∣s,a)=PM(st+1∣st,at)PM(st+1∣s,a). The maximum upper bound counterfactual probability, therefore, will be:
Because of Assumption B.1, there must exist an MDP M where PM(st+1∣st,at)=PM↑LB(st+1∣st,at) and PM(s′∣s,a)=PM↑UB(s′∣s,a). Also, note that because of Assumption B.2, PM↑LB(st+1∣st,at)>0.
Therefore, the maximum upper bound counterfactual probability in this case is
Case 2: PM↑LB(s′∣st,at)>0 and PM↑UB(st+1∣st,at)PM↑LB(st+1∣s,a)≥PM↑LB(s′∣st,at)PM↑UB(s′∣s,a). This is a valid condition, because, by assumption, PLB(s′∣st,at)>0, and PLB(st+1∣st,at)>0 since this was the observed transition (Assumption B.2).
If this condition holds, then, for every M∈M↑, PM(st+1∣st,at)PM(st+1∣s,a)≥PM(s′∣st,at)PM(s′∣s,a), and so, for every M∈M↑ the upper bound counterfactual probability must be 0, to satisfy the counterfactual stability constraint. Therefore, we know the maximum upper bound counterfactual probability P~↑UB(s′∣s,a) will be:
Case 3: PM↑LB(s′∣st,at)>0. If PLB(s′∣st,at)>0, then, for all MDPs M∈M↑, the counterfactual probability of the transition P~M,t(s′∣s,a)≤PM(s′∣s,a), due to the counterfactual monotonicity constraints.
For every MDP M∈M↑, the counterfactual probability P~M,tUB(s′∣s,a)=min(PM(s′∣s,a),1−PM(st+1∣s,a)), as long as the counterfactual stability constraint does not constrain the counterfactual probability to 0. This leads to the following optimisation problem:
Because of Assumption B.1, there must exist an MDP M∈M↑ with
• PM(s′∣s,a)=PM↑UB(s′∣s,a)
• PM(st+1∣s,a)=PM↑LB(st+1∣s,a)
• PM(s′∣st,at)=PM↑LB(s′∣st,at)
• PM(st+1∣st,at)=PM↑UB(st+1∣st,at)
This MDP results in the maximum possible values of PM(s′∣s,a) and 1−PM(st+1∣s,a), therefore, this also produces the maximum possible value of min(PM(s′∣s,a),1−PM(st+1∣s,a)).
In this case, we know PM↑UB(st+1∣st,at)PM↑LB(st+1∣s,a)<PM↑LB(s′∣st,at)PM↑UB(s′∣s,a) (otherwise, we would be in Case 2), therefore for this MDP M, the counterfactual stability constraint will not constrain the counterfactual transition probability P~M,t(s′∣s,a). Therefore, the maximum counterfactual probability across all MDPs M∈M↑ will be:
Case 4: PM↑UB(s′∣st,at)=0. If PM↑UB(s′∣st,at)=0, then, for all MDPs M∈M↑, PMUB(s′∣st,at)=0. Therefore, the upper bound counterfactual probability of the transition for all MDPs M∈M↑ is as follows:
Because of Assumption B.1, there must exist an MDP M∈M↑ where:
• PM(st+1∣s,a)=PM↑LB(st+1∣s,a)
• PM(s′∣s,a)=PM↑UB(s′∣s,a)
• PM(st+1∣st,at)=PM↑LB(st+1∣st,at)
Also, note that because of Assumption B.2, PM↑LB(st+1∣st,at)>0.
This MDP results in the maximum possible values of 1−PM(st+1∣s,a) and PM(st+1∣st,at)PM(s′∣s,a), and therefore produces the maximum possible value of min(1−PM(st+1∣s,a),PM(st+1∣st,at)PM(s′∣s,a)).
Therefore, the maximum counterfactual probability across all MDPs M∈M↑ will be:
Case 5: PM↑LB(s′∣st,at)=0 and PM↑UB(s′∣st,at)>0. For every MDP M∈M↑, the counterfactual probability of P~M,t(s′∣s,a) depends on the value of PM(s′∣st,at):
• If PM(s′∣st,at)>0, then the counterfactual probability of the transition will either be P~M,t(s′∣s,a)=min(PM(s′∣s,a),1−PM(st+1∣s,a)), because of the counterfactual monotonicity constraint, or 0 if the counterfactual stability constraint holds.
• Otherwise, if PM(s′∣st,at)=0, then the counterfactual probability of the transition P~M,t(s′∣s,a)=min(1−PM(st+1∣s,a),PM(st+1∣st,at)PM(s′∣s,a)).
Because ∀M∈M↑,0<PM(st+1∣st,at)≤1 we have, for all MDPs M∈M↑:
Therefore, the counterfactual transition probability for MDPs where PM(s′∣st,at)=0 will always be greater than or equal to the counterfactual transition probability when PM(s′∣st,at)>0. Because of Assumption B.1, and since PM↑LB(s′∣st,at)=0, there must exist an MDP M∈M↑ where:
This assignment leads to the maximum possible value of min(1−PM(st+1∣s,a),PM(st+1∣st,at)PM(s′∣s,a)). Therefore, the maximum upper bound counterfactual probability is:
B.3.2 Lower Bound. Because the lower bound closed-form solutions for each MDP M contain ∑s′∈S∖{s′}P~M,tUB(s′∣s,a), this makes it challenging to identify the minimum lower bound counterfactual probability across all MDPs M∈M↑. Because of this, we provide two solutions: a closed-form solution for a non-tight lower bound, and a reduced optimisation problem that solves for the exact lower bound as efficiently as possible.
Solution 1: Non-tight Lower Bound.
Theorem B.7. Assume (s,a)=(st,at), and assume that the support of (s,a) overlaps with the support of (st,at) in the IMDP M↑. In this case, the optimisation problem in (8) will produce a lower bound that is guaranteed to be no smaller than:
Case 1: s′=st+1. Because of Assumption B.2, for any MDP M∈M↑, PM(st+1∣st,at)>0 since this was the observed transition. Therefore, for any MDP M∈M↑, the monotonicity assumption ensures that P~M,t(st+1∣s,a)≥PM(st+1∣s,a), and the closed-form solution is:
We need to minimise this condition over all MDPs M∈M↑. We can immediately see that the minimum values of each part of the closed-form solution, i.e., PM(st+1∣s,a) and
1−∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a) will occur in the same MDP M. This is because, to minimise 1−∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a), we need to identify an MDP M which maximises the value of ∑s′′∈S∖{st+1}PM,t(s′′∣s,a). Clearly, the maximum value of ∑s′′∈S∖{st+1}P~M,t(s′′∣s,a) is 1−PM↑LB(st+1∣s,a), and the minimum value of PM(st+1∣s,a) across all MDPs M∈M↑ is PM↑LB(st+1∣s,a). Therefore, we can consider each part of this closed-form solution separately.
Now, consider the minimum value of 1−∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a) across all MDPs M∈M↑. In any MDP M∈M↑, we require the transition probabilities from every state-action pair to sum to 1. Because of this, it is challenging to determine the MDP with the greatest value of ∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a). However, to identify a non-tight lower bound, we can ignore this constraint, and instead find the value of ∑s′′∈S∖{st+1}P~M↑,tUB(s′′∣s,a) across the whole IMDP M↑. Clearly, ∑s′′∈S∖{st+1}P~M↑,tUB(s′′∣s,a)≥∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a) for any MDP M∈M↑, so 1−∑s′′∈S∖{st+1}P~M↑,tUB(s′′∣s,a) results in a lower bound.
Therefore, a minimum (but not necessarily tight) lower bound would be:
Case 2: PM↑UB(s′∣st,at)>0 and PM↑LB(st+1∣st,at)PM↑UB(st+1∣s,a)≥PM↑UB(s′∣st,at)PM↑LB(s′∣s,a). This is a valid condition, because, by assumption, PM↑UB(s′∣st,at)>0, and PM↑UB(st+1∣st,at)≥PM↑LB(st+1∣st,at)>0 since this was the observed transition (Assumption B.2).
Because of Assumption B.1, there must exist an MDP M∈M↑ with:
• PM(s′∣s,a)=PM↑LB(s′∣s,a)
• PM(st+1∣s,a)=PM↑UB(st+1∣s,a)
• PM(s′∣st,at)=PM↑UB(s′∣st,at)
• PM(st+1∣st,at)=PM↑LB(st+1∣st,at)
Therefore, for this MDP M, PM(st+1∣st,at)PM(st+1∣s,a)≥PM(s′∣st,at)PM(s′∣s,a), and so the lower bound counterfactual probability for P~M,tLB=0, to satisfy the counterfactual stability constraint. Since the counterfactual probability of any transition cannot be smaller than 0, we know the minimum lower bound counterfactual probability across all MDPs M∈M↑, P~M↑,tLB(s′∣s,a) will be:
Case 3: PM↑UB(s′∣st,at)>0 and PM↑LB(st+1∣st,at)PM↑UB(st+1∣s,a)<PM↑UB(s′∣st,at)PM↑LB(s′∣s,a), or PM↑UB(s′∣st,at)=0. In this case, because either PM↑UB(s′∣st,at)>0 and PM↑LB(st+1∣st,at)PM↑UB(st+1∣s,a)<PM↑UB(s′∣st,at)PM↑LB(s′∣s,a), or PM↑UB(s′∣st,at)=0, then, for every MDP M∈M↑, either PM(s′∣st,at)>0 and PM(st+1∣st,at)PM(st+1∣s,a)<PM(s′∣st,at)PM(s′∣s,a), or PM(s′∣st,at)=0. Therefore, the closed-form solution for every MDP M∈M↑ will be:
We need to minimise this condition over all MDPs M∈M↑. Clearly, the counterfactual probability of any transition cannot be any smaller than 0. Therefore, if there exists an MDP M∈M↑ where P~M,tLB(s′∣s,a)=0, then the absolute minimum value of P~M↑,tLB(s′∣s,a)=0 as well. The minimum lower bound counterfactual probability P~M↑,tLB(s′∣s,a) will only be greater than 0 if for every MDP M∈M↑, 1−∑s′′∈S∖{s′}P~M,tUB(s′′∣s,a)>0.
Now, consider the minimum value of 1−∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a). In any MDP M∈M↑, we require the transition probabilities from every state-action pair to sum to 1. Because of this, it is challenging to determine the MDP with the greatest value of ∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a). However, to identify a non-tight lower bound, we can ignore this constraint, and instead find the value of ∑s′′∈S∖{st+1}P~M↑,tUB(s′′∣s,a) across the whole IMDP M↑. Clearly, ∑s′′∈S∖{st+1}P~M↑,tUB(s′′∣s,a)≥∑s′′∈S∖{st+1}P~M,tUB(s′′∣s,a) for any MDP M∈M↑, so 1−∑s′′∈S∖{st+1}P~M↑,tUB(s′′∣s,a) results in a lower bound.
Therefore, a minimum (but not necessarily tight) lower bound would be:
max0,1−s′∈S\{s′}∑P~M↑,tUB(s′∣s,a)
Solution 2: Reducing the Optimisation Problem. Alternatively, if it is computationally feasible, we can calculate the exact lower bound for the counterfactual probability of any transition by calculating the true minimum value of 1−∑s′′∈S∖{s′}P~M↑,tUB(s′′∣s,a), for Cases 1 and 3 in Solution 1. This can be solved by maximising the value of ∑s′′∈S∖{s′}P~M↑,tUB(s′′∣s,a), in a nested optimisation problem, as follows:
This works, because we have proven in existing work that the counterfactual probability of any given transition depends only on the interventional distributions from the observed state-action pair (st,at) and the counterfactual state-action pair (s,a) (hence the closed-form solution for P~tUB(s′∣s,a) depends only on these two distributions), so we don’t need to consider any other state-action pair in our optimisation.
Given this nested optimisation, we can correctly calculate the lower bounds in Cases 1 and 3 as follows:
where PM is the MDP's transition probabilities, St, At and St+1 are endogenous variables representing the state, action and next state, and the values of the exogenous variable Ut=(Gs,t)s∈S are sampled from the standard Gumbel distribution 4.
Algorithm 1 Gumbel-max Topdown Sampling
Input: logits, observed st+1, number of samples nsamp=1
gumbels[:, i] ← sample nsamp values from Gumbel(0,1) {Unconstrained state}
end if
end for
return gumbels
We can perform (approximate) posterior inference of P((Gs,t)s∈S∣st,at,st+1) through rejection sampling [23], or the top-down Gumbel sampling [19] algorithm, given in Algorithm 1. This algorithm returns a finite sample of values from the posterior Gumbel distribution, Gs,t′. The counterfactual transition probabilities can then be calculated as follows:
Given an IMDP M↑, we can derive conservative bounds for counterfactual transition probabilities as follows;
Theorem C.1. Given an arbitrary IMDP M↑, observed transition st,at→st+1, and counterfactual transition s,a→s′, under the Gumbel-max SCM the counterfactual transition probabilities of the observed state-action pair are exact for all M∈M↑: P~t(st+1∣st,at)=1 and P~t(s′∣st,at)=0 for all s′=st+1.
For (s,a)=(st,at), a lower bound for the counterfactual transition probability across all MDPs M∈M↑, produced by the Gumbel-max SCM, is given by:
and Gq,t′ is derived given PM(s′∣st,at)=PM↑LB(s′∣st,at), and ∀s′′=s′,PM(s′′∣st,at)=PM↑UB(s′′∣st,at).
4This formulation relies on the Gumbel-max trick [19] by which sampling from a categorical distribution with n categories is equivalent to sampling n values g1,…,gn from the standard Gumbel distribution and evaluating argmaxj{log(P(Y=j))+gj} over all the categories, where Y is the output.
PROOF. We first consider the observed state-action pair (st,at). For any M∈M↑, its corresponding Gumbel-max SCM produces counterfactual probabilities P~M,t(st+1∣st,at)=1 and P~M,t(s′∣st,at)=0 for all s′=st+1, since the posterior Gumbel values are, by construction, those for which st+1 is the arg max under the same logits. These bounds are therefore exact.
For the remaining state-action pairs (s,a)=(st,at), let us consider the lower counterfactual probability bound (the proof for the upper counterfactual probability bound follows similarly by reversing all bounds throughout). To derive the lower counterfactual probability bound, we need to consider how we can minimise P~M,t(s′∣s,a) across all M∈M↑:
First, we assume the IMDP satisfies the normalisation assumption (Assumption B.1).
Next, from (13), we can see that the counterfactual transition probabilities depend only on the logits of the observed state-action pair (st,at) and the counterfactual state-action pair (s,a). This means we only need to consider these logits within their bounds to determine the upper and lower bounds of the counterfactual transition probability for any transition. Also, from (13), we can see that to minimise the counterfactual transition probability PM,t(s′∣s,a), we must minimise the number of samples where s′ is the arg max over all states q∈S (and vice versa for maximising the counterfactual probability). To achieve this, we need to minimise both logPM(s′∣s,a) and Gs′,t′, while maximising the corresponding quantities logPM(q∣s,a) and Gq,t′ of all other states q=s′.
Clearly, we can minimise logPM(s′∣s,a) by setting PM(s′∣s,a)=PM↑LB(s′∣s,a), and maximise logPM(q∣s,a) for each q=s′ by setting PM(q∣s,a)=PM↑UB(q∣s,a). Note that we take these extremal values for each next state individually, so together they need not form a valid probability distribution (i.e., they need not correspond to any admissible MDP M∈M↑); as we show below, this still yields a valid, though possibly not tight, lower bound.
Now, we need to consider how to minimise the posterior Gumbel distribution Gs′,t′, which is derived from the top-down sampling algorithm in Algorithm 1. Note that the Gumbel values are determined entirely by the logits of the observed state-action pair, logPM(⋅∣st,at). We will examine the following disjoint cases separately.
Case 1: s′=st+1. In this case, the Gumbel values are given by
topgumbel−logPM(st+1∣st,at),
where topgumbel is sampled from the standard Gumbel distribution. Therefore, to minimise the Gumbel values, we need to maximise logPM(st+1∣st,at). Since logPM(st+1∣st,at)≤0 (because 0≤PM(st+1∣st,at)≤1), this maximum is achieved when
PM(st+1∣st,at)=PM↑UB(st+1∣st,at).
Case 2: s′=st+1 and PM↑LB(s′∣st,at)>0. If s′=st+1 and PM↑LB(s′∣st,at)>0, then the top-down sampling algorithm produces the following Gumbel values, across all MDPs M∈M↑:
which is strictly negative, since exp(x)>0 for all real x.
Therefore, the minimum Gumbel value Gs′,t′ occurs when L is maximised, i.e.,
PM(s′∣st,at)=PM↑UB(s′∣st,at)
Case 3: s′=st+1 and PM↑UB(s′∣st,at)=0. If PM↑UB(s′∣st,at)=0, i.e., s′ is not in the support of (st,at), then the Gumbel values for s′ are drawn from the standard Gumbel distribution. In this case, adjusting the logits for PM(⋅∣st,at) has no impact on the posterior Gumbel distribution, and therefore no effect on the counterfactual transition probability.
Case 4: s′=st+1, PM↑LB(s′∣st,at)=0, and PM↑UB(s′∣st,at)>0. If PM↑LB(s′∣st,at)=0 and PM↑UB(s′∣st,at)>0, then depending on the choice of MDP M∈M↑, the top-down sampling algorithm could fall into different cases. However, the truncated Gumbel values (which occur when PM(s′∣st,at)>0) are always smaller than Gumbel values sampled from the standard Gumbel distribution (which occur when PM(s′∣st,at)=0). Therefore, to minimise the lower counterfactual probability, we should select an MDP where P(s′∣st,at)>0. Moreover, as shown in Case 2, the minimum Gumbel values for such an MDP occur when
PM(s′∣st,at)=PM↑UB(s′∣st,at).
Therefore, in all cases, we should derive Gs′,t′ given PM(s′∣st,at)=PM↑UB(s′∣st,at) to minimise Gs′,t′; by the same argument (Case 2), the remaining posterior Gumbel values Gq,t′,q=s′, are maximised by setting PM(q∣st,at)=PM↑LB(q∣st,at). As before, these extremal values are chosen for each next state individually and need not form a valid distribution.
However, since the derivation depends on the realised Gumbel samples, we cannot deterministically specify which state will be the arg max sample for a given choice of transition probabilities. But, for any fixed realisation of the Gumbel samples g and topgumbel, whether s′ is the arg max is monotone increasing in its interventional logit logPM(s′∣s,a) and posterior Gumbel value Gs′,t′, and monotone decreasing in those of every other state q=s′; hence so is the probability that s′ is the arg max. Therefore, although the arg max outcome itself is random, we can minimise the probability that s′ is selected by minimising the former and maximising the latter.
Take the following assignment of interventional probabilities:
If there exists an MDP M∈M↑ with this assignment of probabilities, this assignment simultaneously minimises PM(s′∣s,a) and Gs′,t′ and maximises those of all other states, and therefore minimises the probability that s′ will be the arg max, leading to a tight lower bound.
If no admissible MDP satisfies this assignment exactly, we may still evaluate the Gumbel-max expression at these extremal logits. Since the probability of the arg max event is monotone in each logit (increasing in those of s′ and decreasing in those of all other states), evaluating it at these extremal (possibly infeasible) logits yields a conservative lower bound.
where P^LB(q∣s,a)=PM↑LB(s′∣s,a) if q=s′ and PM↑UB(q∣s,a) otherwise, and Gq,t′ is derived given PM(s′∣st,at)=PM↑UB(s′∣st,at) and ∀s′′=s′,PM(s′′∣st,at)=PM↑LB(s′′∣st,at).
The proof for the upper bound follows similarly, by taking the opposite IMDP bounds throughout.
In our experiments, we estimate these bounds using (12) with N=10,000 samples from the posterior Gumbel distribution per transition. For the observed state-action pair (st,at), we fix the counterfactual transition probabilities to 1 for the observed next state st+1 and 0 for all other states, since under the Gumbel-max SCM the counterfactual of the observed state-action pair always reproduces st+1 (as in Theorem B.3). Because the remaining bounds are estimated by sampling, we clip them to [0,1] and, where sampling error places the lower bound above the upper bound, set the two equal. Finally, we rescale the lower bounds of each distribution to sum to at most 1 and the upper bounds to sum to at least 1, to ensure we have a valid CFIMDP.
D Confidence Intervals over Counterfactual IMDP
Given a finite set of observed transitions in an MDP, we can build an interval MDP where transition probabilities are represented as intervals, capturing uncertainty in the transition probabilities due to limited data. For a given state-action pair, (s,a), we can simulate a large number of transitions, and calculate:
• m(s,a): number of times action a was taken in state s.
• n(s,a,s′): number of times the system transitioned to state s′ after being in state s and taking action a.
• Empirical probability P^(s′∣s,a)=m(s,a)n(s,a,s′).
D.1 Confidence Intervals
There are several methods we could use to produce confidence intervals over the probability of each transition. We require all transition probabilities to lie within their intervals simultaneously with probability at least 1−α. To achieve this, we distribute the overall confidence evenly across all nondeterministic transitions: by a union bound, it suffices to compute each interval at confidence level 1−α′, where α′=α/∣T′∣ and T′ is the set of nondeterministic transitions 5. There are several methods we could use to produce confidence intervals over the probability of each transition:
• Hoeffding’s inequality provides a high-probability bound on the deviation between the true transition probability P(s′∣s,a) and P^(s′∣s,a). For a confidence level of 1−α′,
Pr(∣P(s′∣s,a)−P^(s′∣s,a)∣≥η)≤2e(−2⋅m(s,a)⋅η2)
where
η=2⋅m(s,a)ln(2/α′)
is chosen so that the right-hand side equals α′. We can then construct an interval MDP as follows. For each transition s,a→s′, we estimate its interval transition probability as:
The Clopper–Pearson method provides an exact (1−α′) confidence interval for a binomial proportion based on the cumulative distribution function of the binomial distribution. For a confidence level of 1−α′, the Clopper–Pearson interval is given by:
where Beta−1(q;a,b) denotes the q-quantile of the Beta(a,b) distribution. These intervals are typically tighter than those from Hoeffding's inequality, so we use the Clopper–Pearson method in all our experiments.
D.2 Construction and Normalisation of the IMDP
In our approach, we use the Clopper–Pearson method to estimate the IMDP. The resulting intervals are then normalised to satisfy Assumptions B.1 and B.2, which ensure that counterfactual probabilities can be computed over the IMDP.
We have constructed the IMDP such that for any transition s,a→s′ in the MDP,
Pr(P(s′∣s,a)∈/PM↕(s′∣s,a))≤α
where PM↕(s′∣s,a) is the true transition probability.
D.3 Propagation of Confidence to the CFIMDP
PROOF OF PROPOSITION 4.2. For now, assume the derived counterfactual probability bounds are tight (we will consider what happens if we apply our non-tight lower bound later). Take our IMDP M↑ derived from observational data using the Clopper–Pearson bounds. By construction, the chance of any true transition probability lying outside the IMDP is at most α, i.e., Pr(∃s,a,s′:P(s′∣s,a)∈/PM↑(s′∣s,a))≤α.
Take an arbitrary transition s,a→s′. In the worst case, where the true transition probability for this transition is not contained in the bound [PM↑LB(s′∣s,a),PM↑UB(s′∣s,a)], the corresponding counterfactual probability bounds could be entirely disjoint from those in our CFIMDP (though in practice, some overlap is likely). However, the counterfactual bounds are exact given the true transition (interventional) probabilities, and, by construction, all true transition probabilities lie within the estimated IMDP with probability at least 1−α. Hence, with probability at least 1−α, all true counterfactual transition probabilities lie within their CFIMDP intervals simultaneously. Therefore, we can propagate the confidence bound through to the CFIMDP: the CFIMDP will contain the true counterfactual MDP (CFMDP) with probability at least 1−α.
5Since the topology of the MDP is known, deterministic transitions have probability exactly 1 and require no confidence interval.
Finally, when we use a non-tight lower bound for the CFIMDP, this will be an over-approximation (which includes all valid CFMDPs and possibly some invalid ones). Therefore, this only increases our confidence that the computed counterfactual probability bounds contain the true counterfactual transition probability.
E IMDP Value Iteration with Max Changes
Algorithm 2 IMDP Value Iteration with Max Changes
Input: CFIMDP M~τ↑ with bounds P~t↑, observed path τ, maximum number of changes K
Output: values V∗, policies πk∗ for k=0,…,K
for s∈S, k=0 to K do
V∗(s,∣τ∣,k)←0
end for
for t=∣τ∣−1 down to 0 do
for k=0 to K do
for s∈S do
best ←−∞
for a∈A do
if k=0 and a=at then
continue {no changes remaining}
end if
k′←k−1{a=at}Q←R(s,a)+minP~t∈P~t↑∑s′P~t(s′∣s,a)V∗(s′,t+1,k′)
if Q>best then
best ←Q; πk∗(t,s)←a
end if
end for
V∗(s,t,k)←best
end for
end for
end for
return V∗,{πk∗}k=0K
F Environment Descriptions and System Details
Below, we provide brief descriptions of the MDP environments and system specifications used in our experiments. The same environments as Lally et al. [17] are used to allow for comparison.
F.1 GridWorld
In the GridWorld MDP, an agent navigates a 4×4 grid starting from the top-left corner with the objective of reaching the goal state in the bottom-right corner. At each time step, the agent can choose to move up, down, left, or right; however, it moves only in the chosen direction with probability p, otherwise moving in a random direction. Reaching the goal state yields a reward of 100, and intermediate transitions provide shaped rewards proportional to the agent's proximity to the goal. The grid also contains a hazardous, terminal state in the centre, and entering it incurs a penalty of −100. In our experiments, we use two variants of the environment with different values of p, p=0.9 (i.e., 90% chance of moving in the chosen direction) and p=0.4.
F.2 Frozen Lake
The Frozen Lake MDP is adapted from PRISM [10, 16]. In this environment, the agent navigates a 4×4 grid to retrieve a frisbee, while avoiding a set of holes scattered across the grid. Since the original PRISM environment is formulated as a reachability problem, the environment has been converted to a reward-based setting, which yields a reward of 100 for successfully reaching the frisbee, and a penalty of −100 for falling into a hole. Both the goal state and states with holes are terminal.
F.3 Sepsis
The Sepsis MDP [23] simulates patient trajectories in a sepsis treatment setting. At each time step, the patient's state is defined by four vital signs (heart rate, blood pressure, oxygen concentration, and glucose levels), each categorised as low, in normal range, or high. The RL agent controls three treatments (which can be switched on or off), with the goal of discharging the patient (which occurs when at least three of the vital signs are in normal range, and all three treatments are switched off). The patient dies if at least three vital signs are out of normal range at any time step. Rewards are shaped by the number of vital signs that are out of normal range, ranging from −1000 for patient death to +1000 for patient discharge.
F.4 Aircraft
The Aircraft MDP is a navigation task, also adapted from PRISM [10, 16]. In this environment, the RL agent controls an aircraft that advances forward by one unit at each time step, and must choose to increase, decrease, or maintain its altitude, with a fixed probability of success. The goal is to successfully reach the right-hand side of the grid without colliding with another aircraft, which independently increases, decreases, or maintains its current altitude at each time step. Since the original PRISM environment is formulated as a reachability problem, it has been converted to a reward-based setting, which yields a reward of +100 for reaching the goal or a penalty of -100 for colliding with the other aircraft. Intermediate transitions receive a shaped reward inversely proportional to the proximity of the two aircraft.
F.5 System Specification
Our experiments were run in parallel using 32 threads on a 128-core machine with an Intel Xeon CPU and 512 GB RAM. Simulation of IMDPs and construction of the corresponding CFIMDPs were implemented in Python 3.10, while our extended value iteration algorithm was implemented by extending the Julia Interval MDP package (v0.6.0) with the algorithm described in Appendix E.
G Additional Experiments
G.1 Correctness for Off-policy Evaluation Experiment: GridWorld (p=0.4)
Table 4: Given 100 randomly sampled observed trajectories, we compare the average lower and upper bounds, V⊥,π∗(s0) and V⊤,π∗(s0), on the counterfactual value under the exact CFIMDP with those under data-driven CFIMDPs, whose IMDPs are learnt from N simulated trajectories. Averaged over observed trajectories, the counterfactual value equals the interventional value, so every pair of bounds should contain the true interventional value Vπ∗(s0)=−40.1.
Lower Bound
Upper Bound
Exact Bounds
−192±163
102±154
Data-driven Bounds
N=10,000
−284±168
144±143
N=100,000
−232±164
125±136
N=1,000,000
−221±162
119±138
The results for the GridWorld (p=0.4) experiment closely mirror those of the GridWorld (p=0.9) experiment in Section 5.1, further confirming that our approach is valid and unbiased, as the data-driven CFIMDP bounds again consistently contain the true expected return, and converge towards the exact bounds as the number of trajectories increases.
Figure 5 gives a more detailed view of the Sepsis counterfactual paths summarised in Figure 4. For the same catastrophic observed trajectory and each k, we plot 200 counterfactual paths sampled under the policy πk∗ and an adversarially chosen CFMDP within the exact CFIMDP. Each row shows one component of the patient's state over time: heart rate, systolic blood pressure, oxygen saturation and glucose, followed by the three treatments (antibiotics, vasopressors and ventilation). With k=0, the counterfactual paths follow the observed treatments and the patient's vital signs deteriorate as observed. As k increases, πk∗ may change more of the observed treatments, and the vital signs of more counterfactual patients return to the normal range (dotted lines), consistent with the rise in recovery shown in Figure 4.
observed path
counterfactual path (observed action)
counterfactual path (action changed)
Figure 5: Counterfactual Sepsis trajectories for one catastrophic observed trajectory, under πk∗ for varying numbers of allowed action changes k. Rows show the patient's vital signs and applied treatments over time. The observed path is shown in black, and the 200 sampled counterfactual paths in blue, or red at steps where an action differs from the observed one (in the treatment rows, where that treatment was changed). Dotted lines mark the normal range of each vital sign.
G.3 Execution Times and Bound Widths
Table 5: Left: effect on CFIMDP transitions of using tight (but more expensive) bounds in place of conservative closed-form bounds. Right: comparison of runtimes for constructing the CFIMDP (using N=100,000, α=0.1 and averaging over 100 randomly generated suboptimal paths).
Environment
Bound Width Statistics
Execution Time (s)
Transitions Affected (%)
Avg Difference in Width
Exact CFIMDP
Data-driven CFIMDP (Cons. LB)
Data-driven CFIMDP (Exact LB)
Data-driven CFIMDP (Gumbel-max)
All
Non-zero
All
Non-zero
GridWorld (p=0.9)
4.37±0.46
20.6±2.1
4.89×10−4±7.6×10−5
0.0112±0.0013
1.67±0.08
1.71±0.09
2.64±0.13
1.55±0.07
GridWorld (p=0.4)
1.14±0.74
5.5±3.5
2.8×10−4±3.9×10−4
0.018±0.014
1.62±0.12
1.65±0.06
2.40±0.11
1.55±0.10
Sepsis
0.0041±0.0050
1.0±1.2
3.9×10−7±3.3×10−7
0.024±0.013
57.2±3.9
141±31
1430±580
−†
Frozen Lake
0.19±0.12
1.49±0.91
1.5×10−5±1.2×10−5
0.0070±0.0029
2.24±0.11
2.34±0.11
3.75±0.30
2.03±0.10
Aircraft
0.0097±0.0052
0.90±0.48
5.7×10−6±3.3×10−6
0.059±0.011
7.9±1.8
10.0±1.9
85±13
293±7
† We omit Sepsis, as generating its Gumbel-max CFIMDPs is computationally prohibitive.