Manuscript Offprint
arXiv:2610.27726Anytime-Valid Runtime Monitoring of Learned Barrier Certificates
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Learned barrier certificates provide a principled mechanism for establishing safety of stochastic systems, but their validity may deteriorate during deployment when the underlying dynamics differ from those used for training. We propose an anytime-valid runtime monitor that audits a learned barrier certificate using observed closed-loop trajectories. The monitor is intended to detect loss of statistical support for the deployed barrier condition; it does not by itself guarantee detection before unsafe entry or safety of a subsequent intervention. Specifically, the conditional barrier-drift condition is formulated as an episode-wise sequential hypothesis test, and observed barrier increments are transformed into a nonnegative test supermartingale, yielding finite-sample false-alarm control under arbitrary stopping times. Inspired by finite-horizon safety verification, we further introduce a deterministic temporal shaping of the monitoring boundary, making the monitor more conservative early in a prescribed deployment horizon while preserving anytime-validity. The monitor is designed to detect statistical evidence that the safety certificate is no longer consistent with the observed dynamics, rather than to predict unsafe entry. To assess the monitor empirically, we evaluate empirical alarm behavior under valid and invalid certificates. Code and data are available at https://github.com/FormalCert-AI/runtime-barrier-monitor.
1 Introduction
Safety is a critical requirement for learning-enabled autonomous systems operating in uncertain and evolving environments. In robotics, autonomous driving, and cyber-physical infrastructure, even rare failures can be catastrophic, making purely data-driven validation insufficient for deployment (Chougule et al. 2023; Uesato et al. 2018). Consider an autonomous drone navigating a cluttered warehouse whose floor plan changes over time. A barrier trained in simulation may provide a probabilistic safety guarantee under the assumed system dynamics and disturbance model, but unmodeled disturbances or environmental changes may invalidate the deployed safety certificate. This motivates runtime monitoring mechanisms that continuously assess whether the assumptions supporting a deployed safety certificate remain consistent with observed system behavior and, when necessary, trigger appropriate safety interventions.
Barrier certificates (Prajna and Jadbabaie 2004; Prajna, Jadbabaie, and Pappas 2007) certify safety through a scalar function whose expected value does not increase along trajectories, offering a scalable alternative to reachability analysis. In practice, however, the barrier B is learned from data, which introduces a fundamental verification gap: finite datasets provide incomplete coverage, simulation-to-reality mismatch induces distribution shift, and black-box models resist formal verification. In stochastic environments, iterative test-then-train refinement on counterexamples also cannot guarantee global validity of the updated certificate.
Rather than pursuing complete verification, we shift the focus to runtime monitoring and alarm-triggered intervention. The key idea is to continuously audit the deployed barrier using observed closed-loop trajectories and detect statistical evidence that the certificate is no longer consistent with the underlying dynamics. When sufficient evidence accumulates, the monitor can trigger a predefined intervention or fallback mechanism, thereby providing a practical mechanism for responding to potential loss of certificate validity during deployment. It is worth noting that the monitor is not designed to predict the exact time of unsafe entry, nor does it guarantee detection before every safety violation. Its purpose is to identify statistically significant evidence that the validity of the safety certificate is in question.
To realize this, we formulate runtime barrier auditing as an anytime-valid sequential hypothesis test based on e-processes (test supermartingales) and predictable plug-in betting strategies (Ramdas et al. 2023; Shafer et al. 2011; Vovk and Wang 2021; Shafer 2021; Waudby-Smith and Ramdas 2022). Observed barrier-value increments are converted into betting factors whose product forms a nonnegative test supermartingale. Consequently, the monitor retains finite-sample false-alarm control under arbitrary stopping times within an episode, allowing evidence to be assessed continuously without sacrificing the prescribed statistical validity. A finite deployment horizon also provides useful temporal structure for monitoring. Inspired by finite-horizon safety verification (Xue 2025), we introduce a deterministic time-varying scaling of the monitoring boundary that makes the monitor more conservative at early time steps and gradually approaches the standard anytime-valid threshold as the prescribed horizon is reached. The resulting framework combines anytime-valid runtime monitoring with a finite-horizon temporal boundary tailored to the deployment horizon.
The formal guarantee concerns the statistical validity of the barrier-condition monitor: when the learned barrier satisfies its conditional supermartingale condition, the probability of an alarm within an episode is controlled at the prescribed level. The theory does not guarantee detection of every barrier violation, detection before unsafe entry, or safety of the intervention taken after an alarm. These properties are therefore evaluated empirically and distinguished from the statistical false-alarm guarantee.
The contributions of this work are summarized as follows.
-
Anytime-valid barrier auditing: We formulate the conditional drift condition underlying a stochastic barrier certificate as an episode-wise sequential hypothesis test and construct an e-process from observed barrier increments. The monitor provides finite-sample level- false-alarm control under arbitrary within-episode stopping times.
-
Finite-horizon boundary shaping: Motivated by finite-horizon safety verification results (Xue 2025), we introduce a deterministic time-varying scaling of the monitoring boundary to tailor the monitor to a prescribed finite deployment horizon. The resulting exponential boundary profile is more conservative at early time steps and gradually approaches the standard anytime-valid threshold as the deployment horizon is reached.
2). Barrier Certificates and Synthesis. Barrier certificates have been widely studied for safety verification and controller synthesis (Prajna and Jadbabaie 2004; Jagtap, Soudjani, and Zamani 2018; Cao et al. 2025; Xue 2025; Ames et al. 2019; Žikelić et al. 2023; Zhi et al. 2024; Abate, Giacobbe, and Roy 2024; Xue 2024; Henzinger et al. 2025; Xue 2026). Existing data-driven methods (Mathiesen et al. 2023; Nejati and Zamani 2023; Salamati et al. 2024; Wu et al. 2026; Mathiesen et al. 2026) focus on synthesizing barrier certificates under assumptions such as known dynamics. In contrast, our work does not synthesize barrier certificates; rather, it provides an anytime-valid runtime monitor for auditing deployed barrier certificates and detecting statistical evidence that their underlying drift conditions may no longer be consistent with the observed dynamics, particularly under distribution shifts. The resulting alarm-triggered trajectories can be reused as counterexamples for subsequent certificate updating using existing synthesis methods. This creates a complementary relationship with CEGIS (Abate et al. 2021; Zhao et al. 2023; Chatterjee et al. 2023): whereas CEGIS focuses on iterative certificate synthesis and refinement, our framework focuses on deployment-time monitoring of a learned certificate.
Paper organization. The remainder of the paper is organized as follows. Section 2 presents the problem formulation. Section 3 develops the proposed anytime-valid runtime monitoring framework, including the e-process construction, adaptive betting strategy, and finite-horizon boundary shaping. Section 4 evaluates the monitor on stochastic benchmark systems under both valid and invalid barrier certificates. Section 5 concludes the paper and discusses future directions.
2 Preliminaries
This section introduces the mathematical setting underlying our framework. We first review e-processes and anytime-valid inference, and then formalize the stochastic control system and the runtime safety monitoring problem.
2.1 E-Processes and Anytime-Valid Inference
We work on a probability space , where is the sample space, is a -algebra, and is a probability measure. Random variables are measurable functions defined on this probability space.
Definition 1 (Filtration). A filtration is an increasing sequence of sub- -algebras of such that for all .
A filtration models the information available at each time ; contains exactly what is known up to that point.
Definition 2 (Martingale and supermartingale). Let be a sequence of random variables adapted to . We say that is a martingale if
-
is -measurable for all ,
-
for all ,
-
almost surely for all .
If the equality is weakened to , then is called a supermartingale. In this case the process drifts downward in conditional expectation. Every martingale is a supermartingale.
When the filtration is understood, we simply refer to as a martingale or supermartingale.
Definition 3 (E-process and test supermartingale). A nonnegative adapted process is called an e-process under a null hypothesis if for every bounded stopping time . A test supermartingale is an e-process that is also a supermartingale with . Every test supermartingale is an e-process, but the converse is not true.
The power of these objects comes from a time-uniform tail bound. While Markov’s inequality controls a single nonnegative random variable, Ville’s inequality extends the control to the whole trajectory of a test supermartingale.
Proposition 1 (Ville’s inequality (Ville 1939)). Let be a nonnegative test supermartingale under . Then for any , .
If the process ever crosses the threshold , we may reject with a false-alarm probability at most .
A standard method to construct a test supermartingale is through e-variables. Let be a sequence of nonnegative random variables such that is -measurable and . Then the product process with is a nonnegative supermartingale and hence an e-process. Each factor can be seen as a local bet against the null; the product aggregates this evidence multiplicatively. Persistent small violations of the null accumulate steadily, while isolated fluctuations have little long-term effect. By Ville's inequality, the test that stops and rejects the first time controls the type-I error at level , uniformly over all stopping times.
2.2 Problem Formulation
We consider a discrete-time stochastic dynamical system
where is the state, is the control input, and denotes an independent and identically distributed (i.i.d.) stochastic disturbance. Throughout this paper, both the system dynamics and the disturbance distribution are assumed to be unknown. The system is operated under a feedback policy , yielding the closed-loop dynamics . Let denote the natural filtration generated by the trajectory.
Safety objective. Let denotes a safe set, denotes the initial set. The safety objective is to ensure that trajectories starting from an initial state remain within with high probability, i.e., .
A standard approach to certifying such properties is through barrier certificates. To formalize the analysis, it is convenient to introduce the stopped (or frozen) system
This construction ensures that once the trajectory exits S, it remains outside. The probability that the original system stays within S coincides with the probability that the stopped system never leaves S (Yu et al. 2023).
Barrier certificate condition (Kushner 1967; Yu et al. 2023). Assume that the barrier function is integrable such that the following conditional expectation is well-defined. The function is called a barrier certificate if it satisfies
The last condition states that behaves as a supermartingale along the stopped system. If such a function exists, then for any , .
Remark 1. In this paper, we consider the barrier condition of the form (2c) for safety verification. Nevertheless, the proposed method is not restricted to this specific formulation and can be extended to more general barrier conditions, such as , which is widely used in finite-time and infinite-time safety verification, as well as reach-avoid analysis (Xue 2025, 2026).
Problem of interest. We consider the setting where both the barrier certificate B and the controller are learned from data, so condition (2c) may fail globally despite appearing sound on the training data. Rather than assuming the correctness of these learned components, our goal is to continuously audit their validity from realized trajectories while maintaining a time-uniform false-alarm probability bounded by a prescribed level . The resulting monitor can serve as a component of a runtime detection mechanism, providing statistical evidence that the learned barrier certificate is no longer supported by the observed dynamics.
3 Anytime-Valid Runtime Monitoring of Learned Barrier Certificates
In this section, we introduce our anytime-valid sequential monitoring framework for runtime auditing of learned barrier certificates (Fig. 1). Instead of requiring offline validation of a deployed barrier certificate, we continuously audit its consistency with observed closed-loop trajectories. By formulating barrier-condition monitoring as a sequential hypothesis test and constructing an e-process that accumulates evidence online, we obtain an anytime-valid monitor with finite-sample false-alarm control under arbitrary stopping times within an episode. The resulting evidence can be used to trigger predefined runtime interventions when the validity of the deployed safety certificate is called into question.
3.1 Anytime-Valid Monitoring
Trajectories and Barrier Consistency Hypothesis. We first formalize the observed closed-loop trajectories and the barrier consistency hypothesis that the monitor will audit throughout deployment. A single run of the closed-loop system under the learned controller produces a trajectory

