{'fraction_non_alphanumeric': 0.035498128301710764, 'fraction_numerical': 0.009259367237699852, 'mean_word_length': 4.904971766974246, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Safe Control with Learned Certificates: A Survey of Neural Lyapunov, Barrier, and Contraction methods

Learning-enabled control systems have demonstrated impressive empirical performance on challenging control problems in robotics, but this performance comes at the cost of reduced transparency and lack of guarantees on the safety or stability of the learned controllers. In recent years, new techniques have emerged to provide these guarantees by learning certificates alongside control policies -- these certificates provide concise, data-driven proofs that guarantee the safety and stability of the learned control system. These methods not only allow the user to verify the safety of a learned controller but also provide supervision during training, allowing safety and stability requirements to influence the training process itself. In this paper, we provide a comprehensive survey of this rapidly developing field of certificate learning. We hope that this paper will serve as an accessible introduction to the theory and practice of certificate learning, both to those who wish to apply these tools to practical robotics problems and to those who wish to dive more deeply into the theory of learning for control.


I. INTRODUCTION
M ANY desirable properties of dynamical systems, including stability, safety, and robustness to disturbance, can be proven via the use of certificate functions. Perhaps the most well known of these certificate functions are Lyapunov functions: pseudo-energy functions that, if shown to be strictly decreasing along trajectories of the system, prove the stability of the system about a fixed point [1]. Other well-known certificates include barrier functions (which prove forward invariance of a set, and thus safety [2], [3]) and contraction metrics (which prove differential stability in trajectory tracking [4], [5]). A summary of these different certificates is shown in Fig. 1.
These certificate functions can be extremely valuable to the control system designer, as they allow her to prove safety and stability properties even for complex and nonlinear control systems. However, although the theory of certificates like Lyapunov functions is more than a century old, it is not until the last decade that general numerical methods have C. Dawson and C. Fan are with the Department of Aeronautics and Astronautics at the Massachusetts Institute of Technology. This work was supported by the Defense Science and Technology Agency in Singapore, but this article solely reflects the opinions and conclusions of its authors and not DSTA Singapore or the Singapore Government. C. Dawson  emerged to construct certificates, and even then many proposed methods were computationally intractable (e.g. relying on solving a high-dimensional PDE numerically) [1]. Absent efficient general-purpose methods, finding certificates requires spending great effort to hand-design certificates for specific systems. Even in the best case, this hand-tuning requires a good deal of intuition and luck to find an appropriate functional form (e.g. fixed-degree polynomial) and parameters (e.g. polynomial coefficients) for the certificate.
In recent years, new techniques have emerged for automatically synthesizing certificate functions. For systems with polynomial dynamics, the search for a valid certificate can be framed as a convex semi-definite optimization problem through the use of sum-of-squares (SoS) techniques [6]. Unfortunately, SoS methods are limited to polynomial systems and scale poorly to higher dimensional systems [7]. To address these shortcomings, an emerging body of work in the control theory, machine learning, and robotics communities have employed neural networks to learn approximate certificate functions [8].
Unlike traditional approaches to learning for control that search only for a control policy (such as many reinforcement learning, or RL, methods), certificate-based techniques simultaneously search for a control policy and a certificate that proves the soundness of that policy. This search may be guided by a separate reward function, similarly to traditional RL methods [9], but the reward function can be omitted entirely in favor of a self-supervised training signal provided by the certificates themselves [8], [10], [11], [12]. Because they produce a verifiable correctness certificate alongside a learned control policy, these neural certificates provide a trustable approach to learning for control, helping to address concerns about the safety and reliability of learned controllers. Neural certificates have been successfully applied to complex nonlinear control tasks, including stable walking under parametric uncertainty [13], precision quadrotor flight through turbulence induced by propeller wash [14], and provably safe decentralized control of multi-agent systems containing over 1,000 agents [11].

A. Scope and Contributions
This is a rapidly developing field for which no comprehensive survey has yet been written. Giesl   or through linear and second-order cone programming, but does not cover neural representations [1]. Ahmadi and Majumdar's 2016 paper presents a relevant summary of the sum-of-squares optimization-based approaches for synthesizing Lyapunov functions, but similarly does not cover neural representations (and only applies to systems with polynomial dynamics [6]). The 2021 review of contraction theory by Tsukamoto, Chung, and Slotine [5] discusses neural approaches to learning one particular type of control certificate, but does not discuss the most common certificates (Lyapunov and barrier functions). Our goal is to provide a comprehensive survey of recent developments in certificate learning to serve as an accessible introduction to these tools, both to those who might wish to apply them to practical robotics problems and to those who wish to dive more deeply into the theory of learning for control. Our survey includes theoretical discussion of all three common types of control certificate: Lyapunov functions, barrier functions, and contraction metrics. However, reflecting the prevalence of Lyapunov and barrier functions in the literature, our case studies focus mainly on these two types of certificate (readers interested in case studies involving contraction metrics are referred to the tutorial paper by Tsukamoto, Chung, and Slotine [5]). Our review is organized as follows.
• Section II provides the relevant background from control theory, introducing Lyapunov functions, barrier functions, and contraction metric certificates. • Section III discusses prior, non-neural approaches to certificate synthesis. • Section IV discusses how neural networks can be used to synthesize certificates and their corresponding safe controllers. This section attempts to unify the various synthesis methods presented in the literature, but also includes some historical discussion. • Section V discusses issues that arise when implementing certificate-based controllers on hardware, and Section VI presents a number of case studies applying these techniques to practical robotic systems, both in simulation and hardware. • Finally, Sections VII and VIII concludes by discussing some open problems in this area.

II. BACKGROUND
This section provides the necessary background from control theory by outlining the various types of certificate function and their use in controller design. Readers with a background in control theory should feel free to skim this section. We begin by defining notation and terminology, then examine the three major types of control certificates: Lyapunov functions, barrier functions, and contraction metrics.

A. Dynamical systems
In the rest of this paper, we will consider general dynamical systems of the formẋ = f (x, u), where x ∈ X ⊆ R n is the state, u ∈ U ⊆ R m is the input, and f : X × U → X is the flow map (which we assume to be locally Lipschitz in x and u). The sets X and U represent the sets of admissible state and control inputs, respectively. Often, we will consider a restricted (but still quite general) class of dynamics known as control-affine:ẋ = f (x) + g(x)u, where g : R n → R n×m is also assumed to be locally Lipschitz. For clarity, we will focus only on the continuous time case, but the theory for the discrete-time case follows similarly; readers interested in the discrete-time theory may read [15] or [5].
In the context of these dynamics, the controls engineer's task is to find a feedback controller π : X → U such that the control input u = π(x) imparts the closed-loop systeṁ x = f c (x) = f (x, π(x)) with certain desirable properties (e.g. stability). In general, π may be a function of time as well as state, as in trajectory-tracking control. For clarity, we focus on the case when the state x is fully observable, but Section V discusses methods for ensuring robustness to imperfect state measurements or observation-feedback control.
Given an initial state x 0 ∈ X 0 ⊆ X at time t = 0, the closed-loop system's behavior can be described via its trajectory map x(t) = ξ π (x 0 , t) : X 0 × R + → X , which we associate with the controller π used to close the feedback loop. When designing a controller, it is important to ensure that the system's behavior achieves objectives such as stability, safety, or contraction. In the rest of this section, we will define each of these objectives in turn and introduce certificates that can be use to prove that a controller achieves these objectives.

B. Stability and Lyapunov certificates
Stability can be defined in a number of increasingly strict senses [16]. A point x g ∈ X is said to be: a) Stable in the sense of Lyapunov (i.s.L.) if, for an appropriate norm, for every > 0 there exists a δ > 0 such that for all t 2 ≥ t 1 ≥ 0: a) Asymptotically stable if the system is stable i.s.L. and a) Exponentially stable if there exist constants C, λ > 0 such that The concept of stability can also be extended to the case where the goal is a set X g ⊆ X rather than a point, in which case the norm distance between points in the above hierarchy is replaced with distance between a point and X g (see Definition 4.10 in [17]).
To prove that a closed-loop system is stable about a point, we can turn to one of the most widely known types of certificate: the Lyapunov function. A continuously differentiable is the Lie derivative of V along the closed-loop dynamics f c (often denoted L fc V (x)). If a function satisfying these conditions can be found, then it serves to certify the stability of x g via the following theorems.
Theorem 1 (Theorem 4.1 in [16]). If V is a Lyapunov function (i.e. V (x g ) = 0, V (x) > 0 ∀ x ∈ X \ {x g }, and dV dt ≤ 0 ∀ x ∈ X ) and f c (x g ) = 0, then the system has a stable i.s.L. equilibrium at x g (with X forming the region of attraction). Moreover, if dV dt < 0 for all x ∈ X \ {x g }, then the system has an asymptotically stable equilibrium at x g .
The proof can be found in most controls textbooks and is omitted here, but the primary insights are 1) sub-level sets of V are forward invariant (i.e. once the system enters a sublevel set of V , it will remain inside that set for all future time), proving stability i.s.L., and 2) if V is monotonically decreasing and bounded below, then it must eventually approach its minimum value at 0. Intuitively, it is useful to think of V as a generalized energy -if the system is strictly dissipative then it will eventually come to rest. We can also certify exponential stability by adding additional conditions to V .

