SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2104.03946 · ICLR · 2021

Learning What To Do by Simulating the Past

Anca Dragan, Pieter Abbeel, Rohin Shah, David Lindner

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 4 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 2 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2104.03946.json · badge: /api/ran/2104.03946.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
HumanCompatibleAI/deep-rlsp canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
baseline_state_distributions Ran
ran, honoured the contract we drafted
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/relative_reachability.py
code served (permissive licence) · get_code("6300d079d0db6635")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

class SimpleMDP:
    def __init__(self, num_states, baseline_matrix):
        self.nS = num_states
        self.baseline_matrix_transpose = baseline_matrix

# Create a simple MDP with 5 states
num_states = 5
# Create a transition matrix transpose (5x5)
# Each column should sum to 1 (valid probability distribution)
baseline_matrix = np.array([
    [0.5, 0.2, 0.1, 0.0, 0.3],
    [0.3, 0.3, 0.2, 0.4, 0.1],
    [0.1, 0.3, 0.4, 0.3, 0.2],
    [0.05, 0.15, 0.2, 0.2, 0.3],
    [0.05, 0.05, 0.1, 0.1, 0.1]
], dtype=np.float32)

mdp = SimpleMDP(num_states, baseline_matrix)

ARGS = {
    "mdp": mdp,
    "horizon": 3,
    "start": 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
compute_d_last_step Ran
ran; our contract draft was wrong, not the code
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/rlsp.py
code served (permissive licence) · get_code("7b90883f18025f04")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 1, dtype family float, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a simple MDP class with T_matrix_transpose attribute
class SimpleMDP:
    def __init__(self):
        # T_matrix_transpose should be a matrix that when dotted with flattened state-action probs
        # returns state occupancies
        # state_action_prob will be of shape (num_states, num_actions) flattened to (num_states * num_actions,)
        # We need T_matrix_transpose to map from (num_states * num_actions,) to (num_states,)
        # So T_matrix_transpose should be shape (num_states, num_states * num_actions)
        num_states = 4
        num_actions = 3
        self.T_matrix_transpose = np.random.randn(num_states, num_states * num_actions)

mdp = SimpleMDP()

# Initial state probability distribution
# Should be shape (num_states,) since D starts as p_0
p_0 = np.array([0.25, 0.25, 0.25, 0.25])

# Policy: list of T-1 elements, each is a (num_states, num_actions) matrix
T = 5
num_states = 4
num_actions = 3
policy = [np.random.rand(num_states, num_actions) for _ in range(T - 1)]

# Normalize policy to be valid probability distributions
for t in range(len(policy)):
    policy[t] = policy[t] / policy[t].sum(axis=1, keepdims=True)

gamma = 1.0
verbose = False
return_all = False

ARGS = {
    "mdp": mdp,
    "policy": policy,
    "p_0": p_0,
    "T": T,
    "gamma": gamma,
    "verbose": verbose,
    "return_all": return_all
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
encode_transition_data Ran
ran; our contract draft was wrong, not the code
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/model/dynamics_mdn.py
code served (permissive licence) · get_code("d825d0c7b407d326")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleEncoder(nn.Module):
    """Minimal encoder that takes a tensor and outputs a latent representation."""
    def __init__(self, input_dim=4, latent_dim=3):
        super().__init__()
        self.linear = nn.Linear(input_dim, latent_dim)
    
    def forward(self, x):
        return self.linear(x)

class LatentSpace:
    """Stand-in latent space with an encoder method."""
    def __init__(self):
        self.encoder = SimpleEncoder(input_dim=4, latent_dim=3)

# Create sample transition data
# states: list of 2 state tensors, each of shape (4,)
# actions: list of 2 action tensors, each of shape (2,)
# next_states: list of 2 next state tensors, each of shape (4,)
states = [torch.randn(4), torch.randn(4)]
actions = [torch.randn(2), torch.randn(2)]
next_states = [torch.randn(4), torch.randn(4)]

data = (states, actions, next_states)

latent_space = LatentSpace()

ARGS = {
    "latent_space": latent_space,
    "data": data,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_play_data Ran
ran; our contract draft was wrong, not the code
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/model/dynamics_mdn.py
code served (permissive licence) · get_code("60d43411850523aa")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleEncoder(nn.Module):
    def __init__(self, input_dim, latent_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, latent_dim)
    
    def forward(self, x):
        return self.linear(x)

class LatentSpace(nn.Module):
    def __init__(self, input_dim=4, latent_dim=3):
        super().__init__()
        self.encoder = SimpleEncoder(input_dim, latent_dim)

latent_space = LatentSpace(input_dim=4, latent_dim=3)

# Create play_data with observations and actions
# 2 trajectories
observations = [
    [torch.randn(4), torch.randn(4), torch.randn(4)],  # trajectory 1: 3 observations
    [torch.randn(4), torch.randn(4)]  # trajectory 2: 2 observations
]

actions = [
    [torch.tensor([0.1, 0.2]), torch.tensor([0.3, 0.4])],  # trajectory 1: 2 actions (for 3 obs)
    [torch.tensor([0.5, 0.6])]  # trajectory 2: 1 action (for 2 obs)
]

play_data = {
    'observations': observations,
    'actions': actions
}

ARGS = {
    'latent_space': latent_space,
    'play_data': play_data
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_coverage Ran
ran, honoured the contract we drafted
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/relative_reachability.py
code served (permissive licence) · get_code("e233f51ce4afed18")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

class SimpleMDP:
    def __init__(self, nS, nA):
        self.nS = nS
        self.nA = nA
        # T_matrix should have shape (nS * nA, nS)
        # This represents transition probabilities for all state-action pairs
        self.T_matrix = np.random.rand(nS * nA, nS)

mdp = SimpleMDP(nS=4, nA=3)
horizon = 2

ARGS = {
    "mdp": mdp,
    "horizon": horizon
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (4, 4) — shape (4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_samples_from_trajectories Ran
ran, honoured the contract we drafted
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/policy_discriminator.py
code served (permissive licence) · get_code("609b7fc9cbb10c33")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Analyzing the function:
# - trajectories: a list of trajectories
# - each trajectory is a list of observations
# - each observation has length obs_len (accessed via len(trajectories[0][0]))
# - sample_length: an integer specifying how many observations to concatenate
# - the function extends samples with observations and creates chunks of size sample_length * obs_len

# Create sample trajectories
# obs_len = 3 (dimension of each observation)
# sample_length = 2 (we want 2 observations per sample)
# So each sample should have length 2 * 3 = 6

obs_len = 3
sample_length = 2

# Create trajectories: list of trajectories, each trajectory is a list of observations
# Each observation is a list of length obs_len
trajectories = [
    # First trajectory: 5 observations of length 3
    [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],
    # Second trajectory: 4 observations of length 3
    [[20, 21, 22], [23, 24, 25], [26, 27, 28], [29, 30, 31]],
    # Third trajectory: 6 observations of length 3
    [[40, 41, 42], [43, 44, 45], [46, 47, 48], [49, 50, 51], [52, 53, 54], [55, 56, 57]]
]

ARGS = {
    "trajectories": trajectories,
    "sample_length": sample_length
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
relative_reachability_penalty Ran
ran, honoured the contract we drafted
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/relative_reachability.py
code served (permissive licence) · get_code("237bd2a08627e422")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

class MDP:
    def __init__(self, nS, nA, T_matrix, baseline_matrix_transpose):
        self.nS = nS
        self.nA = nA
        self.T_matrix = T_matrix
        self.baseline_matrix_transpose = baseline_matrix_transpose

# Create a small MDP
nS = 4  # number of states
nA = 3  # number of actions

# T_matrix should be (nS * nA, nS) - transition matrix
# When reshaped to (nS, nA, nS), it represents P(s'|s,a)
T_matrix = np.random.rand(nS * nA, nS)
T_matrix = T_matrix / T_matrix.sum(axis=1, keepdims=True)  # normalize to probabilities

# baseline_matrix_transpose should be (nS, nS) - used for matrix multiplication with distributions
# This represents the transition probabilities for the baseline policy
baseline_matrix_transpose = np.random.rand(nS, nS)
baseline_matrix_transpose = baseline_matrix_transpose / baseline_matrix_transpose.sum(axis=0, keepdims=True)  # normalize

mdp = MDP(
    nS=nS,
    nA=nA,
    T_matrix=T_matrix,
    baseline_matrix_transpose=baseline_matrix_transpose
)

horizon = 3
start = 0

ARGS = {
    "mdp": mdp,
    "horizon": horizon,
    "start": start
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (3, 4) — shape (3, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
compute_feature_expectations Not yet run
unverified (harvested, no recorded run)
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/rlsp.py
code served (permissive licence) · get_code("ab56e0052ce4f077")
How it ran

no invocation recorded.

compute_g Not yet run
unverified (harvested, no recorded run)
HumanCompatibleAI/deep-rlsp/src/deep_rlsp/rlsp.py
code served (permissive licence) · get_code("69be236c06fdf0cd")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
compute_d_last_step 1 other paper
1 dated earlier
1902.04198 (2019-02)
Preferences Implicit in the State of the World
compute_g 1 other paper
1 dated earlier
1902.04198 (2019-02)
Preferences Implicit in the State of the World

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Since reward functions are hard to specify, recent work has focused on learning policies from human feedback. However, such approaches are impeded by the expense of acquiring such feedback. Recent work proposed that agents have access to a source of information that is effectively free: in any environment that humans have acted in, the state will already be optimized for human preferences, and thus an agent can extract information about what humans want from the state (Shah et al., 2019). Such learning is possible in principle, but requires simulating all possible past trajectories that could have led to the observed state. This is feasible in gridworlds, but how do we scale it to complex tasks? In this work, we show that by combining a learned feature encoder with learned inverse models, we can enable agents to simulate human actions backwards in time to infer what they must have done. The resulting algorithm is able to reproduce a specific skill in MuJoCo environments given a single state sampled from the optimal policy for that skill.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2104.03946")
get_code_for_paper("2104.03946")
have("2104.03946")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2104.03946.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2104.03946.svg)](https://syntology.ai/paper/2104.03946)

Connect an agent — have() is free.