Figure 1: Overview of the proposed framework for anytime-valid monitoring of learned barrier certificates.
with natural filtration , which captures all information available up to time within that specific episode, where , .
The first two conditions of the barrier certificate B can be constructed alone. Our task is to test whether the conditional supermartingale condition (2c) remains valid under the deployed dynamics. The monitor uses one realized trajectory to accumulate statistical evidence against this conditional null. The null hypothesis is therefore
for all . Equivalently, defining the one-step increment
we test whether . Under the null the barrier should not drift upward in expectation and any systematic tendency to increase signals a potential safety violation.
Local Evidence. We now convert each observed increment into an evidence factor that behaves like a fair bet against the null. Define
where the betting fraction is chosen at time using only information available up to that point in the same episode ( -measurable). Intuitively, if the barrier increases , the factor exceeds 1, signalling a surprise. If the barrier decreases, the factor is , consistent with .
Proposition 2 (One-step validity). Under , if , then .
Proof. By definition, . Under the conditional expectation of is non-positive, and , we have the conclusion.
Thus, under the null, each factor has conditional expectation at most 1 - it is a “fair bet” in the sense that we cannot expect to accumulate evidence against a true null. The betting fraction controls the sensitivity of the monitor: larger values react more strongly to positive increments but require a tighter bound to preserve non-negativity.
Evidence Accumulation. Local bets are combined multiplicatively into a single cumulative score that reflects the total evidence against the null accumulated during the episode. The trajectory-level evidence process is
Because each factor has conditional expectation , the product is a non-negative supermartingale under , a fact we record as a lemma if every factor satisfies .
Lemma 1. Under and , , is a test supermartingale.
Proof. Non-negativity is obvious. The process is adapted, and , where we used that is -measurable and the one-step bound from Proposition 2.
The product form of the e-process enables sustained evidence against the barrier condition to accumulate multiplicatively over time. When the observed barrier increments consistently provide evidence against , the corresponding betting factors can compound the evidence substantially, whereas transient fluctuations whose effects do not persist have less lasting influence on the accumulated score. This allows the monitor to respond to systematic departures from the learned barrier condition without treating every stochastic fluctuation as a certificate violation.
Because is a test supermartingale, Ville's inequality applied to the stopping rule bounds the false-alarm probability of any episode by : if the evidence process crosses the threshold, we reject , and under this occurs with probability at most . The threshold crossing should therefore be interpreted as evidence that the deployed barrier condition has lost statistical support, rather than as a direct prediction of unsafe entry. The following subsection exploits a prescribed finite deployment horizon to introduce a time-varying monitoring boundary.
3.2 Data-driven adaptive betting on (DAB)
Even if the above theory is established, we still encounter the following two difficulties: 1. How to choose a suitable that can satisfy the nonnegativity constraint on in Lemma 1; 2. Even if the constraints are met, how to adapt these bets to the observed barrier increments? Below we will introduce the design method of based on data-driven and using discounted empirical moments inspired by Adam.
Building on the Kelly betting principle in (Waudby-Smith and Ramdas 2022; Shafer 2021), we use an exponentially weighted version of the empirical first and second moments, inspired by the moment estimates in Adam (Kingma and Ba 2014). The unweighted case is recovered when . Specifically, we choose based only on barrier increments observed up to time , by setting , and
where is a fixed memory parameter. Both moments contain only increments observed by time , before observing . We set , and , and then use
Here, prevents excessively large bets and . Then , leading to the conservative cap . Under this choice, .
The intuition follows a growth-rate and Kelly-type principle. When the observed barrier increments fluctuate around zero, the estimated conditional drift remains small, resulting in a conservative betting fraction. In contrast, when the observed increments provide sustained evidence of a positive barrier drift, the estimated drift increases , allowing the e-process to accumulate evidence more rapidly. Thus, the adaptive betting rule places greater weight on persistent departures from the learned barrier condition while remaining conservative when the observed dynamics provide little evidence against it.
We introduce to address a specific cancellation effect in barrier increments: without forgetting , , so a sustained recent increase can remain masked by an earlier decrease, whereas discounts stale increments and allows the betting fraction to respond to increases relative to a recent barrier baseline. In the appendix, we provide a detailed demonstration of the scenarios in which the case fails.
3.3 Shaping the Abort Time via Deterministic Scaling
While the constant-threshold rule remains valid under arbitrary stopping times, it does not exploit the finite deployment horizon that often arises from practical constraints such as physical timeouts, fuel limits, or fixed simulation lengths. A finite horizon allows the monitoring boundary to be shaped so that early alarms require stronger evidence, reducing sensitivity to transient fluctuations, while the threshold gradually approaches the standard anytime-valid level as the horizon is reached. We therefore introduce a deterministic temporal scaling of the boundary that adjusts the monitor's conservatism over the episode while preserving the false-alarm guarantee .
We can achieve this temporal preference by scaling the supermartingale with a deterministic time factor, effectively shaping the abort boundary without altering the underlying evidence factor :
Under , because , the conditional expectation of the scaled process satisfies:
Thus, the expected value of grows by at most a factor of . Following the finite-horizon martingale properties established in Theorem 1 in (Xue 2025) (with ), the probability of crossing the terminal threshold is bounded by . We can formalize this by defining the sequential stopping rule as the first moment the scaled monitor crosses :
which guarantees that . Using , the stopping rule can be equivalently written as:
Therefore, the time-varying threshold preserves the desired false-alarm control while allowing earlier detection to be emphasized through the parameter . For , the rule reduces to the constant-threshold baseline. If , the trajectory is stored as a counterexample and used to update the barrier function and the policy when necessary.
Theorem 1 (Anytime-valid falsification guarantee). Let be as in (3). Suppose that is a nonnegative test supermartingale under . Define the rejection event . Then .
Proof. Define the scaled process
Since is a nonnegative test supermartingale under ,
Thus, satisfies the finite-horizon growth condition
from Theorem 1 in (Xue 2025), with
Moreover,
Therefore, the case and of Theorem 1 in (Xue 2025) gives
Finally,
Hence,
and therefore
This completes the proof.
Ultimately, this deterministic scaling mechanism has profound consequences for the temporal dynamics of the abort time.
• Case : is a test supermartingale; the rejection threshold is and the test is valid for any stopping time (no bias toward early or late abort). While theoretically clean, it ignores the finite horizon and treats all time steps equally, which can be wasteful when resources are limited or early decisions are preferred.
• Case (patient test): decreases exponentially over time, making the rejection threshold highest initially and lowest near the deadline. Thus, early alarms require stronger evidence, while the test approaches the classical anytime-valid rule as . This design is preferable when false alarms are costly or transient effects are common. For example, a drone may experience short-lived oscillations after takeoff. A patient monitor avoids unnecessary aborts by requiring sustained evidence before intervention. Larger values of improve robustness against transient fluctuations and spurious alarms, while values closer to 1 recover the standard monitor. This conservatism, however, reduces sensitivity to brief or rapidly developing safety violations.
By framing a as a patience parameter, the safety engineer can deliberately prioritize robustness against early noise or rapid detection and resource efficiency, choosing the mode that best aligns with the system’s physical characteristics and the cost of data collection.
3.4 Comparison with Direct Barrier Monitoring
Since the barrier value is a supermartingale under , one may ask whether directly monitoring the normalized barrier process is sufficient, making the proposed DAB mechanism unnecessary. Indeed, Ville's inequality guarantees episode-wise false-alarm control at level by raising an alarm whenever
Thus, direct barrier monitoring is statistically valid under . Moreover, as shown in Remark 2, it is a special case of the proposed multiplicative e-process. The key distinction is that direct monitoring fixes the betting strategy, whereas DAB allows the betting strategy to adapt to the observed barrier increments.
-
Dependence on the initial barrier value. Both direct monitoring and DAB use the nominal alarm threshold when their evidence processes are normalized to start at 1. However, direct monitoring is based on the relative barrier value , so its equivalent threshold in terms of the unnormalized barrier is . Consequently, the response of the normalized barrier process to a given absolute barrier change depends on the initial barrier value. DAB, in contrast, provides greater flexibility in how barrier increments contribute to the monitoring statistic through its adaptive betting strategy.
-
Adaptive evidence accumulation. Direct monitoring corresponds to the particular betting strategy , for which the multiplicative e-process reduces to . DAB allows alternative adaptive betting strategies that respond to recent barrier increments. In our implementation, DAB refrains from betting when the discounted sum of recent increments is negative, avoiding evidence losses during these periods and preserving evidence for subsequent barrier increases. As demonstrated in our experiments, this flexibility can improve detection across a broader range of initial states. Such improvements are empirical, however, and do not imply that DAB always detects certificate degradation earlier than direct monitoring.
Remark 2. Direct barrier monitoring is recovered by choosing , provided . Specifically, with , . Consequently,
Thus, direct barrier monitoring is a special case of the proposed multiplicative e-process. The potential benefit of DAB comes from its more flexible betting strategy and the resulting evidence accumulation, rather than from a stronger false-alarm guarantee.
3.5 Runtime Monitoring
The preceding subsections establish the statistical foundations of the proposed anytime-valid monitor. We now instantiate these results as a deployment-time runtime monitoring procedure.
In each deployment episode, the learned barrier and policy are fixed, and the monitor updates the e-process online using the observed closed-loop trajectory. The episode is terminated when the evidence process crosses the time-varying decision boundary. Under the null hypothesis that the deployed barrier satisfies the conditional drift condition, the probability of such an alarm within an episode is controlled at the prescribed level , regardless of the stopping time. The monitoring procedure is independent of how the barrier is constructed and can therefore be applied to analytical, optimization-based, or learned barrier certificates, provided that the assumptions required by the monitor are satisfied. The collected trajectories can optionally be stored as counterexamples and used for subsequent barrier or policy refinement between episodes; such updates do not occur within an episode and are therefore separate from the anytime-valid monitoring procedure. The complete deployment procedure is summarized in Algorithm 1.
Algorithm 1: Anytime-Valid Runtime Monitoring
Require: Initial barrier , policy , buffer size , significance level , maximum horizon , and patience factor
Ensure: Runtime monitoring
1: Initialize , ,
2: for deployment episode do
3: Observe ; initialize and
4: for do
5: Choose as in Eq. (4)
6: Set and observe
7: Append to
8: Compute
9: Update
10: if then
11: Exit the episode; break
12: end if
13: if then
14: Exit the episode; break
15: end if
16: end for
17:
18: if then
19: Optional: Update , using ; set
20: end if
21: end for
Remark 3. The monitoring procedure is intended to operate while the system remains in the safe set S. By construction, the stopped process follows the original system's dynamics whenever it is in the safe set S and remains frozen after exiting S. Consequently, the global supermartingale condition
is equivalent to the barrier-drift condition for the original system restricted to the safe set:
Indeed, outside S, the stopped process remains at its current state, so the supermartingale condition holds automatically with equality. Thus, the safe set S is precisely the region in which the barrier-drift condition needs to be monitored. Accordingly, each trajectory is terminated upon its first exit from S or upon reaching the prescribed horizon , whichever occurs first. Thus, once a trajectory exits the safe set, there is no need to simulate its subsequent evolution.
Remark 4. The monitor is designed to detect statistical evidence against the learned barrier condition, rather than to predict unsafe entry. At the same time, the monitor can serve as a component of a runtime safety-shielding mechanism by triggering a predefined conservative intervention when sufficient evidence indicates that the learned certificate is no longer consistent with the observed dynamics. Thus, a trajectory may move toward the unsafe region without triggering the monitor, provided that the monitored barrier condition remains statistically consistent with the observed dynamics. Such a situation does not constitute a failure of the proposed detection objective, since the monitor is intended to identify when the statistical support for the safety certificate has become questionable, rather than to predict every impending safety violation. Once sufficient evidence against the barrier condition accumulates, the deployed certificate is treated as unsupported for continued operation, and the predefined intervention can be activated to reduce the risk of subsequent unsafe behavior.
Alg. 1 resets the e-process at the start of each episode, yielding false-alarm control at level within each episode. The per-episode guarantee is appropriate when episodes are treated as separate operational units, as in episodic RL or session-based monitoring. If error control is instead required across deployment episodes, the episode-wise error budget can be allocated such that , for example, using or a summable sequence such as . By the union bound, the probability of at least one false alarm over all episodes is then at most . More elaborate cross-episode e-process constructions may also be considered when their required measurability and null conditions are satisfied. Such global error control involves a sensitivity trade-off: decreasing across episodes increases the rejection threshold and may reduce detection power in later episodes. We therefore use per-episode error control in our experiments and leave cross-episode error allocation as an application-dependent extension.
4 Experiments
We evaluate the proposed anytime-valid runtime monitoring framework on four benchmark systems. The experiments address three questions:
-
RQ1: whether the monitor preserves the prescribed false-alarm guarantee when the barrier certificate is valid;
-
RQ2: Can we detect environmental changes and invalid barrier certificates using our monitor?
-
RQ3: How does temporal boundary shaping trade fewer false alarms under valid certificates for delayed or missed detection under invalid certificates?
The default setting is , , , and , using the same runs. Table 1 also reports the standard anytime-valid rule . Subsection 4.1 answers RQ1, Subsection 4.2 answers RQ2. Subsection 4.3 answers RQ3. Detailed benchmark descriptions, implementation details, proofs of validity or counterexamples establishing invalidity for the candidate barriers are provided in Appendix A. The sensitivity of and is provided in Appendix B.
The formal objective of the proposed framework is runtime monitoring of the learned barrier condition. Theorem 1 provides a statistical guarantee for this objective: under , the probability of falsely rejecting the barrier-drift condition within an episode is at most . This guarantee does not imply a lower bound on detection power or guarantee that an alarm occurs before an unsafe transition. Nevertheless, the monitor can serve as a component of a runtime safety-shielding mechanism: when sufficient evidence is accumulated against the deployed barrier, a predefined intervention can be triggered rather than continuing to rely on an unsupported barrier. We therefore evaluate unsafe-rollout detection as a downstream operational detection measure of this monitoring mechanism in Subsection 4.4.
Why do we use ? Since enters the alarm threshold exponentially over the horizon, varying directly makes it difficult to interpret the strength of threshold shaping. We therefore parameterize in terms of , which directly determines the logarithm of the threshold inflation factor at the beginning of the horizon relative to the terminal threshold. With this parameterization, the alarm threshold at step is
Thus, at , the threshold lies above , and it decreases linearly in to at . The threshold on starts at and decreases exponentially to .
4.1 Runtime Monitoring under Valid Certificates
Under a valid certificate, Theorem 1 guarantees that the probability of an alarm within the horizon is at most for the system starting from the state in the initial set . To empirically assess the consistency of the observed alarm behavior within this theoretical guarantee, we sample initial states and simulate independent trajectories from each initial state. Let be the alarm time of the monitor on the -th trajectory from . Let be the first exit step of this trajectory from ( if it stays in ). Following Remark 3, monitoring stops at , and the empirical alarm rate for is
as well as the worst-case empirical alarm rate,
To summarize the empirical alarm across the sampled initial states, we call empirically abnormal if and report the fraction of empirically abnormal initial states,
Under a valid certificate, we expect to be close to zero and to remain close to or below , providing empirical support for the theoretical guarantee. Conversely, it is worth noting that observing empirical alarm rates below does not, by itself, establish the validity of the certificate which will be discussed in detail in the Appendix B.2.
Results. We evaluate the monitor on two benchmark systems, for which globally valid barrier certificates satisfying (2) are available. We also compare two betting strategies: DAB and
| System | Direct | DAB | |||
|---|---|---|---|---|---|
| Valid certificates | |||||
| System 1 | 0 | 0.00 | 4.80 | 0.00 | 0.90 |
| 4 | 0.00 | 0.20 | 0.00 | 0.10 | |
| System 2 | 0 | 0.00 | 0.00 | 0.00 | 0.00 |
| 4 | 0.00 | 0.00 | 0.00 | 0.00 | |
| Invalid certificates | |||||
| System 2-input | 0 | 18.10 | 100.00 | 82.10 | 92.00 |
| 4 | 17.90 | 100.00 | 79.90 | 81.50 | |
| System 3 | 0 | 24.00 | 69.40 | 79.00 | 96.30 |
| 4 | 23.80 | 63.60 | 78.40 | 95.10 | |
Table 1: Runtime monitoring under valid and invalid certificates with and the default setting on the same runs. is the fraction of initial states with and is the worst-case alarm rate. initial states, trajectories per initial state, , . All values are percentages. Figure 3 shows the full distribution of .
Direct . As shown in Table 1, both monitors achieve under both rules, which is consistent with the conclusion of in Theorem 1. However, the rates for the direct betting remain slightly higher than those for the DAB. As shown in Figure 5, System 1 has lower values in the initial points , thereby increasing the probability of an alarm when . In contrast, our method is far less sensitive to the initial value and is therefore much less affected by this issue. Overall, these observations are both consistent with the anytime-valid false-alarm guarantee under a valid certificate.
4.2 Runtime Monitoring under Invalid Certificates
In this subsection, we will answer RQ2 by investigating scenarios involving invalid barriers. The remaining systems in Table 1 have invalid barrier certificates. We consider two scenarios: (1) initially, we obtain a valid barrier function for System 2 in RQ1. However, environmental changes are inevitable in real-world scenarios. To simulate such a scenario, we actively injected noise into state from step onward:
where and the equation of is unchanged. Although the true environmental dynamics can be unknown in our monitor, we test the original valid function against the modified dynamical system and discovered counterexamples. Consequently, the original barrier function proved to be invalid in the changed environment. (2) The environment has not changed, but due to the sample-based training, the barrier function for system 3 is invalid from the start. We also find a counterexample establishing that this candidate is invalid.
Results. When , under invalid certificates, both methods detect substantial deviations from the prescribed alarm behavior, but their performance differs across the two systems. In System 2-input attack, direct betting has a worst-case alarm rate of 100%, compared with 81.5% for DAB. However, DAB identifies a much larger fraction of abnormal initial states, with compared with 17.9% for direct betting. In System 3, DAB performs better in terms of both metrics: its reaches 78.40%, compared with 23.80% for direct betting, while its worst-case alarm rate is 95.10%, compared with 63.60% for direct betting. These results highlight the complementary roles of the two metrics. A high worst-case alarm rate indicates that the monitor frequently raises alarms for at least one sampled initial state, suggesting that the deployed barrier condition may no longer be trustworthy. Meanwhile, quantifies the fraction of sampled initial states for which the empirical alarm rate exceeds , revealing how widely this evidence of potential barrier invalidity occurs across the initial states.
4.3 The patience parameter a
We introduce a as a deployment-time design parameter for the monitoring boundary. For fixed , , and betting strategy, changing a leaves the underlying evidence process unchanged and modifies only the decision rule applied to that evidence. Its choice expresses the trade-off between avoiding unnecessary intervention and detecting certificate invalidity promptly. A larger a is appropriate when unnecessary early interventions are costly and the application can tolerate delayed detection.
The experimental results in Subsections 4.1 and 4.2, reported in Table 1 and Figure 5, show that increasing a cannot increase the number of alarms and cannot advance the first alarm time. This observation is consistent with the theoretical analysis: a larger a raises the rejection threshold at early time steps, making the monitor more conservative. To illustrate how this affects monitoring under valid and invalid certificates, we consider Systems 1, System 2+input and System 3. In System 1, where the barrier certificate is valid, the DAB evidence process exhibits a transient increase that triggers an alarm when a = 1, but then drops rapidly (we give an example trajectory in Figure 2). Since the certificate is valid in this scenario, the threshold crossing is a false alarm caused by a temporary fluctuation, with no sustained evidence against the barrier condition. Increasing the temporal scaling to raises the early-time rejection threshold, preventing the evidence process from triggering an alarm. In this case, the more conservative threshold helps avoid an unnecessary alarm. In contrast, in System 2+input and System 3, where the barrier certificate is invalid, increasing the temporal scaling to delays the alarm compared with the case a = 1, but the evidence eventually becomes sufficient to cross the rejection threshold. Thus, the monitor still detects evidence against the barrier condition, albeit later. These examples illustrate the trade-off controlled by a: a more conservative threshold can suppress alarms caused by transient fluctuations under a valid certificate, but may also delay the detection of an invalid certificate.
In practice, before deployment, we do not know whether this barrier is valid. Thus, a should be selected according to the desired level of confidence in the deployed certificate and the trade-off between avoiding unnecessary alarms and detecting degradation promptly. When the certificate is considered highly trustworthy and avoiding unnecessary alarms is the priority, a larger a can be used to make the monitor more conservative. In contrast, when the validity of the certificate is uncertain or degradation is suspected, setting a = 1 is preferable because it allows earlier detection. In particular, we recommend a = 1 when prompt detection of potential certificate invalidity is the primary objective. When there is some disturbance in the early stages of the system, we recommend choosing a > 1.
4.4 Practical Applications of Algorithm 1
In this subsection, we empirically investigate two potential downstream applications of our runtime monitoring method: improving the adaptability of learned barrier certificates through retraining and detecting unsafe rollouts before the first safety violation. The latter evaluates the monitor's potential to serve as a component of a runtime safety-shielding mechanism. These experiments provide empirical evidence of the potential benefits of monitoring-guided retraining and early detection, but do not establish formal guarantees for either capability.
Following Algorithm 1, we will update the barrier using data collected from the environment: for System 2 under the input attack we retrain only the barrier function, and for System 3 we retrain both the barrier function and the policy. We then check whether the alarm rates return below .
Results. (1) For System 2 under the input attack, retraining the barrier function reduces the worst-case alarm rate over the sampled initial states from 100.00% to 0.00% for the direct rule and from 81.50% to 0.00% for DAB. For System 3, decreases from 63.60% to 0.00% for the direct rule and from 95.10% to 0.00% for DAB. After retraining, neither monitor raises an alarm in any run of either system, so . (2) With the accumulation of evidence , we find that our method could terminate the trajectory in advance, before the state leaves the safe set S. Before retraining, 42.88% of the evaluated System 3 trajectories exited the safe set S within the evaluation horizon. Among these exiting trajectories, DAB raised an alarm strictly before the first exit in 47.09% of cases under the default setting , compared with 11.88% for Direct. With , the corresponding rates were 51.81% and 22.56%, respectively. These pre-exit alarms provide an opportunity for intervention before unsafe entry.
5 Conclusions and Future Work
We introduced an anytime-valid framework for runtime monitoring of learned barrier certificates in stochastic systems. By continuously auditing observed barrier-value increments with an e-process, the proposed monitor provides finite-sample false-alarm control under arbitrary stopping times within each deployment episode. Motivated by finite-horizon safety verification, we further introduced a temporal boundary-shaping mechanism that adjusts the conservatism