Theorem 2.
[Theorem 4.10 in [16]] If V is a Lyapunov function, f (x g ) = 0, and there exist positive constants k 1 , k 2 , k 3 , a such that then x g is exponentially stable.
The proof can be found in [16]; the main insight is that condition (5b) ensures that V decays exponentially to zero, while condition (5a) ensures that V → 0 implies ||x − x g || → 0. Other forms of Theorem 2 exist in the literature [10], typically replacing (5b) with L fc V ≤ −k 3 V , but these modifications do not change the essential theory.
In addition to certifying the stability of a closed-loop system, Lyapunov functions can also be applied to certify the stabilizability of open-loop systems (i.e. prove that there exists some controller that makes the closed-loop system stable). Restricting our view to a control affine system, a Control Lyapunov Function (CLF) V : X → R certifies asymptotic stabilizability about x g if where L f V and L g V denote the Lie derivatives of V along f and g, respectively. A similar definition exists for exponentially stabilizing CLFs (ESCLF) [18], where the last condition is replaced with for some positive c. Once found, a CLF (or ESCLF) defines a set of admissible control inputs for each state: Any Lipschitz policy π that chooses control inputs from these sets will necessarily stabilize the system. Since these conditions are affine in u, a common choice is a quadratic program (QP) that finds the smallest-magnitude control such that u ∈ K CLF or u ∈ K ESCLF [18], for example: This QP can also be used to filter a potentially-unstable reference policy π r by replacing the objective with ||u−π r || 2 , in which case the QP solves for the value of u closest to the reference that still ensures stability, as shown in Fig. 2. Now that we have derived a control policy from the solution of a constrained optimization problem, it is important to discuss the continuity of that policy. An important result in the theory of CLFs (also applicable to CBFs, which we discuss next) is that the controller (10a) is Lipschitz continuous (Section 4.2 in [19] and [18]) and has a closed-form solution so long as U is convex [18].

C. Safety and barrier certificates
Given an unsafe set X u ⊆ X that does not intersect the set of initial conditions X 0 , a system is safe if it will never enter the unsafe region if started within X 0 . That is, it will be safe if all trajectories satisfy: To prove this property, we would need to prove that some set (containing X 0 but not intersecting X u ) is forward invariant. We can do this using a certificate known as a barrier function. Concretely, consider a compact set C, defined as the zero sub-level set of a barrier function h : X → R (i.e. C = {x : h(x) ≤ 0}). If h satisfies certain properties (given in Theorem 3), then C will be forward invariant. Note that some references reverse the sign of h to be positive on the invariant set; however, we choose this convention to illustrate the parallels between barrier and Lyapunov certificates. In particular, it is often useful to know that every Lyapunov function implies a family of barrier functions defined via its sub-level sets.

Theorem 3.
[Proposition 1 in [20]] If there exists a strictly increasing scalar function α : R → R such that α(0) = 0 (i.e. an extended class-K function) and then h is a barrier function and C is forward invariant for the closed-loop systemẋ = f c (x).
A common choice for α(h) is simply γh for some positive γ. The proof of this theorem can be found in [20]; the main insight is that h is decreasing whenever x is on the boundary of C, where h(x) = 0, which prevents the system from ever exiting C. In fact, if the system starts outside of C, this condition ensures that it will asymptotically converge to C. A direct consequence of Theorem 3 is that if X 0 ⊆ C and X u ∩ C = ∅, then the closed-loop system is safe in the sense of the definition in (11).
Barrier functions can be extended to certify the safety of open-loop systems through the use of Control Barrier Functions (CBFs), which directly parallel the CLFs introduced in the previous section. A function h is a CBF if As with CLFs, this condition is affine in u, allowing a CBF to be used in a QP in a similar way. Usefully, the CBF condition (13) can be combined with a relaxed version of the CLF condition (6c) to yield a single controller that combines safety and stability considerations [20]: In this combined CLF-CBF QP, the constraint (14c) ensures safety at all times while the stability constraint (14b) is relaxed by some variable amount r. This relaxation allows the system to temporarily cease progress towards the goal in order to remain safe, and k > 0 is a tunable parameter governing the trade-off between control effort and relaxation of the CLF condition. It is important to note that this combined QP can suffer from deadlock when there is no safe direction that moves closer to the goal, although there are proposals for switched controllers [21] and unified Lyapunov-barrier certificates [10] that alleviate this concern.

D. Contraction metric certificates
In our previous discussion of stability, we assumed that the control system designer is interested in stabilizing the system about a fixed point; however, in many applications we are more interested in trajectory tracking rather than stabilization. Of course, a fixed-point-tracking controller can be used to track a trajectory if that trajectory varies slowly enough, but in order to track more general trajectories we need a richer specification than simply stabilizing a fixed point.
In this context, the designer wishes to find a controller so that the trajectories x(t) of the closed-loop system will converge to some desired trajectory, which we represent as a sequence of states and control inputs x * (t) and u * (t): for some R ≥ 1, λ > 0. Intuitively, we can think of this as a requirement that the distance between the system's trajectory and the reference we wish to track shrinks exponentially (with some potential overshoot allowed by R). Contraction theory [22], [23] allows us to formalize this requirement. Just as a Lyapunov function defines an energy-like quantity that decays along trajectories (proving stability), contraction theory defines a measure of distance between neighboring trajectories (a contraction metric) that decreases exponentially over time [22]. Let the metric M (x) : X → R n×n be a function returning a positive-definite matrix (which we denote M 0). This matrix defines a metric (a generalized distance) on virtual displacements between trajectories δx T M δx. By showing that this metric is contracting (i.e. the displacement between any two neighboring trajectories is shrinking), a contraction metric allows us to certify that a closed loop system (with some feedback tracking controller) is capable of tracking any feasible trajectory using the following theorem.
Theorem 4 (Proposition 1 in [14]) , and K = ∂π ∂x for some feedback tracking controller π(x, x * , u * ). Further, let sym(A) = A + A T . Then, if for all x ∈ X , x * ∈ X , and u * ∈ U, M + sym(M(A + BK)) + 2λM ≺ 0 (16) then equation (15) holds with R equal to the square root of the condition number of M and we say the system is contracting with rate λ.
Contraction is a property of the closed-loop system, not of any particular trajectory, and thus the existence of a metric satisfying condition (16) suffices to prove that a control system is capable of exponentially stabilizing any dynamically feasible nominal trajectory. Additionally, if a system is contracting, then bounded disturbances will produce a bounded worst-case tracking error, and this tracking error will be proportional to the magnitude of the disturbance [14]. As a result, the metric M provides a certificate that the corresponding tracking controller π successfully stabilizes the system and is robust to disturbances, as illustrated in Fig. 3. Fig. 3. A contraction metric proves that the system will exponentially converge to track any feasible reference trajectory. The error ||x(t) − x * (t)|| shrinks exponentially, with transient overshoot limited by the condition number of M and the steady-state tracking error is bounded proportional to the worst-case disturbance.

