Papers
Topics
Authors
Recent
Search
2000 character limit reached

A Foundation for Differentiable Logics using Dependent Type Theory

Published 27 Feb 2026 in cs.LO | (2602.23878v1)

Abstract: Differentiable logics are a family of quantitative logics originated in the machine learning literature. Because of their origin, differentiable logics often come equipped with analytic properties that guarantee that they are differentiable. However, they usually lack an accompanying theory that describes their algebraic and proof-theoretic properties. Meanwhile, fuzzy logics, seen as substructural logics, have been studied algebraically and proof-theoretically, and some fuzzy logics with desirable analytic properties have also been used in machine learning. Our aim is to systematically compare analytic, algebraic and proof-theoretical properties of both fuzzy and differentiable logics. To this end, we formalize differentiable and fuzzy logics in a unified framework, encoded using the Mathcomp library in the Rocq proof assistant. We propose a single language specification to encompass multiple logics, using intrinsic typing to only allow valid and well-typed formulas for each of the logics that we encode: Yager, Łukasiewicz, Gödel and product fuzzy logics, as well as the differentiable logics DL2 and STL. Algebraically, we show how these logics can be interpreted using residuated lattices, which are prevalent in the theory of substructural logics. Analytically, we formalise the existence of a positive derivative for certain logical connectives, and to this end we formalise L'Hôpital's, contributing it to the Mathcomp library. Proof-theoretically, we formalise established sequent calculi for fuzzy logics, and we propose new sequent calculi for DL2 and STL_{\infty}, and formalise their soundness in our framework.

Summary

  • The paper formalises seven differentiable logics in roughly 9,400 lines of Rocq code, using intrinsically typed dependent syntax to ensure that only valid formulas and logic-specific operators can be constructed.
  • The paper characterises DL2 and STL∞ as residuated lattices, proves new sound hypersequent calculi for both, and identifies product logic and DL2 as strong candidates when algebraic structure and shadow-lifting are both required.
  • The paper completes the missing STLν shadow-lifting case using a mechanised L’Hôpital rule, proves convergence to minimum as ν approaches infinity, and demonstrates certified compilation of ε–δ robustness specifications into training losses.

Motivation and scope

Differentiable logics (DLs) are quantitative logics used to compile logical specifications into loss functions for property-guided training of neural networks. Although they originate in the machine learning literature and are typically accompanied by analytic guarantees such as differentiability, they generally lack a systematic account of their algebraic and proof-theoretic properties. Conversely, fuzzy logics—viewed as substructural logics—possess mature algebraic semantics via residuated lattices and established sequent calculi, but most of them fail the analytic properties required by gradient-based training. This paper addresses this asymmetry by formalising seven differentiable logics—Gödel, Łukasiewicz, Yagerr_r, product, DL2, STLν_\nu, and STL_\infty—in a single framework within the Rocq proof assistant using the Mathematical Components libraries (2602.23878).

The unifying device is a generic syntax with intrinsic typing: an inductive type expr indexed by dl_type, refined with flags controlling which connectives have defined semantics per logic. This design ensures that only well-typed formulas can be constructed for each logic, and it accommodates the heterogeneous domains involved: [0,1][0,1] for fuzzy logics, (,0](-\infty,0] for DL2, and (,+)(-\infty,+\infty) for STLν_\nu. The development totals roughly 9,400 lines of Rocq code.

Algebraic characterisation via residuated lattices

The central new contribution is a characterisation of machine-learning-inspired differentiable logics in terms of distributive residuated lattices—the standard algebraic semantics of substructural logics. The paper proves that Gödel, Łukasiewicz, Yagerr_r, product, DL2, and STL_\infty each form a residuated lattice; that Łukasiewicz, Yagerr_r, and STLν_\nu0 have involutive negation; that Gödel, Łukasiewicz, Yagerν_\nu1, product, and STLν_\nu2 have monoidal duals; and that Gödel and STLν_\nu3 have idempotent ν_\nu4. Notably, STLν_\nu5 itself fails the lattice axioms because its conjunction is deliberately non-associative, whereas STLν_\nu6 satisfies R1–R10 and N2–N4. This yields a sharp trade-off: at the limit ν_\nu7, STL's operators acquire desirable algebraic properties but lose shadow-lifting, so the parameter ν_\nu8 functions as a switch between analytic and algebraic adequacy. The authors also record negative results as mechanised counterexamples: negation in STLν_\nu9 is not definable as implication to _\infty0; negation in Gödel and product logics is not involutive; and Łukasiewicz, Yager_\infty1, and product are not monoidally idempotent.

No single logic satisfies all desirable properties simultaneously, consistent with Varnai and Dimarogonas's impossibility result that idempotence, associativity, and shadow-lifting cannot coexist. On this basis the paper identifies product logic and DL2 as the most promising candidates when residuated-lattice structure, sound sequent calculi, and shadow-lifting are jointly required.

Analytic properties and L'Hôpital's rule

