Verification and validation of cyber-physical systems (CPS) via large-scale simulation often surface failures that are hard to interpret, especially when triggered by interactions between continuous and discrete behaviors at specific events or times. Existing debugging techniques can localize anomalies to specific model components, but they provide little insight into the input-signal values and timing conditions that trigger violations, or the minimal, precisely timed changes that could have prevented the failure. In this article, we introduce DeCaF, a counterfactual-guided explanation and assertion-based characterization framework for CPS debugging. Given a failing test input, DeCaF generates counterfactual changes to the input signals that transform the test from failing to passing. These changes are designed to be minimal, necessary, and sufficient to precisely restore correctness. Then, it infers assertions as logical predicates over inputs that generalize recovery conditions in an interpretable form engineers can reason about, without requiring access to internal model details. Our approach combines three counterfactual generators with two causal models, and infers success assertions. Across three CPS case studies, DeCaF achieves its best success rate with KD-Tree Nearest Neighbors combined with M5 model tree, while Genetic Algorithm combined with Random Forest provides the strongest balance between success and causal precision.
Figures & tables
Fig. 1 : Example Illustration of DeCaF and Example signals of counterfactual explanation generated for the AT case-study systems with Throttle and Brake inputs.
Fig. 2 : Overview of DeCaF Framework.
Fig. 3 : Distribution of evaluation metrics of the ML techniques across our systems
Sys.
TS
Fail
GA
KD
RS
M5
RF
M5
RF
M5
RF
AT
300
169
84 (50%)
169 (100%)
166 (98%)
169 (100%)
166 (98%)
167 (99%)
CC
250
177
0 (0%)
177 (100%)
126 (71%)
177 (100%)
126 (71%)
174 (98%)
ACC
120
56
55 (98%)
56 (100%)
55 (98%)
56 (100%)
55 (98%)
55 (98%)
Tot.
670
402
139 (35%)
402 (100%)
347 (86%)
402 (100%)
347 (86%)
396 (99%)
TABLE I : Number of generated counterfactuals ( #CF ) for each system and DeCaF configuration. TS Size denotes the total number of test inputs generated by Step 1, #Fail denotes the number of failing test inputs that violate the system requirement. Percentages denote #CF as a fraction of #Fail .
Succ. (#Valid/#Fail)
Rel. Succ. (#Valid/#CF)
Sys.
GA
KD
RS
GA
KD
RS
M5
RF
M5
RF
M5
RF
M5
RF
M5
RF
M5
RF
AT
0.46
0.77
0.93
0.51
0.79
0.67
0.92
0.77
0.95
0.51
0.81
0.68
CC
0.00
0.73
0.59
0.65
0.42
0.26
–
0.73
0.83
0.65
0.59
0.26
ACC
0.61
0.61
0.93
0.68
0.43
0.45
0.62
0.61
0.95
0.68
0.44
0.45
Avg.
0.36
0.70
0.82
0.61
0.55
0.46
0.77
0.70
0.91
0.61
0.61
0.46
TABLE II : Success rates and relative success rates of DeCaF’s combinations of counterfactual generation strategies and ML models across our systems.
RS vs KD and GA
KD vs GA
Sys.
Comp.
p
A^12
ES
Sys.
Comp.
p
A^12
ES
AT
RS vs GA
0.014
0.538
None
AT
KD-M5 vs GA-M5
0.188
0.485
None
CC
RS vs KD
<10−15
0.661
Med.
AT
KD-M5 vs KD-RF
<10−18
0.282
Large
CC
RS vs GA
<10−12
0.664
Med.
AT
KD-M5 vs GA-RF
2.1×10−6
0.412
Small
ACC
RS vs KD
<10−8
0.683
Med.
CC
KD-M5 vs KD-RF
0.0015
0.361
Med.
ACC
RS vs GA
<10−8
0.687
Med.
CC
KD-M5 vs GA-RF
0.025
0.452
None
TABLE III : Statistical comparison of DeCaF configurations. Left: (RS vs KD) and (RS vs GA). Right: impact of the counterfactual generation strategies and ML models (KD vs GA). A^12 indicates effect size.
Sys.
GA
KD
RS
M5
RF
M5
RF
M5
RF
AT
(.42, .98)
(.62, 1.00)
(.53, –)
(.71, –)
(.77, 1.00)
(.88, 1.00)
CC
(–, –)
(.54, .93)
(.13, .88)
(.16, .92)
(.81, .96)
(.78, .96)
ACC
(1.00, .93)
(1.00, .78)
(1.00, –)
(1.00, –)
(1.00, 1.00)
(1.00, 1.00)
Avg.
(.71, .96)
(.72, .90)
(.55, .88)
(.62, .92)
(.86, .99)
(.89, .99)
TABLE IV : Goodness of DeCaF configurations: (necessity, sufficiency) scores across systems.
Safety
Avg Pred./G-score
Sys.
GA
KD
RS
GA
KD
RS
M5
RF
M5
RF
M5
RF
M5
RF
M5
RF
M5
RF
AT
0.75
0.65
0.85
0.87
0.99
0.96
1.75/1.00
2.35/0.99
1.84/1.00
2.54/1.00
2.13/1.00
2.44/1.00
CC
–
0.77
0.72
0.73
0.82
0.80
–/–
2.39/0.95
1.64/1.00
2.58/1.00
1.32/1.00
2.56/0.96
ACC
0.71
0.66
0.57
0.56
0.85
0.92
1.71/1.00
2.31/0.79
1.50/1.00
2.62/0.89
1.40/0.96
1.95/0.96
Avg.
0.73
0.69
0.71
0.72
0.89
0.89
1.73/1.00
2.35/0.91
1.66/1.00
2.58/0.96
1.62/0.99
2.32/0.97
TABLE V : Safety measure, average number of predicates, and generalization score of success assertions inferred by DeCaF across configurations.
Cyber-Physical Systems (CPS) study networked computation and control interacting with physical processes, from factories and power grids to robots and vehicles.
Modern autonomous Cyber-Physical Systems (CPSs), such as self-driving cars, face increasingly complex demands, and yet are expected to act reliably. The black-box nature often characterizing such systems, especially those relying on neural components, makes it impossible to fully verify the system behavior prior to deployment. Unfortunately, unexpected failures-when the system does not comply with its specification-are inevitable and may have catastrophic implications. To improve trust in the system and facilitate future mitigation after a failure occurs, it is important to try to derive an explanation for the unexpected system behavior. This paper introduces the novel concept of leveraging the framework of actual causality for CPS failure explanation. Up until now, this framework was only used to derive explanations in the context of simple systems, such as image classifiers. This paper addresses the theoretical gaps and provides the guidance needed to allow for correct explanation derivation in the CPS domain. Beyond the theoretical contribution, the paper presents two novel, practical, system-agnostic explanation derivation algorithms, allowing to prioritize either explanation optimality or derivation efficiency. The approach is demonstrated and evaluated in the context of a neural-network-controlled autonomous car, designed to avoid collisions.
Modern autonomous Cyber-Physical Systems (CPSs), such as self-driving cars, operate in increasingly complex environments while expected to maintain high reliability. The black-box nature of many of these systems makes it impossible to fully verify their behavior prior to deployment. When a failure occurs, it is important to analyze it to guide improvements to system robustness. A recent work introduced the novel concept of leveraging the framework of actual causality for CPS failure explanation. However, that work considered only a discrete, binary causal model that cannot capture continuous changes in system inputs. In this paper, we address these limitations by extending the actual causality framework with the notion of distance to account for the continuous characteristics of the system. Specifically, we introduce the novel concepts of distance-weighted actual cause and distance-weighted degree of responsibility, enabling causal influence to account for the magnitude of changes required to avoid a failure, rather than only its cardinality. While motivated by the continuous nature of CPSs, this constitutes a general extension of the theory of actual causality and enables more fine-grained analysis of continuous inputs in any causal model. Building on these notions, we present an efficient, practical, system-agnostic explanation-derivation algorithm that uses distance-weighted responsibility to guide the explanation search. We experimentally evaluate our approach across a number of environments from two autonomous-driving simulators with black-box neural controllers. The results show that the proposed extension provides more effective guidance than the current discrete approach.
Falsification searches for counterexamples to formal specifications in cyber-physical systems (CPS). With specifications written in Signal Temporal Logic (STL), falsification can be formulated as a robustness optimization problem, traditionally tackled with black-box search algorithms. In parallel, large language models (LLMs) have recently emerged as surprisingly effective optimizers when coupled with iterative prompting. In this work, we connect these ideas and introduce LLM-Falsifier, an LLM-based approach that falsifies specifications by minimizing the STL robustness degree. Beyond generic prompt-based optimization, our key idea is to expose the LLM to semantic information that is natural for language models but absent from standard numerical optimizers, including natural-language input and output names, output trajectories, and critical-time witnesses for the minimum robustness value. These additions enable smarter and more sample-efficient robustness search. On the ARCH-COMP falsification benchmarks, LLM-Falsifier is shown to outperform existing falsification tools based on a range of optimization paradigms, from surrogate-based and Bayesian optimization to search-based testing, on 14 of 21 specifications when measured by the average number of simulations required to find a counterexample.
Ali ArjomandBigdeli, Jiawei Zhou, Stanley Bak
Stony Brook University, Stony Brook, New York, USA