III. PRIOR WORK ON CERTIFICATE SYNTHESIS
In this section, we discuss prior work on certificate synthesis methods. We separate this discussion into two parts. First, we cover early methods for certificate synthesis, including numerical methods, polynomial optimization, and simulationguided synthesis. These methods represent an important step in the history of certificate synthesis, but the poor scalability of these early methods, particularly when dealing with nonlinear dynamics, sparked the development of the neural techniques that are the focus of this survey.
Of course, neural certificates are not the only class of methods that have evolved to fill this gap. The second part of this section discusses two parallel lines of work, safe RL and reachability, that are similar in purpose to neural certificate methods but often use different vocabularies and methods. Our aim here is not to provide a comprehensive introduction to these methods, since excellent surveys exist for both Hamilton-Jacobi reachability [24] and safe RL [25]; instead, we aim to to highlight key similarities and differences between these lines of research and situate recent developments in neural certificates in this modern context.

A. Early approaches: numerical solutions and optimization
Depending on the complexity of the dynamics, several existing techniques may be used to synthesize certificate functions, although there is currently no generally-applicable scalable framework [1]. When the dynamics of the closed-loop system are linear and stable,ẋ = (A − BK)x for feedback gains K, then a quadratic Lyapunov function will exist of the form V (x) = x T P x for some symmetric positive definite matrix P . In this case, P can be found by solving the continuous Lyapunov equation numerically (most numerical linear algebra packages provide this functionality, including MATLAB [26] and SciPy [27]).
For systems with polynomial dynamics, constraints on the sign of the certificate function's derivative can be expressed as constraints that certain polynomials be expressible as sumsof-squares (SoS). Due to the correspondence between fixeddegree SoS polynomials and positive semidefinite matrices (which form a convex cone), certificates encoded in the SoS framework can be synthesized using convex optimization methods. Unfortunately, the computational complexity of these techniques grows exponentially in the degree of polynomials involved and they are limited to systems with polynomial dynamics [6]. Additionally, SoS optimization is only convex when searching for either a certificate or a controller; the optimization problem becomes non-convex and often encounters numerical issues when searching for a certificate and controller simultaneously [28]. A comprehensive review of SoS methods for control is outside the scope of this review, but the interested reader may see [6] for a survey and [29], [30], [28] for relevant examples.
A related technique for certificate synthesis for nonlinear systems is the simulation-guided synthesis [31]. In this framework, the controls engineer selects a fixed set of basis function z(x) (e.g. monomials up to some degree) and constructs a Lyapunov candidate of the form V (x) = z T P z. The state space is then sampled at a large number of points, and each point is simulated forward to estimate the closed-loop state derivative. After computing z for these fixed points, the Lyapunov and barrier function conditions at those points become linear in the entries of P , allowing P to be computed using linear programming. After solving for P , the candidate V is verified using a satisfiability modulo theory (SMT) solver, which a generalizes Boolean satisfiability to include statements involving real numbers [32]. If the SMT solver finds a violation of the certificate conditions, then a counterexample representing that violation is added to the optimization problem and P is recomputed. This process continues until either the SMT solver verifies that V is a valid certificate or the LP becomes infeasible (in which case we can conclude nothing beyond the fact that our choice of basis is not suitable).
Due to the poor scalability of these methods, particularly with regard to nonlinear or high-dimensional dynamics, they have not seen widespread adoption since their introduction (with the notable exception of SoS methods, although substantial concerns remain about the scalability of SoS methods in practice [10]). A qualitative summary of various prior methods is shown in Table I.

B. Parallel approaches: safe RL and HJ reachability
It is important to acknowledge that certificate-based control is not the only line of research that deals with the problem of guaranteeing safety and stability for control systems. In particular, safe RL [25] and Hamilton-Jacobi reachability [24] have received a large amount of research interest in recent years. While full coverage of these methods is outside the scope of this survey, we will review the basics of each approach here, with an eye towards highlighting the underlying commonalities and differences between these methods and certificate-based control.
In the broadest possible terms, safe RL is a collection of methods that seek to optimize a control policy to achieve good performance on a specified task (i.e. by maximizing some reward) while respecting a number of constraints on the behavior of the controlled system [25]. There are three classes of safe RL methods in particular that highlight connections to certificate-based control. The first class of methods use an a priori given certificate to constrain the actions that the RL agent can take [33], [34], [35], possibly with some learning of model uncertainty as the controller explores [33], [34]. These methods highlight the complementary nature of certificatebased control and traditional RL; certificates enforce safety and stability constraints while the RL agent tries to achieve good performance on non-safety-critical metrics. Of course, these methods require a certificate to be provided a priori, requiring a separate certificate synthesis process, and so they are not the focus of this survey. The second class of safe RL methods propose to learn certificates alongside a control policy using standard RL optimization algorithms (e.g. learning a Lyapunov function in [9], a CLF in [36], or a CLF and CBF together in [37]). We see these methods as examples of the neural-certificates approach, with the main difference between these and other neural certificate-learning methods being the choice of optimization algorithm (there is also a minor vocabulary difference, as the safe RL community often considers a "safety index" function that acts similarly to a barrier function [38]). The final class of safe RL methods attempts to derive certificate functions directly from the structure of the constrained partially-observable Markov decision process underlying the safe control problem [39], [40]; these methods are exciting, as they suggest the future possibility of extending control-theoretic certificates to handle a more general class of constraints (as we discuss in Section VII).
In addition to the body of safe RL literature, there are also a class of methods for safe control synthesis and verification based on Hamilton-Jacobi (HJ) reachability analysis. HJ methods, which are sometimes also referred to as Hamilton-Jacobi-Isaacs (HJI) methods to emphasize the connection to game theory, typically frame the safe control problem as a two-player zero-sum game between the controller and an adversary. In this game, the controller seeks to maximize some safety index (making the system as safe as possible) while the adversary seeks to minimize this index. Both a value function (indicating how unsafe the system will be if it starts at a given state) and a control policy that maximizes the safety of the system are found by approximately solving an HJI partial differential equation under the assumption of bounded actions by the adversary [24]. There are fundamental connections between the HJ value function and certificate functions, since the super-and sub-level sets of HJ value functions and Lyapunov functions, respectively, certify the forward invariance of a safe region. The primary difference between traditional HJ and certificates is that the controller found by solving an HJ reachability problem is optimally safe in that it always seeks to maximize the safety of the system, and can thus be conservative, but recent work in linking HJ reachability with barrier functions [41] have reduced this conservatism. Historically, HJ methods have been limited by the complexity of solving the HJI PDE in highdimensional state spaces (which usually requires covering the state space with a discrete mesh of sufficient resolution before iteratively solving the PDE, [24]). However, there has been an exciting trend towards using neural networks to approximate solutions of HJ reachability problems [42], [43], paralleling the use of neural networks for general certificate synthesis, substantially reducing the amount of computation required for HJ analysis. Based on these developments, we anticipate that HJ reachability methods and neural certificates will continue to converge over the coming years, with each community applying insights from the other to develop more scalable and flexible algorithms.