— DAB evidence of one run ○ alarm, a = 1 ● alarm, default --- threshold, a = 1 — threshold, (default)
Figure 2: The trade-off between avoiding unnecessary alarms and detecting degradation promptly.
of the monitor over a prescribed deployment horizon. Experiments under valid certificates, certificate degradation, and distribution shifts demonstrate the practical utility of the framework for detecting statistical evidence against the barrier condition and supporting conservative runtime intervention.
Several directions remain for future work. First, extending the framework to safe RL, continuous-time dynamics, and partially observable systems would broaden its applicability. Second, validation on real robotic platforms under non-stationary environments would further demonstrate its practical value. Third, the relationship between barrier-condition violations and detection power, detection delay, and pre-violation detection warrants further theoretical and empirical study. Moreover, the finite-horizon factor a can be further studied as a time-varying parameter to adapt the monitoring strategy.
References
Abate, A.; Ahmed, D.; Edwards, A.; Giacobbe, M.; and Perruffo, A. 2021. FOSSIL: a software tool for the formal synthesis of lyapunov functions and barrier certificates using neural networks. In Proceedings of the 24th international conference on hybrid systems: computation and control, 1–11.
Abate, A.; Giacobbe, M.; and Roy, D. 2024. Stochastic omega-regular verification and control with supermartingales. In International Conference on Computer Aided Verification, 395–419. Springer.
Alshiekh, M.; Bloem, R.; Ehlers, R.; Könighofer, B.; Niekum, S.; and Topcu, U. 2018. Safe reinforcement learning via shielding. In Proceedings of the AAAI conference on artificial intelligence, volume 32.
Ames, A. D.; Coogan, S.; Egerstedt, M.; Notomista, G.; Sreenath, K.; and Tabuada, P. 2019. Control barrier functions: Theory and applications. In 2019 18th European control conference (ECC), 3420–3431. Ieee.
Bauer, A.; Leucker, M.; and Schallhart, C. 2011. Runtime verification for LTL and TLTL. ACM Transactions on Software Engineering and Methodology (TOSEM), 20(4): 1–64.
Cairoli, F.; Paoletti, N.; and Bortolussi, L. 2023. Conformal Quantitative Predictive Monitoring of STL Requirements for
Stochastic Processes. In Proceedings of the 26th ACM International Conference on Hybrid Systems: Computation and Control (HSCC), 1–11.
Cao, Z.; Wang, P.; Ong, L.; Žikelić, D.; Wagner, D.; and Xue, B. 2025. Comparative Analysis of Barrier-like Function Methods for Reach-Avoid Verification in Stochastic Discrete-Time Systems. arXiv preprint arXiv:2512.05348.
Chatterjee, K.; Henzinger, T. A.; Lechner, M.; and Žikelić, D. 2023. A learner-verifier framework for neural network controllers and certificates of stochastic systems. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems, 3–25. Springer.
Chougule, A.; Chamola, V.; Sam, A.; Yu, F. R.; and Sikdar, B. 2023. A comprehensive review on limitations of autonomous driving and its impact on accidents and collisions. IEEE Open Journal of Vehicular Technology, 5: 142–161.
Clarke, E. M.; and Zuliani, P. 2011. Statistical model checking for cyber-physical systems. In International symposium on automated technology for verification and analysis, 1–12. Springer.
Feng, Y.; Zhu, J.; Platzer, A.; and Laurent, J. 2025. Adaptive shielding via parametric safety proofs. Proceedings of the ACM on Programming Languages, 9(OOPSLA1): 816–843.
Gibbs, I.; and Candès, E. J. 2021. Adaptive Conformal Inference Under Distribution Shift. Journal of Machine Learning Research, 22(178): 1–59.
Gowal, S.; Dvijotham, K.; Stanforth, R.; Bunel, R.; Qin, C.; Uesato, J.; Arandjelovic, R.; Mann, T.; and Kohli, P. 2019. On the Effectiveness of Interval Bound Propagation for Training Verifiably Robust Models. arXiv:1810.12715.
Henzinger, T. A.; Mallik, K.; Sadeghi, P.; and Žikelić, D. 2025. Supermartingale certificates for quantitative omega-regular verification and control. In International Conference on Computer Aided Verification, 29–55. Springer.
Jagtap, P.; Soudjani, S.; and Zamani, M. 2018. Temporal logic verification of stochastic systems using barrier certificates. In International Symposium on Automated Technology for Verification and Analysis, 177–193. Springer.
Jansen, N.; Könighofer, B.; Junges, S.; Serban, A.; and Bloem, R. 2020. Safe reinforcement learning using probabilistic shields. In 31st International Conference on Concurrency Theory (CONCUR 2020), 3–1. Schloss Dagstuhl–Leibniz-Zentrum für Informatik.
Kingma, D. P.; and Ba, J. 2014. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980.
Kushner, H. J. 1967. Stochastic stability and control. Academic Press, Inc.
Lindemann, L.; Qin, X.; Deshmukh, J. V.; and Pappas, G. J. 2023. Conformal prediction for stl runtime verification. In Proceedings of the ACM/IEEE 14th International Conference on Cyber-Physical Systems (with CPS-IoT Week 2023), 142–153.
Mathiesen, F. B.; Romao, L.; Calvert, S. C.; Abate, A.; and Laurenti, L. 2023. Inner approximations of stochastic programs for data-driven stochastic barrier function design. In 2023 62nd IEEE Conference on Decision and Control (CDC), 3073–3080. IEEE.
Mathiesen, F. B.; Romao, L.; Calvert, S. C.; Laurenti, L.; and Abate, A. 2026. A data-driven approach for safety quantification of non-linear stochastic systems with unknown additive noise distribution. Automatica, 193: 113187.
Nejati, A.; and Zamani, M. 2023. Data-driven synthesis of safety controllers via multiple control barrier certificates. IEEE Control Systems Letters, 7: 2497–2502.
Prajna, S.; and Jadbabaie, A. 2004. Safety verification of hybrid systems using barrier certificates. In International workshop on hybrid systems: Computation and control, 477–492. Springer.
Prajna, S.; Jadbabaie, A.; and Pappas, G. J. 2007. A Framework for Worst-Case and Stochastic Safety Verification Using Barrier Certificates. IEEE Transactions on Automatic Control, 52(8): 1415–1428.
Ramdas, A.; Grünwald, P.; Vovk, V.; and Shafer, G. 2023. Game-theoretic statistics and safe anytime-valid inference. Statistical Science, 38(4): 576–601.
Salamati, A.; Lavaei, A.; Soudjani, S.; and Zamani, M. 2024. Data-driven verification and synthesis of stochastic systems via barrier certificates. Automatica, 159: 111323.
Shafer, G. 2021. Testing by Betting: A Strategy for Statistical and Scientific Communication. Journal of the Royal Statistical Society Series A: Statistics in Society, 184: 407–431.
Shafer, G.; Shen, A.; Vereshchagin, N.; and Vovk, V. 2011. Test martingales, Bayes factors and p-values. Statistical Science, 84–101.
Uesato, J.; Kumar, A.; Szepesvari, C.; Erez, T.; Ruderman, A.; Anderson, K.; Heess, N.; Kohli, P.; et al. 2018. Rigorous agent evaluation: An adversarial approach to uncover catastrophic failures. arXiv preprint arXiv:1812.01647.
Vertovec, N.; Mathiesen, F. B.; Badings, T.; Laurenti, L.; and Abate, A. 2025. Scalable verification of neural control barrier functions using linear bound propagation. arXiv preprint arXiv:2511.06341.
Ville, J. 1939. Etude critique de la notion de collectif, volume 3. Gauthier-Villars Paris.
Vovk, V.; and Wang, R. 2021. E-values: Calibration, combination and applications. The Annals of Statistics, 49(3): 1736–1754.
Waudby-Smith, I.; and Ramdas, A. 2022. Estimating means of bounded random variables by betting. arXiv:2010.09686.
Wu, T.; Wagner, D.; Ong, C.-H. L.; and Xue, B. 2026. PAC Finite-Time Safety Guarantees for Stochastic Systems with Unknown Disturbance Distributions. In Proceedings of the 29th ACM International Conference on Hybrid Systems: Computation and Control (HSCC '26). Association for Computing Machinery (ACM).
Wu, T.; Yu, Y.; Xia, B.; Wang, J.; and Xue, B. 2024. A framework for safe probabilistic invariance verification of stochastic dynamical systems. arXiv preprint arXiv:2404.09007.
Xue, B. 2024. Reach-avoid controllers synthesis for safety critical systems. IEEE Transactions on Automatic Control, 69(12): 8892–8899.
Xue, B. 2025. Finite-time safety and reach-avoid verification of stochastic discrete-time systems. Information and Computation, 105368.
Xue, B. 2026. Sufficient and necessary barrier-like conditions for safety and reach-avoid verification of stochastic discrete-time systems. Automatica, 187: 112919.
Yu, E.; Žikelić, D.; and Henzinger, T. A. 2025. Neural control and certificate repair via runtime monitoring. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 39, 26409–26417.
Yu, Y.; Wu, T.; Xia, B.; Wang, J.; and Xue, B. 2023. Safe probabilistic invariance verification for stochastic discrete-time dynamical systems. In 2023 62nd IEEE Conference on Decision and Control (CDC), 5804–5811. IEEE.
Zhao, H.; Qi, N.; Dehbi, L.; Zeng, X.; and Yang, Z. 2023. Formal synthesis of neural barrier certificates for continuous systems via counterexample guided learning. ACM Transactions on Embedded Computing Systems, 22(5s): 1–21.
Zhao, Y.; Hoxha, B.; Fainekos, G.; Deshmukh, J. V.; and Lindemann, L. 2024. Robust conformal prediction for STL runtime verification under distribution shift. In 2024 ACM/IEEE 15th International Conference on Cyber-Physical Systems (ICCPS), 169–179. IEEE.
Zhi, D.; Wang, P.; Liu, S.; Ong, C.-H. L.; and Zhang, M. 2024. Unifying qualitative and quantitative safety verification of dnn-controlled systems. In International Conference on Computer Aided Verification, 401–426. Springer.
Žikelić, D.; Lechner, M.; Henzinger, T. A.; and Chatterjee, K. 2023. Learning control policies for stochastic systems with reach-avoid guarantees. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 37, 11926–11935.
A Benchmark details
A function is a barrier certificate if it satisfies the three conditions (2a), (2b), and (2c). For a state , let denote its next state. For , the stopped system stays at , so (2c) holds with equality there, and it only has to be checked on . To show that a candidate is valid, all three conditions must hold everywhere. To show that it is invalid, we can just find a single counterexample suffices: .
System1: stochastic polynomial system (1D). Dynamics. The state evolves according to
The disturbances are independent across time. Sets and sampling.
Initial states are sampled uniformly from , independently of the disturbance sequence.
System 1: valid. We choose the candidate . It satisfies (2a), and (2b) holds since implies . For (2c), with , and . Hence, for every ,
System2: Van der Pol oscillator (2D) (Wu et al. 2024). Dynamics. The state evolves:
where . The disturbances are independent across time.
Sets and sampling.
Initial states are sampled uniformly from , independently of the disturbance sequence.
System 2: valid. The candidate is a polynomial B of degree 10, computed together with SOS multipliers of degree 10 by the SOS program using the method proposed in (Wu et al. 2024):
s.t. are SOS,
is SOS,
is SOS,
is SOS.
Each constraint implies one condition. A sum of squares is nonnegative, so , which is (2a). For , and , so , which is (2b). For , and , so , which is (2c). We solve the program with YALMIP and MOSEK.
To simulate the changed environments in reality, we actively injected noise into state from step onward:
where and the equation of is unchanged.
System 2+input: invalid. The candidate of system 2+input is the certificate of System 2. Since both the system and the candidate barrier function are polynomial, we can directly compute the function value at a given point, as well as the . At , we obtain and , so is a counterexample. Then the candidate in system 2 before is invalid in system 2+input.
System3: polynomial oscillator (2D) (Abate et al. 2021; Vertovec et al. 2025). Dynamics. We applied Euler discretization to the continuous system from the original text. With and , the system is
(7)
The disturbances are independent across time and . In the refinement stage, we train the policy and barrier function using neural networks with .
Sets and sampling. Let
We define the safe set by .
System 3: invalid. The policy and the barrier are neural networks trained from samples. Finding a valid certificate for such a stochastic system is difficult, and it is not needed here. The closed-loop dynamics are with , where
is the next state without noise. Since is a neural network, it's hard to provide the closed form for . So we bound it by partitioning the noise, as in (Cao et al. 2025), and by interval bound propagation through (Gowal et al. 2019). We split into cells of probability each. For , the successor lies in the box
, and interval bound propagation through gives a lower bound . Hence
The upper bound is obtained in the same way. At , we obtain and . The lower bound of the expectation exceeds , so is a counterexample and the candidate barrier function is invalid.
Computing environment. All experiments were run on an Apple M4 Pro machine (12 CPU cores, 24 GB of memory) with Python 3.12 (NumPy 2.4, SciPy 1.16, and PyTorch 2.5 for training). The SOS program for System 2 was solved with MATLAB R2025a, YALMIP and MOSEK 11.1.
B Further analysis
B.1 Additional Analysis of the Main Experiments
Why does a change in have different effects on system 2 +input versus system 3? Figure 4(a, b) shows the distribution of DAB's alarm rates over the sweep : stays within 2.2 points on both systems, while falls from 92.0% to 81.0% on System 2-input and only from 96.3% to 92.2% on System 3. Figure 4(c, d) shows why. Every threshold equals at , so a run whose evidence is still above at the horizon raises an alarm for every . A larger can only remove the alarm of a run that crosses before and stays below the tilted thresholds. On System 2+input the evidence settles just above from about on, so many runs cross late and only marginally, and the tilted thresholds remove part of them. On System 3 the evidence keeps rising until , so almost every run that crosses also crosses the tilted thresholds.
Why do the two betting strategies differ on the invalid systems? Figure 5 helps explain the different behaviors of the two betting strategies through the distribution of the initial barrier values . For direct betting, the evidence process satisfies , so the alarm condition for is equivalent to
Thus, a smaller initial barrier value yields a lower alarm threshold, making an alarm easier to trigger. System 2-input attack contains many initial states with small , and direct betting reaches a 100% empirical alarm rate for initial states with . However, this behavior is concentrated among a subset of the sampled initial states, as reflected by (Table 1, ; 18.10% with ). The same logic applies to the case where , since the threshold is still proportional to .
In contrast, the initial barrier values in System 3 are generally larger, resulting in higher alarm thresholds for direct betting. Accordingly, Figure 5(b)–(d) shows that its empirical alarm rate decreases rapidly as increases. DAB, however, adapts its betting fraction based on the observed barrier increments and exhibits nonzero empirical alarm rate over a broad range of initial barrier values. This helps explain why DAB achieves a higher fraction of empirically abnormal initial states and a higher worst-case empirical alarm rate than direct betting in System 3.
B.2 Sensitivity analysis
Next, we study how the horizon , and the betting rule affect the alarm rates. In these analyses, we vary only one parameter while keeping the others constant.
Valid certificates. No choice of these parameters can raise the false-alarm probability above . Under , . The barrier can still increase at single steps, but for every chosen from past observations, and . Hence is a test supermartingale for every and , and Theorem 1 holds for every and every . The first two rows of Figure 7 confirm that the alarm rates of System 1 and System 2 stay below in all settings.
Invalid certificates. In scenarios where certificates are invalid, various parameters will influence the corresponding alarm rates, we will also provide specific recommendations for parameter selection in practical deployment.
- The horizon factor We vary with , i.e., with the constant threshold . We choose here not because it is the best value of , but to isolate the effect of the horizon on the alarms: with fixed, and the threshold at every step would change together with , so the effect of the horizon could not be separated from that of the threshold shaping, which is studied separately in Figure 4.
Results. Figure 7(a,d) shows that the alarm rates for the valid systems remain unchanged as varies. With and a fixed , the share of runs that have raised an alarm by step is non-decreasing in : as the monitored trajectory approaches , it can only increase or stay constant. The observed rates remain below or equal to , consistent with the anytime-valid guarantee. For System 2+input, the attack starts at . Thus, when , the monitored trajectory contains no attacked step, and no alarms are raised (Figure 7(g)). For System 3, the barrier function is invalid from the start, but the evidence needs about 300 steps to reach . At , the evidence remains well below the alarm threshold (Figure 4(d)), so no alarms are raised (Figure 7(j)). From onward, DAB achieves higher than Direct betting, indicating that DAB is more effective at detecting the loss of validity of the barrier certificates over these horizons.
In practice, the choice of involves a trade-off between the monitoring horizon and the desired level of confidence in the barrier certificate. A shorter horizon limits the time over which evidence against the certificate can accumulate, whereas a longer horizon provides more opportunities to detect a loss of validity. Since the validity of the barrier certificate is generally unknown a priori, should be selected according to the practical monitoring requirements.

Figure 3: Distribution of the alarm rate over the initial states, Direct (left half) against DAB (right half), with the standard rule (top row) and the default (bottom row); the row below each axis holds the share of initial states with .
and the desired level of trust in the certificate. In particular, a shorter horizon may be appropriate when the certificate is considered highly trustworthy and limiting alarms is a priority, whereas a longer horizon may be preferred when more extensive monitoring is needed to detect potential invalidity.
- Betting rule . Direct uses and has no tunable parameters. Therefore, its alarm rates remain unchanged across the parameter setting in the second and third column of the Figure 7. In contrast, DAB uses
where depends on the discounted sums and of past increments, with the discount factor . When , earlier decreases in the barrier can offset subsequent increases in . As shown in Figure 7(h,k), both invalid systems consequently exhibit substantially fewer alarms. Lowering from 1 raises detection on both systems. Below 0.9, System 3 is flat while System 2+input declines, indicating that the effectiveness of the discount factor depends on the system.
The cap U mainly limits the betting factor when the Kelly-based factor is not the active constraint. Figure 7(i, 1) shows that DAB produces alarm rates above for System 2+input only for , whereas the alarm rates for System 3 change little once . These results suggest that the value of U needed to achieve effective detection depends on the system. In practice, U can be selected through a sensitivity analysis, choosing a value beyond which increasing the cap yields little additional improvement in detection performance. Increasing U does not compromise the anytime-valid guarantee, because the constraint remains in force. Consistent with this guarantee, the alarm rates for the valid systems remain below , even when .
We also try other betting strategies. We compare our adaptive betting rule with fixed betting rules computed from the same barrier increments. For any betting sequence with , define . Monitors use the threshold of the main experiments ( ) for their own betting sequences, and they use the average of the values for multiple fixed parameter values when they have the same weights. For Direct, . The fraction mixture uses , . The absolute mixture uses the fixed absolute bet for with , and . In each episode, each component of the absolute mixture keeps and fixed. In DAB, and are -discounted sums of past and (Eq. (4)).
What do these methods guarantee? For betting components under , their equal-weight mixtures are also nonnegative supermartingales. So Theorem 1 can be applied to all betting rules in Table 2.
Results. Table 3 and Figure 6 show that all monitors keep the alarm rates of the valid systems below , with



threshold, — 1 — 2 — 4 — 8 DAB: distribution — default
Figure 4: Effect of the patience parameter on the DAB alarm rates and evidence for the invalid certificates.

Direct
DAB
(default)
95% CI (a=1)
Figure 5: Initial barrier value and alarm rate: solid lines and filled markers for the standard rule , dashed lines and hollow markers for the default .
| Betting rules | Bet | Alarm | Guar. |
|---|---|---|---|
| Direct | ✓ | ||
| Fraction mix. | ✓ | ||
| Absolute mix. | ✓ | ||
| DAB | Eq. 4 | ✓ |
Table 2: Compared betting rules, all driven by the increments . Guar.: for every (Theorem 1).
on System 1 and no alarm on System 2.
On the invalid systems, DAB raises alarm rates above for of the initial states of System 2-input attack and of those of System 3. For Direct, these shares are only and , and for the mixtures they are at most . This is because a fixed bet is also placed while the barrier decreases, which multiplies the evidence by a factor below one. For example, the barrier of System 2-input attack decreases for many steps before the attack, and the fixed bets lose evidence during this period. DAB does not bet when the discounted sum of recent increments is negative, and thus keeps its evidence for the steps where the barrier rises. Moreover, the mixture methods may be less effective because they average the evidence processes of their components. Consequently, strong evidence accumulated by a single component may be diluted by the others, preventing the mixture from reaching the alarm threshold.
C Training Details
We train the neural barrier (with a softplus output layer so that structurally) by minimizing soft penalties on the barrier conditions. Given a batch of constraint states sampled from the safe region, we simulate independent successor states for each and estimate the conditional expectation by . The supermartingale decrease condition is enforced by
| System | Direct | Fraction mix. | Absolute mix. | Absolute mix. | DAB | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Valid certificates | ||||||||||
| System 1 | 0.00 | 0.20 | 0.00 | 0.50 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.10 |
| System 2 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| Invalid certificates | ||||||||||
| System 2-input attack | 17.90 | 100.00 | 11.30 | 100.00 | 0.00 | 0.00 | 0.00 | 1.20 | 79.90 | 81.50 |
| System 3 | 23.80 | 63.60 | 0.00 | 0.00 | 9.30 | 29.50 | 22.40 | 58.80 | 78.40 | 95.10 |
Table 3: Comparison with other monitors on the runs of Table 1. initial states, trajectories per initial state, , , . All values are percentages.

Figure 6: Distribution of the alarm rates over the initial states for all monitors ().
while the initial and unsafe conditions are enforced on sampled sets and by
where is an upper bound on the initial barrier value. The total loss is
where are weighting parameters. All terms are optimized with Adam. In this paper, we mainly focus on online training, where collecting multiple independent successors from the same state may be impractical. We therefore set . Although the resulting single-sample Monte Carlo estimate is unbiased for , it has higher variance. Moreover, applying the nonlinear ReLU penalty to a single-sample estimate does not provide an unbiased estimate of the ideal expected decrease loss. Consequently, the learned barrier is not necessarily a valid certificate. Nevertheless, the runtime monitor can detect potential violations and intervene against unsafe behavior. The neural network output uses a Softplus activation, which ensures that . We then define the deployed barrier function by the piecewise extension
Therefore, the nonnegativity condition and the unsafe-set condition for all are satisfied structurally. During deployment, the runtime monitor evaluates and computes the barrier increments as
The sampled unsafe-set loss is retained as an auxiliary training term to encourage the neural-network output to approach the prescribed unsafe value near the boundary of the safe set.
(a) System1 (valid)

(d) System2 (valid)
(b) System1 (valid)

(e) System2 (valid)
(c) System1 (valid)

(f) System2 (valid)
(g) System2 + input (invalid)
(h) System2 + input (invalid)
(i) System2 + input (invalid)
alarm rate and (%)
(j) System3 (invalid)
(k) System3 (invalid)
(1) System3 (invalid)
horizon (a=1)
DAB memory
DAB cap U
Direct: distribution of (top: )
Direct:
DAB: distribution of
DAB: ---
default
Figure 7: Sensitivity to the horizon , DAB memory and DAB cap U.