Taming Differentiable Logics with Coq Formalisation
Reynald Affeldt, Alessandro Bruni, Ekaterina Komendantskaya, Natalia Ślusarz, Kathrin Stark
TL;DR
This work formalises differentiable logics (DLs) in Coq using the MathComp libraries to provide a uniform semantics and rigorous proofs of key DL properties. It encodes a generic LDL syntax and interpreters capable of supporting DLs such as Gödel, Łukasiewicz, Yager, product, DL2, and STL, and addresses core requirements like soundness, compositionality, and differentiability. The development yields new results (e.g., STL soundness under restricted conditions and complete shadow-lifting proofs for STL via L'Hôpital's rule) and uncovers concrete errors in prior literature, establishing a solid foundation for verified translation of logical properties into differentiable loss for property-guided training. By delivering a extensible, formally verified framework, the work enables certified compilation and verification workflows for neural-network properties and paves the way for future programming-language support in ML verification. The approach demonstrates the practicality of using Coq and MathComp for formalising state-of-the-art AI verification concepts and supports broader adoption of formal methods in ML tooling.
Abstract
For performance and verification in machine learning, new methods have recently been proposed that optimise learning systems to satisfy formally expressed logical properties. Among these methods, differentiable logics (DLs) are used to translate propositional or first-order formulae into loss functions deployed for optimisation in machine learning. At the same time, recent attempts to give programming language support for verification of neural networks showed that DLs can be used to compile verification properties to machine-learning backends. This situation is calling for stronger guarantees about the soundness of such compilers, the soundness and compositionality of DLs, and the differentiability and performance of the resulting loss functions. In this paper, we propose an approach to formalise existing DLs using the Mathematical Components library in the Coq proof assistant. Thanks to this formalisation, we are able to give uniform semantics to otherwise disparate DLs, give formal proofs to existing informal arguments, find errors in previous work, and provide formal proofs to missing conjectured properties. This work is meant as a stepping stone for the development of programming language support for verification of machine learning.