IV. LEARNING NEURAL CERTIFICATES
All of the certificates discussed above allow the controls engineer to prove that her controller design is sound (or, in the case of CLFs and CBFs, derive a sound controller directly from the certificate). However, these methods share a common drawback: there has historically been no general, scalable method for finding these certificates [1]. In this section, we will discuss how we can apply self-supervised learning to learn these certificates using neural networks (so-called because the algorithm requires no human labeling to supervise its learning; it can generate its own labels).
First, we will discuss how a certificate can be found independent of any controller. This case is useful when a controller is known and the designer simply wishes to find a certificate for the closed-loop system, or when the certificate itself can be used to derive a controller implicitly (as with a CLF or CBF). Of course, in some applications we wish to learn an explicit control policy as well; we will discuss this case shortly, but it is instructive to begin with the certificate-only case.
Generally speaking, the search for a certificate can be seen as an optimization over a space of continuously differentiable functions V. If we consider a generic certificate V : X → R q (where q = 1 for Lyapunov and barrier certificates and q = n 2 for contraction metrics), then the search for a generic certificate can be encoded as an optimization problem [44]: where I is the set of conditions c i that must hold for this particular certificate (with slight abuse of notation for converting between equality constraints and inequalities). For example, to search for a Lyapunov function, inequalities (4a), (4b), and (4c) must hold, creating the optimization problem Different approaches to certificate synthesis can be organized according to how they approach this optimization program. For example, the SoS and simulation-guided synthesis methods discussed in Section III restrict V to the span of a chosen set of basis functions (e.g. polynomials of fixed degree), then solve (17) as a convex (or bi-level convex) program. The convexity imposed by a particular choice of V (e.g. the set of polynomials up to a certain degree) makes solving (17) more efficient but can be overly restrictive, resulting in (17) becoming infeasible if V is not rich enough.
The neural certificate framework can be seen as a natural extension of this approach by searching over a much richer function space. To avoid the limitations imposed by the choice of function space, V is represented as the space of neural networks of particular depth and width (chosen as hyperparameters by the user). By increasing the size of these networks, this representation can approximate any continuous function [45], [46], alleviating limitations due to the choice of function space. Although this same universal approximation property also applies to polynomials (i.e. a polynomial of large enough degree can also approximate any continuous function on some domain), in practice the scaling for neural networks is much more favorable (the number of parameters in the input layer of a neural network grows with O(nd) with n input dimensions and d dimensions in the next layer, while the number of monomials in a d-degree polynomial in n dimensions grows with O(n d )).
To adapt (17) to be solved using a neural representation for V , we must make two modifications to account for the fact that neural networks lend themselves best to unconstrained optimization problems (solved via stochastic gradient descent) rather than constrained optimization. First, we relax the constraints using a penalty method. Second, instead of imposing constraints universally (e.g. ∀x ∈ X ), we evaluate them at a large, finite set of randomly sampled training points {x 1 , . . . , x N } ⊂ X . Each of these training points can be automatically labeled with a loss equal to the violation of the certificate conditions at that point, and averaging this loss across the entire training set yields the empirical certificate loss: with penalty weights α i that are tuned empirically as hyperparameters to encourage constraint satisfaction. Loss refers to the fact that all constraints are included as scalar penalties to be minimized, and empirical loss is distinguished from the true loss in that it is evaluated at a finite number of points rather than over the entire state space. This empirical loss can be minimized using stochastic gradient descent with respect to the weights and biases of the neural network used to represent V , but it is important to remember that zero empirical loss does not guarantee that the certificate is valid; it provides only statistical evidence of validity that can potentially be supplemented by one of the neural network verification strategies discussed in Section V-E. This approach provides the foundation for many certificatebased learning works; early examples include [47], and later works include [48], [3], [49], [50], [51], [52], [53], [54]. Examples that learn CLF or CBF certificates that imply controllers include [55], [56], [57], [58], [10], [21], [59], [12], [60]. A related class of works assume that a certificate is given for a nominal system and use supervised learning to adapt that certificate to the uncertain true model [2], [61], [13], [62].

A. Remarks on certificate learning
At this point it is important to make two remarks. The first remark concerns the constraints that certificates impose on neural network structure. Most of certificate theory for continuous-time dynamical systems assumes that the certificate is continuously differentiable, so it is important that continuous-time certificates are learned using networks with continuously-differentiable activation functions such as tanh, softplus, or the exponential linear unit (ELU). In the discrete-time case, Lyapunov and barrier certificates are required only to be continuous [63]; accordingly, works that focus on the discrete-time case have learned certificates using rectified linear unit (ReLU) activation functions, which are continuous but not differentiable at the origin [64].
Second, it is important to note that although we frame the certificate-synthesis problem as a feasibility problem in (17), there are several metrics of certificate quality that might be included as an objective for the certificate search. The first metric, applicable to Lyapunov functions, is the size of the region-of-attraction certified by the resulting certificate [59], [8], [47]. Larger regions of attraction can be encouraged either implicitly (by attempting to maximize the percentage of samples in the state space where the certificate is valid [8]) or by explicitly searching for new training examples to expand the region of attraction [47]. The second metric, applicable to CLFs and CBFs, is the size of the admissible control set K(x), the maximizing of which will yield a less-restrictive controller. This is particularly relevant when actuator limits are present, in which case the size of the intersection of K and U should be maximized. This second metric is less well explored in the literature. Either objective could be incorporated into the certificate-learning pipeline by adding an appropriately normalized term to the loss function (19), but care should be taken to not allow the neural certificate to overfit to this term at the expense of violating the certificate conditions.

B. Learning certificates and controllers together
Learning the certificate alone is useful when a controller is already known and we seek to verify its performance, or in cases when learning a certificate such as a CLF or CBF allows us to derive a controller. When it is necessary to explicitly learn a controller alongside the certificate, we can easily extend this framework to simultaneously search for a control policy π from some family of policies Π (commonly, π is parameterized as a separate neural network).
There are three different contexts in which we might wish to learn a control policy. The first case is behavior cloning, where we know an "expert" control policy to use as a basis for the learned controller. For example, we may have a computationally expensive nonlinear MPC policy that we wish to compress into a neural network for online computation [12], or we may have a full state feedback controller that we wish to clone for a partial state feedback context ( [65] provides a noncertificate-based example of this context). To accomplish this certified behavior cloning, we simply augment the empirical loss in (19) with a behavior cloning term that penalizes the difference between π and the expert policy (often simply the mean of an appropriate norm): Another interesting application of this case is using a barrier certificate to learn more realistic behavior predictions for pedestrians [66]. In this application, the "expert" is not a control policy per se but observations of human actions, and the resulting policy π is not used for control but to generate more realistic predictions of the humans' future actions.
The second case where we might wish to learn a controller alongside a certificate is when we do not have an expert reference controller, but we have a reward that we seek to maximize; this leads to certificate-regularized reinforcement learning. [9] provides an example of reinforcement learning with a Lyapunov function where L V is used alongside the reward to update the control policy. This setting brings additional complications, as reinforcement learning algorithms typically assume no prior knowledge of the dynamics, and so the Lie derivative of V must be estimated from observed trajectories of the system rather than computed exactly.
The final case is when there are no requirements (beyond the certificate) placed on the learned control policy. In this case, L V is used to self-supervise both the certificate V and control policy π. The first example of simultaneous certificate/policy learning appeared in [8] for a Lyapunov certificate; later works learn barrier functions [11] and contraction metrics [14] alongside control policies as well, or extend to the case when dynamics are only partially-known [67].
Next, we will make this discussion concrete with examples of learning a Lyapunov function, barrier function, and contraction metric, then discuss the history of certificate learning in the controls, robotics, and machine learning literature. Code for each example can be found at https://github.com/ MIT-REALM/neural clbf.

C. Example: learning a Lyapunov function
Our first example involves learning a CLF for the classic toy example: the inverted pendulum (we will progress to more complex examples shortly). This dynamical system has states x = [θ,θ] and control inputs u = [τ ]. The system is parameterized by its mass m, length L, damping b, and gravitational acceleration g, and its dynamics have controlaffine form:ẋ Our goal in learning a CLF is to stabilize this system about x 0 = [0, 0]. To learn the CLF, we parameterize V as a neural network with two hidden layers of 64 units and minimize the following empirical loss over N = 10 4 training points. In all experiments, we sample the training data uniformly from the state space, which we represent as a hyperrectangle.
The third and fourth terms of the empirical loss are different approximations of the Lyapunov decrease conditions; strictly speaking, only the first two terms are needed, but additional terms can help the learning process. Note that in this example, we train V to be positive definite, but it is also possible to ensure positive-semidefiniteness by construction by learning some function ω(x) : R → R n h as a neural network with n h output units, then taking V (x) = ω(x) T ω(x) (this construction is helpful for more complicated examples, but the first loss term is still required to encourage a minimum at x 0 ). Code for this example can be found in training/train_inverted_pendulum.py. The results of learning a CLF for this example are shown in Fig. 4; the CLF-derived controller successfully stabilizes this simple dynamical system. In the next section, we will set our sights higher with a more complicated example of learning a CBF.

D. Example: learning a CBF
To demonstrate learning a CBF, we use the spacecraft rendezvous problem from [68]. In this problem, we need to design a station-keeping controller to keep the "chaser" satellite near a "target," respecting both a minimum distance constraint (to avoid collision) and a maximum distance constraint (to enable observation of the target). The state of the chaser is expressed relative to the target using linearized Clohessy-Wiltshire-Hill (CWH) equations, with state x = [p x , p y , p z , v x , v y , v z ] and control inputs corresponding to thrust in each direction u = [u x , u y , u z ]. With mass m and mean-motion orbital parameter n, the dynamics are given bẏ The station-keeping constraints define the unsafe states X u = {x : 0.25 ≥ r ≤ 1.5} with r = p 2 x + p 2 y + p 2 z . To learn a CBF for these constraints, we take a similar approach as in the previous example and define h as a neural network with 2 hidden layers of 256 units each, sample N = 10 5 points from the state space (labeled according to whether or not they belong to the unsafe or safe sets), and minimize the empirical loss where λ 1 = λ 2 = 100, λ 3 = 1, and r(x i ) is found by solving the CBF QP at state x i with nominal control input u 0 (found using LQR), c = 0.1, and λ 5 = 10 4 : Here, the first and second terms of the empirical loss enforce the boundary conditions, training the h network so that its 0-level set segments the safe and unsafe states. The third term is designed to train h so that the corresponding CBF QP is feasible. Code for this example can be found in training/train_linear_satellite.py. The learned barrier function is shown in Fig. 5, and an example trajectory for the chaser controlled using the CBF QP is shown in Fig. 6.