On the analytic axis, the paper formalises shadow-lifting—the property that partial derivatives of an _\infty2-ary conjunction remain positive away from zero, capturing gradual improvement during training. Partial derivatives were not previously available in MathComp-Analysis; the authors define them via error vectors and limits over deleted neighbourhoods of zero. Shadow-lifting is proven for DL2 (partial derivatives equal to 1) and product logic (partial derivatives equal to _\infty3), both straightforwardly.

The technically demanding case is STL_\infty4. The original pencil-and-paper proof by Varnai and Dimarogonas covered only one of two non-trivial cases (_\infty5); the paper completes the missing case (_\infty6), showing the partial derivative equals _\infty7. A key prerequisite was a generalised formalisation of L'Hôpital's rule, contributed to MathComp-Analysis. The formalisation follows Rudin's proof via Cauchy's Mean Value Theorem, and the authors document a subtle difficulty: Rudin implicitly extends _\infty8 and _\infty9 by continuity with [0,1][0,1]0, which must be made explicit since only right-continuity is assumed. Cases involving infinite limits were not formalised, as they are unnecessary for shadow-lifting.

Additionally, the paper proves that STL[0,1][0,1]1's [0,1][0,1]2-ary conjunction converges to [0,1][0,1]3 as [0,1][0,1]4, justifying the definition of STL[0,1][0,1]5 as a genuine lattice operation. The convergence proof splits sums according to whether each argument attains the minimum, exploiting exponential decay—a mathematically simple argument whose mechanisation required substantial infrastructure for iterated operators interacting with minr.

The formalisation also surfaced errors in prior work: scaling of comparison operators in the authors' own earlier pen-and-paper proofs, and incompleteness of the published STL[0,1][0,1]6 shadow-lifting sketch, which omitted cases and the reliance on L'Hôpital's rule.

Proof-theoretic results

The paper gives the first formalisation of soundness for the established hypersequent calculi of Gödel, Łukasiewicz, and product logics, encoding sequents as pairs of lists and hypersequents as lists thereof, with soundness defined existentially over components of a hypersequent. It extends these calculi with derivable rules for the full differentiable-logic syntax (excepting [0,1][0,1]7 for product logic), noting that some derivations require extended yet derivable rules such as [0,1][0,1]8 for Łukasiewicz—an observation often left implicit in the literature.

Two new calculi are proposed. For DL2, the authors add a residuation-respecting implication to the original semantics and define a hypersequent calculus without a [0,1][0,1]9 rule (since (,0](-\infty,0]0 is undefined for DL2), proving soundness by structural induction; the simplicity of DL2's additive (,0](-\infty,0]1 makes this proof comparatively easy. For STL(,0](-\infty,0]2, a calculus sharing most rules with Gödel logic is given, with standard negation rules excluded because they are unsound; the proof requires working over extended reals (,0](-\infty,0]3, where the absence of lra/nra automation forces manual inequality proofs. No calculus is proposed for full STL(,0](-\infty,0]4, on the grounds that its non-associativity likely demands techniques from non-associative Lambek calculus. In lieu of completeness, the paper establishes weak completeness—provability of the relevant residuated-lattice axioms R1–R9—for both DL2 and STL(,0](-\infty,0]5 calculi. Yager(,0](-\infty,0]6 is argued unlikely to admit a calculus, since pre-linearity fails semantically (e.g., evaluating to approximately 0.86 rather than 1 for suitable parameters).

Application to property-guided training

The framework is exercised on (,0](-\infty,0]7-(,0](-\infty,0]8-robustness, formalised once generically and instantiated for any encoded logic via the corresponding interpretation function. Embedding the (,0](-\infty,0]9 norm and vector subtraction into the syntax, the property (,+)(-\infty,+\infty)0 compiles directly to loss functions, e.g., under DL2 or STL(,+)(-\infty,+\infty)1. This demonstrates the intended use case: certified translation from specifications to training objectives.

Limitations and open questions

Several restrictions are acknowledged explicitly. Shadow-lifting is treated only for conjunction; extension to other connectives is deferred. Scale-invariance and weak smoothness are not considered. Completeness of all calculi, cut-free proof theory, and adequacy relative to Boolean logic (non-trivial once real-valued comparisons are added) remain open. The formalisation specialises to real-number carriers rather than abstract residuated lattices, and uses polymorphic lists rather than multisets for hypersequents, which complicates automation. The infinite-limit cases of L'Hôpital's rule are unformalised. First-order quantification for differentiable logics remains an open problem, though the authors argue the accumulated machinery brings it within reach.

Conclusion

This work provides a uniform, mechanically verified foundation for differentiable logics spanning three research traditions—substructural algebra, real analysis, and Gentzen-style proof theory. Its principal contributions are the residuated-lattice characterisation of DL2 and STL(,+)(-\infty,+\infty)2, completed and corrected shadow-lifting proofs for STL(,+)(-\infty,+\infty)3 supported by a new L'Hôpital's rule in MathComp-Analysis, and the first sound sequent calculi for DL2 and STL(,+)(-\infty,+\infty)4. The development demonstrates that dependent-type encodings with intrinsic typing, combined with the Mathematical Components ecosystem, suffice to formalise state-of-the-art results from the machine learning literature, and it supplies a reusable substrate for certifying specification-to-loss-function compilation in tools such as Vehicle and CAISAR.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.