The #DNN-Verification Problem: Counting Unsafe Inputs for Deep Neural Networks

Luca Marzari, Davide Corsi, Ferdinando Cicalese, Alessandro Farinelli

Abstract

Formal verification of Deep Neural Networks (DNNs) typically yields a binary result: either a safety property is guaranteed (UNSAT) or a counterexample exists (SAT). However, in safety-critical applications, a binary answer is often insufficient for comprehensive risk assessment and model selection. This paper investigates the #DNN-Verification problem—the task of counting the exact number of input configurations that violate a safety property. We demonstrate that this problem is #P-complete and propose CountingProVe, a randomized approximation algorithm that provides provable confidence intervals for the violation rate. Experimental results on the ACAS Xu benchmark demonstrate that CountingProVe offers a scalable and precise alternative to exact counting methods, enabling a quantitative approach to AI safety.

1. Introduction

In the deployment of Deep Neural Networks (DNNs) within safety-critical systems—such as autonomous vehicles, medical diagnostics, or airborne collision avoidance—ensuring reliability is paramount. Traditional formal verification tools provide a rigorous "yes/no" answer regarding whether a model satisfies a specific safety property. While valuable, this binary output lacks the granularity required for nuanced risk management. If two models both fail a safety check, engineers currently lack a standardized method to determine which model is "safer" or how frequently the failure might occur in practice.

To address this, researchers from the University of Verona have introduced the #DNN-Verification problem. By moving from qualitative verification to quantitative counting, they provide a framework for measuring the Violation Rate (VR) of a network, offering a frequentist probability of failure that can guide model selection and safety shielding.

2. The Complexity of Counting Violations

The authors formally define #DNN-Verification as the task of counting the number of inputs within a bounded domain that lead to a violation of a safety property. A significant contribution of this work is the proof that #DNN-Verification is #P-complete.

In computational complexity, #P-complete problems are at least as difficult as NP-complete problems. While an NP-complete problem asks if a solution exists, a #P-complete problem asks how many solutions exist. This high level of complexity suggests that finding an exact count for large-scale, high-dimensional DNNs is likely intractable for most real-world applications, necessitating the development of efficient approximation techniques.

3. Methodology

The research proposes two primary algorithmic approaches to tackle the counting problem: an exact method and a randomized approximation.

3.1 Exact Counting

The exact counting algorithm utilizes a recursive partitioning approach. It splits the input domain into smaller sub-domains and uses a standard formal verifier (such as BaB or ProVe) as a backend engine:

  • If the verifier proves the entire sub-domain is safe, the count for that region is zero.
  • If the verifier proves the entire sub-domain is unsafe, the entire volume of that region is added to the violation count.
  • If the verifier is inconclusive (finding both safe and unsafe points), the sub-domain is split further until a conclusion is reached or a precision limit is hit.

3.2 CountingProVe: Randomized Approximation

To mitigate the "curse of dimensionality" that plagues exact counting, the authors developed CountingProVe. This algorithm provides a probabilistic lower and upper bound on the violation rate with a user-defined confidence level (e.g., 99%).

CountingProVe employs a heuristic splitting strategy. Instead of arbitrary branching, it samples violation points to identify a "median" for splitting the domain, effectively balancing the distribution of violations across branches. By applying Markov’s inequality over multiple iterations, the tool generates a provable confidence interval. A key innovation is the "Safe Rate" trick: by applying the same logic to the negation of the safety property, the algorithm derives an upper bound on violations, resulting in a tight interval $[VR_{low}, VR_{up}]$.

4. Experimental Evaluation

The framework was evaluated using the ACAS Xu benchmark—an industry-standard for DNN verification involving 45 models designed for aircraft collision avoidance—and various synthetic models to test scalability across input dimensions.

4.1 Performance and Scalability

Exact counting methods frequently reached a 24-hour timeout on complex ACAS Xu properties. In contrast, CountingProVe consistently provided tight confidence intervals in approximately 4 hours. The use of ProVe, a GPU-accelerated verifier, as the backend significantly enhanced performance, particularly as the depth and width of the neural networks increased, saving substantial computation time compared to CPU-based alternatives.

4.2 Precision

In scenarios where exact counts were obtainable, CountingProVe demonstrated remarkable accuracy. For a model with a ground-truth violation rate of 55.22%, the approximation algorithm returned an interval of [54.13%, 57.5%] in just 34 minutes. This suggests that the probabilistic bounds are sufficiently tight for practical engineering decisions and risk assessments.

5. Discussion and Future Directions

The #DNN-Verification framework represents a shift toward a more probabilistic and risk-aware approach to AI safety. By providing a quantitative metric, it enables better model selection and more informed implementation of runtime "shields" (monitors that block unsafe actions).

However, challenges remain. The computational cost, while lower than exact counting, is still significant for complex properties. Future work may involve parallelizing the algorithm's iterations to achieve near-linear speedups. Additionally, the authors propose integrating violation counts directly into the training process—using the violation rate as a loss function—to develop "safety-by-design" networks that are inherently more robust.

6. Conclusion

The #DNN-Verification problem and the CountingProVe algorithm provide a vital bridge between formal methods and statistical risk assessment. By transforming a binary "SAT/UNSAT" result into a measurable violation rate, this research equips engineers with the tools necessary to deploy Deep Neural Networks in high-stakes environments with greater confidence and transparency.

Summary updated

BibTeX
@inproceedings{marzari2023dnn,
  author = {Luca Marzari and Davide Corsi and Ferdinando Cicalese and Alessandro Farinelli},
  title = {{The \#DNN-Verification Problem: Counting Unsafe Inputs for Deep Neural Networks}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.24963/ijcai.2023/25},
}
Figure