E. Example: learning a contraction metric
Our third example demonstrates learning a contraction metric alongside a control policy. For this example, we consider the problem of designing a nonlinear trajectory-tracking control policy to run on an autonomous ground vehicle. To motivate this problem, we look at the case where the ground vehicle has limited computational resources on-board, so running computationally expensive control policies such as nonlinear MPC may be infeasible. Instead of running this expensive policy on-board, we can use a neural network to learn a computationally inexpensive clone of the MPC policy, and we also learn a contraction metric to ensure that the cloned policy is sound.
Concretely, we consider a simple nonlinear ground vehicle model with states x = [p x , p y , θ] for the 2D position and heading and control inputs u = [v, ω] for the linear and angular velocities. The system dynamics are control-affine: We construct an expert control policy by solving a nonlinear MPC problem using CasADi [69]. Using this expert policy, we construct a training dataset of 100 random reference trajectories of length 10 s each (simulated at 100 Hz with a 10 Hz zero-order hold control signal; data points were sampled at 10 Hz). Expert demonstrations are augmented with a small amount of noise to widen the distribution of training data. We represent the contraction metric M (x) and control policy u(x, x * , u * ) as neural networks with 2 hidden layers of 32 neurons, and construct the metric M = A + A T where A is the output of the neural network to ensure that the contraction metric is symmetric (other parameterizations exist that ensure that the eigenvalues of M are lower-bounded by construction [14], but we use this construction for simplicity). We also set u(x, x * , u * ) = u * +π(x, x−x * )−π(x, 0) to ensure that u(x, x * , u * ) = u * when x = x * . We simultaneously optimize the parameters of the metric and policy networks to minimize the empirical loss over N train = 10 4 tuples (x, x * , u * , u expert ) sampled uniformly from a user-specified hyper-rectangle: where [•] P D and [•] N D are hinge losses encouraging positive-and negative-semi-definiteness, respectively. Example code for this example is provided in training/contraction/train_cm.py; note that the structure of this code is different from that in the previous two examples since contraction metrics must be trained using trajectory data rather than randomly sampled points. Additional examples of contraction metric training can be found in the code accompanying [14]: https://github.com/sundw2014/C3M. An example of the trained controller tracking a (previouslyunseen) random reference trajectory is shown in Fig. 7, and the value of the learned contraction metric over time is shown to decrease exponentially in Fig 8. Note that even though the neural network control policy only receives the reference state and input at the current instant in time (the original MPC policy receives a 1-second window of future reference states and inputs), it is able to successfully track a trajectory that was not part of the training dataset.

F. History of certificate learning
The earliest proposal for using a neural network for Lyapunov function synthesis comes from Prokhorov's 1994 paper [70], but this technique relies on neural networks as a model of computation rather than as a function approximator, preventing the approach from scaling. Serpen [71] in 2005 first framed the neural network certificate-representation problem as an optimization problem analogous to (19). However, neither of these works include a demonstration of their learned certificates. Noroozi et al. [72] demonstrated learning a neural network approximation of a Lyapunov function for simple two-and three-dimensional nonlinear dynamical systems in 2008, while Petridis and Petridis [73] in 2006 employ a neural certificate trained via a genetic algorithm to verify the stability of a recurrent neural network. These early works are typically restricted to Lyapunov certificates and involved relatively small dynamical systems.
It is not until after the explosive growth in interest and computational power applied to neural networks in the mid-2010s that neural certificates were rediscovered in the context of robotics and control. One of the first practical implementations came in 2018, where Richards, Berkenkamp, and Krause [47] frame certificate synthesis as a classification problem, with the goal of finding the largest region of attraction (RoA) certified by a neural network certificate (they search only for a certificate and assume a controller is given). This approach iteratively grows the approximate certified RoA outwards from a fixed point, sampling from points near the boundary of the RoA to expand its training dataset. The Lyapunov conditions are only enforced for points that lie within the current estimate of the RoA (as determined by simulating forward from those points), allowing this method to estimate the RoA for systems that are only locally stable. Richards et al. demonstrate their method on a feedback-stabilized inverted pendulum in simulation, where it outperforms other methods for estimating the RoA (particularly, local linearization and SoS).
Since this initial work, several other authors have also addressed this issue of finding a certificate for a fixed, pre-defined controller. [74], [49] incorporate an SMT solver to verify the learned Lyapunov certificates and provide counterexamples for training, and [3] takes a similar approach to learning barrier functions (the authors of [74], [49], [3] later unified these methods in a single software framework in [50]). [4] learns a contraction metric in the case when the control policy is known but applies this technique for system identification rather than controller verification (the contraction metric constrains the learned dynamics model to be stabilizable).
The first work to propose jointly optimizing for a control policy and Lyapunov certificate is that of Chang, Roohi, and Gao in 2019 [8]. This work employs an SMT-based learnerverifier architecture using the dReal SMT solver, and alternates between optimizing the empirical loss (19) and searching for counterexamples to guide training. Chang et al. demonstrate that jointly optimizing for a controller and a certificate yields improved performance, in the sense of a larger region of attraction, than either optimizing for a fixed controller (using LQR) or using SoS techniques.
Since Chang et al.'s work, other authors have expanded this joint control-certificate learning approach to other certificate functions. For instance, [11] jointly learns a barrier function and controller, while [56], [57], [58], [10], [21], [59] learn control Lyapunov and control barrier functions (implicitly combining the certificate and control policy). Other authors, notably Tsukamoto, Chung, and Slotine [55], [75] have extended the neural certificate approach to contraction metrics (see [5] for an overview of these approaches). In addition to different types of certificate, later works have expanded this framework to more challenging problems in control, such as multi-agent control in [11], black-box dynamical models in [67], the RL context in [9], and the robust case in [10]. Many of these later works are particularly notable for providing theoretical and algorithmic contributions to address difficulties that arise in practice (such as control from observations), which we discuss next in Section V.

V. IMPLEMENTATION CONSIDERATIONS
Successfully deploying a control system on hardware is more challenging than demonstrating the performance of that system in simulation. In hardware, effects such as state estimation error, control frequency and delay, external disturbances, unmodeled dynamics, and actuator limits can degrade the safety and stability of the controller unless suitable steps are taken to mitigate these effects. This section will discuss a number of strategies to mitigate these effects.

A. Mitigating measurement uncertainty
A notable gap between simulation and real hardware is the availability of high-quality state estimates. As a result, it is natural to ask how state estimation errors can affect the guarantees of certificate-based controllers. The most directly relevant work in this vein is that by Dean et al. deriving conditions under which barrier functions are robust to measurement errors [76]. In this framework, the authors assume access to a state estimate with bounded error, i.e.x = x + e(x) with error bounded by some known function ||e(x)|| ≤ (x). Given this assumption and knowledge of the Lipschitz constants of the barrier function and its Lie derivatives, the authors in [76] derive a tightened version of condition (13) that guarantees control-invariance despite state estimation uncertainty. These conditions can be used derive quantitative requirements on the state-estimation accuracy needed to enable a certificate-driven approach to control.
Although [76] provides the theoretical basis for barrier certificates that are robust to errors in state estimation, these "measurement-robust" barrier functions are strictly more difficult to synthesize than standard barrier functions (due to the tightening of condition (13)). We are not aware of any published work learning (or otherwise automatically synthesizing) measurement-robust barrier functions, but we anticipate that future work in this area will bridge this gap, since neural synthesis methods can be easily adapted to these tightened conditions.

