Pushdown Reward Machines for Reinforcement Learning
Giovanni Varricchione, Toryn Q. Klassen, Natasha Alechina, Mehdi Dastani, Brian Logan, Sheila A. McIlraith
TL;DR
This work extends reward machines by introducing pushdown reward machines (pdRMs) that leverage a single stack to represent deterministic context-free languages, enabling rewards for temporally extended behaviors beyond regular languages. It defines two policy families for pdRMs—full-stack policies and top-$k$ policies—and provides a criterion to determine when top-$k$ policies can attain the same value as full policies, along with formal analyses of expressive power and space complexity. The paper compares pdRMs with counting reward automata (CRAs), showing that pdRMs can offer more compact representations in certain regimes while acknowledging CRA expressiveness can exceed that of pdRMs for multiple counters. It also introduces CpRM, a counterfactual learning extension for pdRMs, and demonstrates through five domains that pdRMs can achieve strong sample efficiency and competitive performance in both discrete and continuous settings, sometimes outperforming recurrent neural approaches. Overall, pdRMs provide a principled, scalable framework for encoding and learning with deterministic context-free rewards, with practical benefits in tasks requiring memory of structured sequences.
Abstract
Reward machines (RMs) are automata structures that encode (non-Markovian) reward functions for reinforcement learning (RL). RMs can reward any behaviour representable in regular languages and, when paired with RL algorithms that exploit RM structure, have been shown to significantly improve sample efficiency in many domains. In this work, we present pushdown reward machines (pdRMs), an extension of reward machines based on deterministic pushdown automata. pdRMs can recognise and reward temporally extended behaviours representable in deterministic context-free languages, making them more expressive than reward machines. We introduce two variants of pdRM-based policies, one which has access to the entire stack of the pdRM, and one which can only access the top $k$ symbols (for a given constant $k$) of the stack. We propose a procedure to check when the two kinds of policies (for a given environment, pdRM, and constant $k$) achieve the same optimal state values. We then provide theoretical results establishing the expressive power of pdRMs, and space complexity results for the proposed learning problems. Lastly, we propose an approach for off-policy RL algorithms that exploits counterfactual experiences with pdRMs. We conclude by providing experimental results showing how agents can be trained to perform tasks representable in deterministic context-free languages using pdRMs.
