A DbC Inspired Neurosymbolic Layer for Trustworthy Agent Design

Claudiu Leoveanu-Condrei · 2025

Read A DbC Inspired Neurosymbolic Layer for Trustworthy Agent Design by Claudiu Leoveanu-Condrei (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2508-03665.txt.

Introduction

Language models speak smoothly but promise nothing, and a 2025 paper by Claudiu Leoveanu-Condrei adds a contract layer to hold them to account. The idea borrows from Design by Contract, a software discipline where each part states what it needs and what it guarantees.

In the design, every call to the model passes through contracts that state meaning and type demands on inputs and outputs. When output breaks a contract, probabilistic fixes steer the next try toward compliance. Contract checks are defined by the programmer on well-typed data, making correctness something testable rather than hoped for. The author also proposes that any two agents honoring the same contracts count as interchangeable for those tasks.

Catalog record

CREATORClaudiu Leoveanu-Condrei
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE14 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2508-03665

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

A DbC Inspired Neurosymbolic Layer for Trustworthy Agent Design Claudiu Leoveanu-Condrei Abstract Generative models, particularly Large Language Models (LLMs), produce fluent outputs yet lack verifiable guarantees. We adapt Design by Contract (DbC) and type-theoretic principles to introduce a contract layer that mediates every LLM call. Contracts stipulate semantic and type requirements on inputs and outputs, coupled with probabilistic remediation to steer generation toward compliance. The layer exposes the dual view of LLMs as semantic parsers and probabilistic black-box components. Contract satisfaction is probabilistic and semantic validation is operationally defined through programmer-specified conditions on well-typed data structures. More broadly, this work postulates that any two agents satisfying the same contracts are functionally equivalent with respect to those contracts. [ [email protected], url=https://futurisold.github.io/, ] keywords neurosymbolic AI ,design-by-contract ,probabilistic programming ,large language models † † copyrightyear: 2025 † † copyright: Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). † † venue: ANSyA 2025: 1^{st} International Workshop on Advanced Neuro-Symbolic Applications, co-located with ECAI 2025. † † address: ExtensityAI, 20 Stefan-Fadinger-Straße, Wels, 4600, Austria 1 Introduction The increasing integration of generative models, especially Large Language Models (LLMs), into diverse applications necessitates formal approaches to ensure the dependability of their outputs ( Yan et al. 2024 ; Huang et al. 2024 ) . LLMs are susceptible to producing outputs that, despite being syntactically plausible, may be factually incorrect or semantically misaligned with user expectations ( Chen et al. 2021 ; Deng et al. 2024 ; Zhang et al. 2023 ) . Standard software engineering paradigms like Design by Contract (DbC) ( Meyer 1997 ) offer principles for constructing reliable systems by enforcing explicit specifications, termed contracts , that detail the mutual obligations between software components. This research extends and adapts these principles to the inherently probabilistic and semantic operational domain of modern generative models. Dinu et al. 2024 positions LLMs as components that function as semantic parsers. These parsers transform inputs (e.g., natural language prompts) into structured data representations or perform operations guided by semantic intent—the specific meaning and purpose the user intends to convey or achieve. Type theory ( Andrews 2013 ; Church 1940 ; Pierce 2002 ; Coquand 1986 ) , particularly through the lens of the Curry-Howard correspondence ( Wadler 2015 ; Dinu 2024 ) , establishes an isomorphism where types in a formal system are analogous to propositions in logic, and well-typed programs (or terms inhabiting those types) correspond to constructive proofs of those propositions ( Girard et al. 1989 ) . A ”well-typed” program or data structure, in this context, is one that conforms to the structural and constraint rules defined by its type. Consequently, defining contracts over such well-typed data structures provides a rigorous theoretical basis for specifying and verifying semantic requirements; a model output satisfying a contract can be seen as a constructive proof of the specification embodied by that contract. Contracts specify pre-conditions ( P ) that must hold before a component’s execution and post-conditions ( Q ) that are guaranteed upon successful, type-conformant completion. The satisfaction of these contractual obligations by LLMs, which are inherently probabilistic, is therefore also probabilistic. The layer incorporates automated, model-driven remediation attempts to guide the component toward outputs that comply with the contract. This methodology extends classical Hoare logic assertions of the form \{P\}C\{Q\} ( Hoare 1969 ; Leung 2010 ) —which specify that if a pre-condition P holds before the execution of a computational unit C , then a post-condition Q will hold upon its termination—by associating the fulfillment of such a triple with a quantifiable success probability, P_{succ} . In the context of this work, an agent \mathcal{A} is a tuple of the form \mathcal{A}=\langle\,\mathcal{M},\Pi,\Theta,\mathcal{T},\mathcal{C}\ \rangle where \mathcal{M} is a set of generative models (e.g., LLMs) the agent controls, \Pi is the set of instructions the agent must execute, \Theta is the set of hyperparameters governing the agent’s behavior (e.g., temperature, iterations, etc.), \mathcal{T} is the set of of types the agent can handle, and \mathcal{C} is the set of contracts the agent must satisfy. The agent’s behavior is defined by its ability to generate well-typed outputs according to \mathcal{T} , given inputs that are well-typed according to \mathcal{T} and instructions in \Pi , while respecting hyperparameters \Theta and satisfying contracts \mathcal{C} . Inspired by observational equivalence ( Morris 1968 ; Hennessy and Milner 1985 ; Plotkin 1981 ; Da Silva 1992 ) , agents satisfying the same probabilistic contracts are functionally equivalent with respect to those contracts; they differ only in (i) P_{succ} , (ii) operational costs, and (iii) potential —i.e., the capacity of the agent to satisfy an ever more complex set of conditions, enabling principled comparison and selection. In practice, guardrails and schema validators ( NVIDIA 2023 ; Colvin 6 14 ) , function-calling and constitutional-style self-remediation ( Lin et al. 2024 ; Chen et al. 2024 ; Bai et al. 2022 ; Madaan et al. 2023 ) , and ReAct/RAG correction loops ( Yao et al. 2023 ; Asai et al. 2024 ; Shinn et al. 2023 ; Yao et al. 2023 ; Besta et al. 2024 ) can all be expressed as pre/post predicates with bounded remediation under the contract layer. Our contribution is a unified, declarative DbC formalism and execution flow that subsumes these patterns while remaining implementation-agnostic. 2 Related Work Program Correctness and DbC: The axiomatic approach ( Floyd 1993 ; Hoare 1969 ) and DbC ( Meyer 1992 ) provide foundations for reasoning about software behavior through explicit interface specifications ( Leung 2010 ) . While runtime monitoring imposes overhead, soft contract verification ( Nguyen et al. 2014 ) enables static proofs via symbolic execution, and Hanus 2020 combines static/dynamic checking for compile-time verification. Type Theory: From Church’s simple types ( Church 1940 ) to Intuitionistic Type Theory ( Coquand 1986 ; Pierce 2002 ) , type systems ensure well-structured data for contracts. The Curry-Howard correspondence ( Wadler 2015 ; Andrews 2013 ) links types to logical propositions, making type conformance a prerequisite for semantic validation. Probabilistic Program Logics: Probabilistic Hoare Logics ( Kozen 1979 ; Den Hartog and de Vink 2002 ) establish properties with probabilities, extended by loops ( Sun et al. 2024 ) and union bounds ( Barthe et al. 2016 ) . eRHL ( Avanzini et al. 2025 ) provides quantitative reasoning for probabilistic programs with completeness results. LLM Reliability: LLMs produce inconsistent outputs ( Yan et al. 2024 ) despite code generation ( Chen et al. 2021 ) and semantic parsing capabilities ( Dinu et al. 2024 ; Schneider et al. 2024 ) . PEIRCE ( Quan et al. 2025 ) unifies material/formal inference through neuro-symbolic conjecture-criticism, while contracts address DL API reliability ( Ahmed et al. 2023 ) . Echoing Marcus 2001 , reliability may hinge on architectures that explicitly manipulate symbols, providing the deterministic, compositional substrate today’s LLMs lack. 3 Implementation The contract layer is built entirely on the SymbolicAI framework ( Dinu et al. 2024 ) , extending its neurosymbolic capabilities with DbC-inspired validation mechanisms 1 1 1 The contract source code is available at this GitHub [link] ; the documentation is available at this GitBook [link] . For challenging practical use

Read the complete text