B. Observation-feedback control certificates
In Section V-A, we ask how certificates might be adapted to handle an uncertain state estimate; a natural extension of this question is how certificates might be adapted to the case where the control policy is a function of observations themselves (i.e. observation-feedback or "pixels-to-torques" control). This is an active area of research in the certificatelearning setting. Early works in this direction assume that the observations are first converted to state estimates with some bounded error (e.g. [76], discussed in V-A). Later works have provided proofs-of-concept for certificates defined directly in the space of observations, without recourse to an intermediate state estimate [21]. These works typically rely on some approximate model of how control actions affect future observations. For some observations, we can construct an analytical approximate model, for example by approximating future Lidar observations as affine transformations of previous observations [21], or modeling force measurements using spring connections to the environment [77]. For more complicated observations, particularly image feedback, there has been some work towards approximating future images using generative models [78], [79], but there is still work to be done to understand the approximation errors of deep generative models and the impact of those errors on the safety of a certificate-based controller.

C. Robustness to disturbance and model uncertainty
A common goal when designing control systems is to ensure that disturbances to the nominal system dynamics do not adversely affect the safety or performance of the system. Some disturbances, such as unmodeled aerodynamic effects [80], can be represented as unknown forces added to the known system dynamics, while others, such as uncertain mass or inertia, must be modeled as potentially multiplicative disturbances [10]. Depending on the prior knowledge of the disturbance, different certificate-based control strategies (each with distinct advantages and drawbacks) may be applied to ensure safety.
When little is known about an additive disturbance beyond its bound, i.e.ẋ = f (x, u)+d, d ∈ D for a known disturbance set D, then learning a contraction metric will guarantee that any bounded disturbance will lead to a bounded tracking error in the worst case. When more information about the structure of disturbance is known, for instance whenẋ = f (x, u, d) and f is known to be affine in d for any fixed (x, u) (as is the case for additive disturbance as well as uncertainty in many physical parameters), then robust variants of Lyapunov and barrier functions exist to guarantee safety and stability despite this uncertainty [10]. These robust methods are complementary with the adaptation techniques discussed in Section V-D, where we might wish to combine a partially-learned dynamics model with robustness to error in those learned dynamics [62], [13].
The most challenging case of model uncertainty is when there is no a priori knowledge of the structure (e.g. additive, control-dependent, etc.) or extent of the uncertainty. In these cases, the model uncertainty may be estimated from data; [81] discusses this case for control-affine systems. While [81] does not include a method for synthesizing a CLF or CBF certificate in this setting, the authors provide a theoretical discussion on how to derive a control input from these certificates (extending the certificate-based QP controllers (10a) and (14a)) and when those controllers are feasible despite model uncertainty.

D. Certificate adaptation
In Section V-C, we discussed robust certificate techniques that take a worst-case approach to handling model uncertainty. This raises the natural question: instead of trying to be robust to a wide range of possible model errors, could we rely on the nominal model for the bulk of the training process and then transfer the learned certificates to the true model using a smaller amount of data from the real system, thus "adapting" the certificate to the true model?
One line of work in certificate adaptation takes inspiration from system identification: if the difference between the nominal and real models can be learned, then certificatebased controllers can adjust for this difference at runtime. For example, if control barrier function h is known for the nominal system (which we write asf andĝ to distinguish from f and g for the real control-affine system), then a safe controller can be found by solving the CBF QP [61]: Unfortunately, the constraint of this QP depends on the unknown dynamics. If the nominal model differs from the true dynamics with error terms ∆ f (x) and ∆ g (x) (i.e.ẋ = f (x) +ĝ(x)u + ∆ f (x) + ∆ g (x)u), then this introduces an error term: where a = L ∆f (x) h and b = L ∆g(x) h. Choi, Castenñeda, et al. demonstrate that a neural network can be used to learn either the model residue (∆ f , ∆ u ) or the Lie derivative residue (a, b) via reinforcement learning [13] or Gaussian process regression [62]. They apply their model-learning adaptation technique to a simulated bipedal walker with 14 state dimensions, demonstrating successful adaptation when the mass and inertia of each robot link are changed [13]. In a similar vein, Taylor et al. learn a and b using an episodic learning framework for both barrier [61] and Lyapunov [2] certificates applied to a Segway model in simulation.

E. Certificate verification
Several methods for verifying learned certificates have been proposed, each with its own advantages and drawbacks. Here, we will discuss the three most common methods for verification: probabilistic methods based on generalization error bounds, Lipschitz arguments, and optimization-based methods.
The first framework for verifying learned certificates, generalization error bounds, is the least computationally expensive but provides relatively soft guarantees. These methods typically sample a large number of points from the state space, check whether the certificate is valid with some margin, and then use this margin to extrapolate (with high probability) to claim that the certificate is valid continuously throughout the state space. These claims are typically based on either statistical learning theory (e.g. [44] or Proposition 2 in [11]) or almost Lyapunov theory [82] (see [9] for an application to certificate verification). This verification strategy is perhaps the most convenient, since it requires little infrastructure in addition to that used for training the neural certificate; however, generalization bounds tend to be conservative, and in some cases it may be desirable to provide firm (i.e. nonprobabilistic) soundness guarantees.
The second common verification framework provides such deterministic guarantees and is based on the Lipschitz constant. Recall that a scalar function f (x) : R n → R is said to be Lipschitz continuous with Lipschitz constant L if for any two x 1 , x 2 ∈ R, it holds that |f (x 1 ) − f (x 2 )| ≤ L||x 1 −x 2 || for an appropriate norm. Certificate-learning works that make a Lipschitz argument for verification (e.g. [47], [83]) compute the Lipschitz constant for each certificate constraint L ci , and then check the margin of constraint satisfaction at each point on either a fixed-size [47] or adaptive [83] grid. If the constraint is satisfied with some margin (i.e. c i (x j , V ) ≤ −L ci τ , where 2τ is the distance between adjacent grid points), then the constraint is guaranteed to be satisfied continuously between those points. This strategy is convenient, since it can be applied to any Lipschitz continuous constraint without much overhead. However, it has a number of drawbacks. First, the use of the Lipschitz constant necessarily introduces conservatism by assuming worst-case variation between sampled points (and the estimated Lipschitz constant itself can be either difficult to estimate [84] or provide a very loose upper bound). Second, checking the constraints over a grid of points incurs the curse of dimensionality, limiting applications to higher-dimensional systems. Third, this after-the-fact verification scheme does little to guide the training process, since it is only used after training is complete (this drawback applies to both Lipschitz arguments and generalization error bounds).
The third common category of verification methods, based on optimization, fills this gap by running periodically throughout the training process to verify the certificate as it is learned (and provide feedback in the form of counterexamples where the certificate is not yet valid). These approaches typically take the form of a learner-verifier architecture, sometimes also referred to as counterexample-guided inductive synthesis (CEGIS [8], [49], [3], [64], [50]). In these architectures (illustrated in Fig. 9), the learner is responsible for training the certificate neural network, while the verifier periodically checks the learned certificate. If the certificate is valid, the verifier stops the training early; otherwise, it provides counterexamples to enrich the training dataset.
Depending on how the certificate and system dynamics are formulated, the verifier can be implemented using a number of different technologies. If the underlying dynamics are piecewise affine and all neural networks are encoded using Rectified Linear Unit (ReLU) activation functions, then the verification problem can be represented as a mixed-integer linear program (MILP) and solved using off-the-shelf MILP solvers, as proposed in [64]. If the underlying dynamics are nonlinear, then the verification problem can be solved using satisfiability modulo theory. SMT problems can be solved using dedicated solvers such as dReal [85]. For examples of this approach, see [8], [49], [3], [50], [74]. Both MILP-and SMT-based methods help address the certificate verification problem, with the added benefit of speeding the training process by providing counter-examples. However, both methods are computationally expensive, and their complexity typically grows exponentially with the number of neurons in the certificate network. In practice, this poor scalability limits the applicability of these methods; for example, the MILP-based method in [64] is demonstrated on networks containing only 16 neurons. More advanced MILP-based neural network verification tools exist, such as MIPVerify [86], but empirical results suggest they are currently limited to networks with less than 200 neurons [87]. SMT-based methods have been demonstrated on networks of up to 30 neurons in [3]. It is possible that recent advances in neural network verification (see [87] for a relevant survey) or adversarial analysis and training of neural networks [88] may improve the scalability of verifier architectures; however, most approaches are currently limited to small neural networks.
As a final note on the topic of verification, it is important to note that control certificates can still be valuable without exhaustive verification, for two reasons. First, even nonverified certificates can act as useful supervision for training control policies [9]. Second, it is possible to deploy a nonverified Lyapunov or barrier certificate safely using a real-time safety monitor. This monitor tracks the rate of change of the certificate and checks whether the derivative condition (4c) (for Lyapunov functions) or (12) (for barrier functions) is violated; any such violation indicates that the certificate is no longer able to guarantee stability or safety and the system should enter a fail-safe mode.

