arXiv:2611.01146cs.LOOct 2026

Manuscript Offprint

arXiv:2611.01146

A polynomial-size logical twin for neural networks

Sandro Preto, Marcelo Finger

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

SANDRO PRETO AND MARCELO FINGER

ABSTRACT. A logical twin of a neural network is a logical representation that mimics the computation of the network through logical formulas. We revisit two earlier proposals for constructing logical twins of feedforward neural networks in Lukasiewicz logic, both of which are susceptible to exponential blow-up in running time and representation size. Building on ideas from both approaches, we present a new construction that directly yields logical twins in Lukasiewicz logic. We show that this construction can be computed in polynomial time and produces polynomial-size logical twins. Finally, we report an empirical evaluation of the three methods, showing that the new proposal substantially outperforms the other two.

1. INTRODUCTION

A logical twin of a neural network, as we propose to use this term, is a representation of such a network in the formal language of a logical framework. Just as formulas of classical logic represent Boolean functions and formulas of Lukasiewicz logic represent McNaughton functions, formulas of a logical system may represent the functions computed by a neural network. In this way, the computation performed by a neural network, usually represented by a graph circuit together with its associated weights and biases, may be carried out through evaluations of logical formulas comprised in its logical twin.

Neural networks are traditionally associated with the blackbox problem, which may be understood as the difficulty of justifying their learned weights and biases and of explaining their decisions, classifications, and the way they perform tasks [4, 6]. By contrast, logic and symbolic frameworks are usually regarded as being grounded in established laws of reasoning and as having a neatly defined semantics. In this sense, a logical twin may offer a new perspective on the blackbox problem by presenting its neural network twin in a symbolic framework that is often more interpretable, even though we acknowledge that logical formulas are not necessarily amenable to human interpretation, especially when they are large. A more immediate possibility, however, lies in the use of such logical twins for formal verification, which has already proved feasible for some neural networks and some of their properties—namely, reachability and robustness [17, 18].

The architecture of feedforward neural networks with the ReLU activation function is widely used in practice. If such an architecture is considered with input values in the unit interval [0, 1] and with the truncated identity max⁡(0,min⁡(1,x))\max(0, \min(1, x)) as the activation function in the output layer, then each output value of the network, as a function of its nn input values, determines a rational McNaughton function f:[0,1]n→[0,1]f:[0,1]^n \to [0,1] [17]. Such functions are continuous piecewise linear, and their linear pieces have rational coefficients. In this work, we refer to neural networks of this kind as ReLU-TId neural networks.

Formulas of Lukasiewicz logic represent McNaughton functions, which are the particular case of rational McNaughton functions whose linear pieces are constrained to have integer coefficients. Thus, direct representations by Lukasiewicz formulas are restricted to McNaughton functions. One approach to circumvent this restriction is representation modulo satisfiability in Lukasiewicz logic, formalized in the system L-MODSAT, a technique for implicitly representing functions by logical formulas proposed by Preto and Finger [15, 16].

In this setting, a function is represented not by a single formula, but by a pair ⟨φ,Φ⟩\langle \varphi, \Phi \rangle, where φ\varphi is a formula and Φ\Phi is a set of formulas. Then, once designated propositional variables are evaluated by a valuation vv according to the arguments of the function, its value is given by v(φ)v(\varphi), provided that vv satisfies the set Φ\Phi. Rational McNaughton functions were shown to be representable in L-MODSAT. Moreover, these representations can be constructed in polynomial time when the functions are given in the so-called closed regional format.

A regional format is a natural representation of piecewise linear functions in which the domain is partitioned into regions so that each linear piece coincides with the function over an associated region. Thus, an encoding of a function in regional format consists of pairs ⟨p,Ω⟩\langle p, \Omega \rangle, where pp is a linear piece and Ω\Omega is a region. When the regions Ω\Omega are polyhedra given by linear inequalities and these pairs satisfy a special property called lattice property, the encoding is said to be in closed regional format. In this case, a lattice representation can be built from it. The construction of representations in L-MODSAT is based on this lattice representation; see Section 3.1.

In order to build a logical twin for a ReLU-TId neural network, one must still extract a regional representation from its graph circuit as an intermediate step. This was the starting point of our earlier workshop paper Regional, Lattice and Logical Representations of Neural Networks, published in the proceedings of the 19th International Workshop on Logical and Semantic Frameworks, with Applications (LSFA 2024) [19], where an algorithm was provided for carrying out this translation. Although the translation produced by that algorithm is not guaranteed to satisfy the lattice property, our experiments indicated that such failures are rare in practice. The present work continues that line of research. However, rather than simply extending the workshop version, this article reframes the problem around a new algorithmic approach that substantially outperforms the previous method.

Beyond the problem that the lattice property is not guaranteed, and therefore that correctness or exactness of the resulting representation is not guaranteed either, that algorithm is exponential in the number of neurons of the ReLU-TId neural network. For this reason, in the present work we propose a new algorithm that abandons the intermediate step of constructing a regional format representation and, inspired by the work of [21], constructs a representation directly by following the architecture of the network.

The algorithm by Zhang and Bölskei [21] represents each neuron of a neural network separately by logical formulas and then mimics the compositional, circuit-structured nature of the network through substitutions in logical formulas. It uses both Lukasiewicz logic and rational Lukasiewicz logic, an extension of the former, to represent the neurons individually. However, this technique cannot be applied directly to ReLU-TId neural networks, but only to equivalent neural networks that must first be computed. Unfortunately, these equivalent neural networks generally have more neurons than the original ones, which may cause an exponential blow-up in this intermediate representation.

In this work, we present a polynomial-time algorithm for directly representing a ReLU-TId neural network in the system L-MODSAT, thereby yielding a polynomial-size logical twin. The neural network is first transformed into an equivalent one by operations that we call output and input normalizations. However, this equivalent network has the same number of neurons as the original one. Then, the function computed by each neuron, which is a truncated linear function, is represented in L-MODSAT. These functions are particular cases of rational McNaughton functions whose representations in L-MODSAT are even less complex. Finally, we leverage the representational framework of L-MODSAT to represent the circuit-based compositions by means of interface propositional variables and linking formulas, producing the logical twin.

We also show that the approach of Zhang and Bölskei [21] can be adapted so as to use neuron representations in L-MODSAT together with interface propositional variables and linking formulas. Thus, the paper brings together three methods for constructing logical twins of ReLU-TId neural networks in the L-MODSAT setting: a lattice-based method built on regional representations, an architecture-based compositional method, and our new polynomial-time proposal yielding polynomial-size logical twins. Finally, we present an empirical evaluation based on implementations of all three methods on randomly generated ReLU-TId neural networks, showing that the new proposal performs substantially better than the other two.

The rest of this work is organized as follows. Section 2 presents the necessary preliminaries on feedforward neural networks, Lukasiewicz logic, and semantics modulo satisfiability. Section 3 revisits two approaches to the construction of logical twins with exponential blow-up, namely the lattice-based method and the architecture-based compositional method. Section 4 introduces our new polynomial-size logical twin construction. Section 5 describes the implementations of the proposed methods and reports the experimental evaluation. Finally, Section 6 concludes the paper.