arXiv:2610.09350cs.ROOct 2026

Manuscript Offprint

arXiv:2610.09350

Learning Unknown Constraints without Unsafe Data via Optimality and Counterfactual Regularization

Zhouyu Zhang, Chih-Yuan Chiu, Glen Chou

Zhouyu Zhang

School of Electrical and Computer Engineering

Georgia Institute of Technology

Atlanta, GA 30309

zzhang3097@gatech.edu

Chih-Yuan Chiu

School of Electrical and Computer Engineering

Georgia Institute of Technology

Atlanta, GA 30309

cyc@gatech.edu

Glen Chou

School of Cybersecurity and Privacy

School of Aerospace Engineering

Georgia Institute of Technology

chou@gatech.edu

ABSTRACT

Learning from demonstrations (LfD) provides a framework for inferring unknown constraints from locally optimal, constraint-satisfying expert behavior. Existing approaches largely fall into two paradigms, constrained inverse optimal control (CIOC) and inverse constrained reinforcement learning (ICRL). CIOC exploits optimality conditions such as the Karush–Kuhn–Tucker (KKT) conditions but typically assumes known dynamics and structured constraint representations. Meanwhile, ICRL accommodates complex unknown constraints and unknown transition dynamics but often requires extensive online exploration, during which unsafe constraint violations may occur. In this work, we introduce Counterfactual KKT (CF-KKT), a constraint learning framework that leverages learned dynamics and locally optimal demonstrations to recover unknown constraints without requiring known dynamics or additional risky exploration, thereby combining the data efficiency and safety advantages of CIOC with the flexibility of ICRL. First, we use a locally learned differentiable dynamics model to impose KKT-inspired optimality conditions directly on the demonstrations. Second, we use the learned dynamics to generate reward-improving counterfactual behaviors near the demonstrations, revealing behaviors that would be preferable in the absence of the unknown constraint and thus providing synthetic infeasible data. When the constraint parameterization is known, the same learned-dynamics framework enables direct CIOC-based parameter recovery, and we characterize its sensitivity to dynamics misspecification. Across high-dimensional robotic control tasks, our approach learns neural constraint representations with improved safety and data efficiency relative to state-of-the-art offline ICRL baselines.

1 INTRODUCTION

Autonomous systems deployed in safety-critical applications, such as autonomous driving and warehouse operations, must adhere to constraints that encode safety and task specifications (Altman, 1999; Achiam et al., 2017; Borkar, 2005; Mayne et al., 2000; Berberich et al., 2021; Magni & Scattolini, 2004). Given the difficulty of manually engineering such constraints and the advent of data-driven methods, learning from demonstration (LfD) has attracted increasing attention as a promising framework for recovering constraints from locally optimal and constraint-abiding expert trajectories (Chou et al., 2020b; 2022; Quan et al., 2024; Liu et al., 2023). LfD-based constraint learning paradigms are often either based on inverse optimal control (IOC) (Englert et al., 2017; Keshavarz et al., 2011; Johnson et al., 2013; Rickenbach et al., 2024; Wulfmeier et al., 2017; Chou et al., 2020b; a; 2018) or inverse constrained reinforcement learning (ICRL) (Scobee & Sastry, 2019; McPherson et al., 2021; Malik et al., 2021; Papadimitriou et al., 2022; Liu & Zhu, 2022; 2024; Park et al., 2020; Jang et al., 2023). IOC-based methods recover constraints by enforcing consistency with the Karush–Kuhn–Tucker (KKT) conditions that characterize the local optimality of a given set of demonstrations (Rickenbach et al., 2024; Menner et al., 2019; Nguyen et al., 2026; Zhang et al., 2026; Chiu et al., 2026) under the dynamics models (Rickenbach et al., 2024; Menner et al., 2019) and control methodology (Nguyen et al., 2026; Zhang et al., 2026; Chiu et al., 2026) from which the demonstrations were obtained. However, such methods assume access to known, smooth system dynamics, which precludes their applicability to high-dimensional, black-box systems. In contrast, ICRL-based constraint recovery (Scobee & Sastry, 2019; McPherson et al., 2021; Malik et al., 2021; Papadimitriou et al., 2022; Liu & Zhu, 2022; 2024; Park et al., 2020; Jang et al., 2023) accommodates unknown dynamics and flexible neural constraint representations. However, such methods usually require computation- (McPherson et al., 2021; Liu et al., 2023) and data-heavy (Scobee & Sastry, 2019; Liu & Zhu, 2022; Quan et al., 2024) online exploration, may induce unsafe constraint violations during training (Malik et al., 2021; Liu et al., 2023; Quan et al., 2024), and have few theoretical guarantees of constraint recovery accuracy (Malik et al., 2021; Park et al., 2020; Quan et al., 2024). While recent offline variants (Quan et al., 2024) avoid online exploration during training, they still rely on offline data generated by potentially constraint-violating policies to identify unsafe regions, which can be difficult or unsafe to collect in real-world systems.

In this work, we bridge CIOC and ICRL to enable constraint learning under unknown dynamics and constraint representations without requiring constraint-violating data. Our approach, Counterfactual KKT (CF-KKT), learns local dynamics from constraint-satisfying expert demonstrations and uses them to combine KKT-inspired optimality conditions with synthetic reward-improving counterfactual trajectories. These counterfactuals provide information about constraint-violating states without requiring constraint-violating trajectories to be executed in the environment. We further show that locally learned dynamics can support CIOC-based parameter recovery when the constraint parameterization is known. Concretely, our contributions are:

  1. For settings with closed-form a priori known constraint parameterizations, we present a two-stage framework which first learns system dynamics without additional demonstration data, then leverages the learned system dynamics to infer the unknown constraint via CIOC;

  2. For settings with neural network (NN)-represented constraints, we introduce Counterfactual KKT (CF-KKT), which combines KKT-inspired optimality conditions with model-generated counterfactual trajectories to learn unknown constraints without observed constraint-violating data;

  3. We present a theoretical analysis of the sensitivity of the recovered constraints to system dynamics misspecification;

  4. We evaluate CF-KKT in simulation across low- and high-dimensional systems with black-box dynamics, demonstrating improved constraint recovery and downstream safety over existing offline ICRL methods while structurally using less data, all of which are safe.

Notation Given non-negative integers n1n_1 and n2n_2 with n1<n2n_1 < n_2, we define [n2]:={1,⋯ ,n2}[n_2] := \{1, \cdots, n_2\} and [n1,n2]:={n1,⋯ ,n2}[n_1, n_2] := \{n_1, \cdots, n_2\}. We use CkC^k to denote kk-times continuous differentiability. Given a differentiable function f:Rn→Rmf : \mathbb{R}^n \to \mathbb{R}^m, we define the Jacobian matrix ∇xf∈Rm×n\nabla_{\mathbf{x}} f \in \mathbb{R}^{m \times n} such that [∇xf]ij:=∂fi∂xj[\nabla_{\mathbf{x}} f]_{ij} := \frac{\partial f_i}{\partial x_j} for each i∈[m]i \in [m], j∈[n]j \in [n].

References (61)