F. Effects of actuator limits
Similarly to constrained model-predictive control, certificate-based controllers such as the quadratic program given in (10a) can easily adapt to actuator limits [20]. The control policy is simply modified to respect the actuator limits (a CLF-based policy is shown here for example): where U is the set of admissible controls. When U is a polytope, then this policy remains a quadratic program and can be solved efficiently online. The only complication is ensuring that this QP will be feasible. A neural certificate architecture can accommodate this constraint through the use of differentiable convex programming [89], which allows back-propagation through a the result of solving a quadratic program like (24). To train the certificate network in this context, the QP policy is relaxed: and the certificate network is trained with an additional loss term to minimize r; see [10] for an example. Although solving this optimization problem at training-time incurs an additional offline cost, it enables a learning-enabled controller to provide assurance that it will respect actuation limits at runtime (as contrasted with black-box learned policies such as those derived from reinforcement learning, which make no such guarantees).

G. Attainable control frequencies
Another important consideration when deploying controllers to hardware is the computational burden of running that controller in real-time. This can become an issue when the complexity of the control task increases; for example, it can be difficult to run robust model-predictive control (MPC) algorithms in real-time, due to the additional complexity of considering the effect of disturbances over a long horizon [10]. In the case of MPC in particular, the need to consider the vehicle's safety over a multi-step horizon imposes a significant computational cost. In contrast, certificate-based controllers effectively encode long-term system properties (like safety and stability) into local properties of the certificate function; synthesizing a certificate can be seen as compiling long-term behaviors into local properties. As a result, certificate-based controllers need consider only a single-step horizon when evaluating a controller such as (10a). Empirically, this results in at least an order of magnitude increase in attainable control frequency as compared to robust MPC [10]. Because a neural certificate control framework shifts the burden of computation to the offline stage (synthesizing the certificate), it is well suited for deployment on robots with limited computational resources or in situations where high control frequencies are required.

VI. CASE STUDIES
In this section, we present a series of instructive examples to demonstrate how the certificate-learning techniques discussed in this survey can be applied to practical problems in robotics. The first example demonstrates a straightforward application of certificate learning: given a nonlinear model of an autonomous car with uncertainty, we synthesize a trajectorytracking controller that is robust to variation in the reference trajectory. Secondly, we demonstrate combining a learned CLF with a learned CBF to synthesize an observation-feedback controller for a mobile robot navigating a cluttered, unknown environment. We also include results from a hardware demonstration for this second example.
Source code for each of these examples, along with pretrained models, are available on the accompanying website: https://github.com/MIT-REALM/neural clbf. This code is intended to serve as a well-documented reference implementation for many of these techniques, and we hope that they will provide a useful starting point for any readers interested in applying these techniques to their own problems.

A. Learning a CLF for complex dynamics
Our first example involves learning a stabilizing tracking controller for a nonlinear model of an autonomous car. We use the single-track car model from the CommonRoad benchmarks [90]. This model includes not only nonlinear steering dynamics, but also the effects of friction and load transfer between the front and rear axles as the car accelerates. The model includes 7 state dimensions and two control inputs: steering angle velocity and longitudinal acceleration. More details on the dynamics can be found in [90], or as implemented in the code accompanying this paper. We modify the dynamics from [90] slightly to express the car's state relative to a reference trajectory. This example builds on experiments presented in [10].
These dynamics are not amenable to traditional control synthesis techniques (such as SoS, which fails due to numerical issues even when approximating these dynamics using polynomials [10]). However, we can apply the techniques introduced in Section IV to learn a controller based on a Control Lyapunov Function (CLF) that stabilizes this system about the reference trajectory. This section will explain how we apply these techniques to this specific problem.
To simplify the learning problem, we look for a CLF, which defines the optimization-based control policy (10a) and removes the need to simultaneously search for a control policy (in effect, the control policy is parameterized by the CLF). We then instantiate the optimization problem (17) with the specific constraints governing CLFs, given in (6a)-(6c). We encode the CLF with learnable parameters θ as V θ (x) = w θ (x) T w θ (x), where w θ is a fully-connected neural network with tanh activation functions and size 9 × 64 × 64 (with the car's 7 state dimensions expanded to 9 by replacing two angular dimensions with their sine and cosine). To improve the convergence of the learning process, we linearize the dynamics, construct a LQR controller for the linearized system, and find the Lyapunov function for the closed-loop linear system V lin = 1 2 x T P x, where P is the solution to the Lyapunov matrix equation. This linear solution is used to initialize the learned CLF by training the learned CLF to imitate V lin for 11 epochs; once this initialization phase is complete, we do not reference the linearized Lyapunov function and train to satisfy the constraints (6a)-(6c) (training continues to 25 total epochs).
Our choice to express the vehicle's state relative to the reference trajectory introduces a new challenge to this leaning problem. We wish to ensure that our learned CLF is valid not only for the reference trajectories seen during training, but also for the range of trajectories we might expect to see in practice. To address this issue, we can draw on work creating robust variants of CLF certificates [10]: we select two "scenarios" characterizing the uncertainty in the reference trajectory (representing maximum steering effort to the right and left), then train the CLF to be valid in both of these scenarios. Using our knowledge of the underlying model and the structure of the CLF conditions (6c) (which are affine in the model uncertainty, as the authors of [10] demonstrate), we can prove that the trained controller generalizes from these scenarios to more general trajectories.
A CLF for this system can be trained by running the code in training/train_single_track_car.py, and a pre-trained model can be evaluated using the code in evaluation/eval_single_track_car.py. The CLF learned using this method is shown in Figure 10 and the tracking performance is shown in Figure 11. Figure 10 clearly shows the difference between the neural CLF and the CLF found by continuous-time Lyapunov equation for the linearized system dynamics. Fig. 10. The CLF learned for the single-track car. Lighter colors indicate higher values of V ; as expected, V decreases to zero at the origin (corresponding to zero error relative to the reference trajectory). By ensuring that trajectories flow "downhill" on this landscape, a CLF-QP control policy can robustly track the reference trajectory. The 0.1-level sets of the neural CLF and the CLF found via linearization are overlaid to highlight the difference. Fig. 11. Tracking performance of a controller based on a learned CLF. Note that the system is only trained on "scenarios" like the circular reference paths shown above, but it successfully generalizes to more general reference paths through the use of the CLF.

B. Safe visual-feedback control with barrier functions
Our second example demonstrates the application of certificates to "full-stack" robotics problems that integrate perception and control. In particular, we can combine a CBF with a CLF (both learned using neural networks) to certify the safety and liveness of a perception-feedback controller capable of safely navigating previously-unseen environments. At a high level, this system uses a CBF to ensure that it remains safe at all times, and it uses a CLF to guide itself to the goal. To avoid getting stuck when the CLF and CBF conflict, the controller is capable of temporarily suspending the CLF as needed to move around obstacles (this corresponds to tracing a level set of the CBF, i.e. maintaining a constant level of safety, while seeking a state from which the CLF can safely decrease). To enable generalization to new environments, the CBF and CLF are learned as functions of observations (Lidar data and range and bearing to the goal) rather than states. More details on this example can be found in [21]. This example shows how learned certificates can be used to ensure safety as part of a larger robotics architecture.
We consider an autonomous ground robot with discretetime nonlinear Dubins car dynamics and the ability to observe its environment via local Lidar observations, represented as range o i along each ray (i = 1, . . . , N r ). We also assume that the robot can measure its range ρ and bearing φ relative to a beacon at the goal. We define the CBF h where h σ is a permutation-invariant neural network with parameters σ and the second and third terms impose the prior that the barrier function should correlate with distance to the nearest obstacle. The CLF is represented as V (ρ, sin φ, cos φ) = V ω (ρ, sin φ, cos φ) + ρ 2 + (1 − cos φ)/2, where V ω is a neural network and the second and third terms impose the prior that the Lyapunov function should correlate with distance to the goal. These neural networks are trained in a single randomly-generated 2D environment using the selfsupervision method discussed in Section IV.
Although the state dynamics of this system are controlaffine, as discussed in Section II, the dynamics in observation space are not. As a result, we cannot use a simple quadraticprogram control policy like Eq. (10a); instead, we must find a control input that satisfies the certificate conditions (5b) and (12) by searching over the action space directly. This is computationally feasible, e.g. by discretizing the action space, but extending this approach to higher-dimensional action spaces, perhaps by applying stochastic optimization methods such as CMA-ES [91], is an interesting area of future work. Finally, we must handle the complication that arises when the system cannot simultaneously preserve safety by satisfying the barrier function condition (12) while moving towards the goal (satisfying the Lyapunov condition (5b)). To do this, we can construct a simple hybrid controller that switches between goal-seeking and exploratory modes, preserving safety in all modes by enforcing the barrier function conditions, but able to temporarily disable the Lyapunov conditions in order to avoid getting stuck in local minima. In addition, the controller presented in [21] defines a constrained stochastic control policy in the exploratory mode to encourage exploration of the state space. The details of this switching strategy and a proof of its liveness can be found in [21].
The learned CBF and CLF are shown in a random environment in Fig. 12, and the hybrid controller is shown navigating a previously-unseen environment in Fig. 13. Even though these certificates were trained using a single randomly-generated environment, the controller is able to navigate new environments safely without adapting its certificate. To demonstrate the potential of certificate-enabled controllers to handle some of the implementation challenges in Section V, we also include results deploying this controller on hardware in a laboratory environment in Fig. 12. Fig. 12. The CBF h (left) and CLF V (right) learned for navigating a cluttered environment (lighter colors indicate higher values). The learned CBF correlates with distance to the nearest obstacle, while the learned CLF correlates with distance from the goal. Since the CBF is learned as a function of observations, it can easily generalize to new environments. Fig. 13. A certificate-based hybrid perception-feedback controller navigating a previously-unseen environment in both simulation (left) and hardware (right). In the hardware demonstration, a new obstacle is thrown in front of the robot partway through the experiment; the CBF allows the robot to gracefully avoid this obstacle. Labels (a) and (b) indicate where the policy switches from goalseeking to exploratory and vice-versa, respectively.

VII. LIMITATIONS AND FUTURE WORK
In our opinion, certificate-based learning for control has great promise but a number of drawbacks, which we discuss in this section. In addition to these limitations, we also highlight promising directions for future research in this area.
A. Limitations 1) Data requirements & Generalization: Presently, the field's understanding of the amount of data required to successfully train a neural certificate is based largely on intuition and experience; there is not yet a firm theoretical footing to predict the data required by a certificate-learning framework. Some works have made some promising progress in this direction; notably, Boffi et al. [44] prove that certificate learning is asymptotically consistent in the sense that as more data points are added to the training set, the maximum volume where the trained certificate fails to be valid shrinks to zero, but their analysis is restricted to systems that are known a priori to be stable. It remains to extend this theory to the case of general nonlinear systems, or systems where the controller is learned alongside a certificate.
Closely related is the issue of generalization error, which relates a learned certificate's performance on a finite training set with its performance on the full state space (as discusses in Section V-E). Some works [44], [11] have applied statistical learning theory to provide probabilistic upper-bounds on the generalization error (i.e. upper bounds that hold with some high probability), but these bounds tend to be conservative. There have been some preliminary attempts to apply almost-Lyapunov theory [82] to certificate learning [9], but it remains to formalize this connection.
2) Scalable verification: As mentioned in Section V-E, there has yet to be an effective solution to the certificate verification problem that scales to networks involving > 100 neurons. Probabilistic guarantees based on generalization error bounds [44], [14], [11] or almost Lyapunov theory [82] have the potential to scale by replacing exhaustive verification with probabilistic guarantees, but this theory has yet to be fully developed and integrated into the certificate learning process (all existing applications of these techniques are post hoc).

B. Future work
In addition to addressing these limitations in the existing theory of certificate learning, we believe that there are several promising directions to extend this theory to more complex controls and robotics problems.
1) Model-free certificate learning and theoretical connections to RL: Although works like [67] and [9] deploy certificate learning in the black-box dynamics model and unknownmodel settings, respectively, there remains much room to explore both practical and theoretical connections between certificate learning and reinforcement learning. On a practical level, [9], [36], [37] all propose to learn the parameters of a Lyapunov function [9], CLF [36], or CLF and CBF together [37] via reinforcement learning.
On a theoretical level, deep connections between certificate learning and reinforcement learning remain unexplored. For example, [34] shows that it is possible to construct a reward function for specific RL problems so that the corresponding value function is also a Lyapunov function, but it is not well understood whether this is possible more generally. In particular, what conditions must the reward function satisfy so that the value function implies a Lyapunov function? Is it always possible to construct such a reward, even when non-stability objectives are included in the reward function? Work on constrained Markov decision processes (cMDPs) suggests that it is possible to derive Lyapunov functions from a cMDP's cost metric [39], and later work [40] has extended this approach to continuous state and action spaces. We anticipate that these questions will be the basis for exciting future research at the intersection of RL and certificate learning.
2) Heterogeneous multi-agent certificates: With an eye towards deploying large fleets of autonomous robots (e.g. in drone delivery or driving contexts), some works have applied certificate learning to systems with multiple agents [11], [66]. However, these works focus exclusively on the case when every agent in the fleet has identical dynamics and constraints, as this allows a single certificate function to be learned for all agents at once. To extend these methods to heterogeneous multi-agent systems (e.g. a fleet of multiple autonomous delivery trucks, each with its own fleet of UAVs), it may be possible to apply compositional verification methods [92], [93], [94] to learn a certificate for various subsets of agents and combine them with rigorous safety guarantees.
3) Distributed & network control: Related to the subject of heterogeneous multi-agent control, we believe there is an opportunity for fruitful research in learning certificates for distributed systems and networks. In addition to compositional verification techniques discussed above, this setting raises a number of interesting issues. The first issue is control and communication delay [95], which has been studied in the controls literature for standard control barrier functions [96] but has not yet been applied in a certificate learning context. The second issue is fault tolerance [97], since a distributed control system should ideally be resilient to failures in individual nodes; this will likely require building on existing work in resilient control (e.g. [98]) to develop frameworks for resilient certificate learning. The third issue is scalability; contraction metrics in particular will likely require some decomposition techniques to avoid computing the eigenvalues of large matrices at training time. The application of certificate learning in this area also presents an interesting opportunity to apply graph neural networks [99], [100] to learn network control certificates.

VIII. CONCLUSION
In this survey, we have reviewed an emerging suite of methods for automatically synthesizing safe controllers for nonlinear systems -the neural certificate framework. This framework builds on established control theoretic concepts (Section II) by applying the representational power of neural networks (Section IV) to synthesize control certificates such as Lyapunov functions (Section IV-C), barrier functions (Section IV-D), and contraction metrics (Section IV-E). We have also discussed several practical and theoretical challenges within this framework, as well as proposed tools from the literature to mitigate these challenges (Section V). Finally, we have presented two case studies (Section VI) and discussed directions for future work (Section VII). We hope that this review provides an accessible jumping-off-point and high-level perspective on this emerging field.
A general framework for automatic certificate synthesis has long eluded control theorists. Since the development of Lyapunov functions in the late 1800s and modern control theory in the mid-to-late 1900s, a number of techniques have brought us progressively closer to this goal. LP-based simulation-guided synthesis [31] and sums-of-squares programming [6] provide important steps in this direction, each addressing some of the restrictions that applied to earlier works. In this context, neural certificates represent an important step forward for the state of the art for computational synthesis of nonlinear controllers. Neural certificates do not require a choice of hand-designed basis, as LP-based methods do, nor are they limited to systems with polynomial dynamics, as SoS methods are. Due to their generality, control architectures based on neural certificates have great promise for a wide range of robotics problems. Due to their generality and ease of implementation, we anticipate that neural certificates will see increasing adoption among practicing roboticists solving nonlinear safe control problems. Sum-of-Squares [6] CEGIS [31] HJ Reachability [24] Neural certificates Scalability O(n 6.5d ) for d-degree monomials [101] SMT is NP-complete [85] O( −n ), grid size [24]