<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>On Challenges and Opportunities in the Translation of Deep Neural Networks into Finite Automata</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Marco Sälzer</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Eric Alsmann</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Martin Lange</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Faculty of Electrical Engineering and Computer Science, University of Kassel</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The certification of safety properties and interpretation of neural networks is a topic of great concern. We recently devised an automata-based approach for addressing these tasks. It translates a neural network with ReLU activations into a finite automaton, capturing the input-output relation induced by the neural network. We report on a proof-of-concept implementation of this translation for a subclass neural networks, so called binarized neural networks, pointing out dificulties and opportunities of the proposed approach.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Neural Networks</kwd>
        <kwd>Finite Automata</kwd>
        <kwd>Verification and Interpretation</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>2. Preliminaries</title>
      <p>at any node is the ReLU function relu(x) = max(0, x).
same input dimension. A DNN  is a sequence of layers 1, . . . ,  such that for all , +1 the
input dimension of nodes in +1 is equal to the size of . The function computed by  is given
by (− 1(. . . 1() . . .)). In this work, we only consider DNN in which the activation function
Let Σ be a finite alphabet. We denote the</p>
      <p>multi-track alphabet consisting of -vectors of
symbols from Σ by Σ. A multi-track (nondeterminstic) finite automata (NFA) is defined as a
usual NFA with transitions over some Σ. Similarly, the language of such a multi-track NFA is
defined as usual. In the remainder of this paper the term NFA refers to such multi-track NFA
over a number of tracks , which is clear from the context.</p>
    </sec>
    <sec id="sec-3">
      <title>3. From Deep Neural Networks to NFA over Multi-Track Words</title>
      <p>example, the vector (− 3.725, 9.125) is represented by
Let  be some DNN computing R</p>
      <p>
        → R, defining the relation  = {(, ) |  ∈ R,  =
 ()} of all its input-output pairs. Now, [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] presents a construction of a finite automaton 
over a multi-track alphabet Σ+ such that the language ( ) of  captures  in the
sense that each word in ( ) can be decoded into a pair (, ) ∈  and each such pair of
 can be encoded into a word  ∈ ( ). An obvious way to encode a tuple (, ) as a
word over some Σ+ is based on the usual binary encoding, leading to the use of automata
over infinite words. It can be observed that weak nondeterministic Büchi automata sufice [
function over (Z∖2)
      </p>
      <p>→ (Z∖2) where (Z∖2) are the dyadic rational numbers, which are
exactly those that have a finite binary representation. Furthermore, we assume that all weights
and biases used in  are also from (Z∖2).1 Then, we can represent each (, ) using a finite
word over Σ+ with Σ = {+, − , 0, 1, .}, used henceforth for the remainder of this article. For
 = −
︂[ ]︂ [︂ 0
︂] [︂ 0
︂] [︂ 1
︂] [︂ 1
︂] [︂ .︂] [︂ 1
︂] [︂ 1
︂] [︂ 0</p>
      <p>︂]
+
1
0
0
1
.</p>
      <p>0
0
1
.</p>
      <p>
        We denote the function mapping such a multi-track word to the unambiguous vector of values
from (Z∖2) by dec. Then, one of the core results of [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] transfers easily.
      </p>
      <p>
        Theorem 1. Let  be a DNN with input dimension  and output dimension . There is NFA 
s.t. ( ) = { ∈ (Σ+)* |  (dec(1), . . . , dec()) = (dec(+1), . . . , dec(+))}.
Proof sketch. First observe that a DNN-node computes its output using four basic operations: 1.
addition of two values; 2. multiplication of a value with a fixed constant; 3. addition of a value
with a constant; and 4. the application of the ReLU function. The relation of value triples and
tuples induced by each of these operations can be recognized by an NFA. We refer to [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] for
details with the indication that the constructions are similar for our setting. An example of an
NFA recognising the addition relation is given in Figure 1. Second, observe that we can combine
these NFA using join and projection operations on single tracks to build an NFA recognising the
1This restriction is no limitation considering the presumed applications of this translation, namely the verification
and interpretation of DNN used in practice. There DNN necessarily contain and work over finitely representable
parameters and values.
      </p>
      <p>
        +
⎡0⎤⎡0⎤⎡1⎤ ⎡0⎤
⎣0⎦,⎣1⎦,⎣01⎦ ⎣0⎦
0 1 1
⎡1⎤
⎣1⎦
0
input-output relation defined by a DNN-node. Then, we use the same operations to establish
an inductive procedure to generate an NFA recognising the input-output relation defined by a
DNN. This is possible due to the inductive structure of DNN as indicated in Sect. 2. Again, see
[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] for details.
      </p>
    </sec>
    <sec id="sec-4">
      <title>4. A Proof-of-Concept Implementation</title>
      <p>
        We present a proof-of-concept implementation, translating so called Binarized Neural Networks
(BNN), into input-output equivalent NFA as discussed in Sect. 3. The BNN model [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] evolved as
a simple but powerful neural network model, defined similar to DNN but with weights and bias
restricted to +1 and − 1. It was shown, that BNN nearly achieve state-of-the-art performances
in comparison to standard DNN [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>
        The code is written in Python.2 The construction of an NFA  for a given BNN conceptually
follows the inductive construction described in Sect. 3 but uses two optimisations: first, we
represent transition labels symbolically. Consider the NFA for addition in Fig. 1. It is notable
that transitions are invariant under permutations of the labels in tracks one and two. This is not
surprising as addition is commutative. Consequently, the transition labels in these automata
can be stored symbolically as a pair (, ) with  ∈ {0, 1} representing the resulting bit in the
addition, and  ∈ N representing the number of 1-bits in the tracks to be added up. Second,
we use minimisation. After each construction that may create a non-minimal automaton,
explicit minimisation is employed. Since NFA minimisation is PSPACE-hard in general, we use
bisimulation quotienting instead. It may not produce minimal automata but it can be done in
low polynomial time [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], and it typically yields good results in practice [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>As benchmarks we use semi-randomly generated BNN: the input size is 1, the output size of
the BNN is 1 and all layers in between consist of 2 nodes. We denote such BNN with BNNfix . The
parameters (weights and bias) of the considered BNNfix were chosen uniformly from {− 1, 1}.
The benchmarks were computed on an Apple M1 Pro CPU with 32GB RAM. In the first part, we
run our translation without intermediate minimisation steps for BNNfix as specified above with
1 to 5 layers. The results are presented in the left chart of Fig. 2. The number of layers is plotted
2Available via https://github.com/marcosaelzer/NN2NFA
on the horizontal axis and the runtime, number of states/transitions on the two logarithmically
scaled vertical axes. The exponential blowup is clearly indicated by the linear interpolations
of the three data series, even for these relatively shallow BNNfix . The fluctuations are due to
the varying amount of − 1 and 1 parameters. In the right chart of Fig. 2 we see the efect of
minimisation. We considered 5 randomly generated BNNfix with 4 layers. The chart depicts the
percentage of reduction of the state set due to minimisation. The state size reduction is &gt;80%,
which indicates that our construction leads to an enormous amount of redundant states.</p>
    </sec>
    <sec id="sec-5">
      <title>5. Discussion and Outlook</title>
      <p>
        We presented a proof-of-concept implementation of the translation from DNN into finite
automata, here NFA over multi-track words, as introduced in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. The translation is exponential,
necessarily so since it reduces NP-hard DNN-reachability [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] to the NLOGSPACE problem for
emptiness of (weak) NBA. Unsurprisingly, this blow-up is visible in the benchmarks. In order to
achieve manageable runtimes, we focused our implementation on BNN of small size. There are
two takeaways from this restriction: first, the maximum representation size of a parameter in
the original DNN is crucial for the performance of the translation and, second, the inductive
approach presented in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] leads to many redundant states as indicated by the high amount of
reduction achieved by minimising the NFA in intermediate steps. This opens a clear path for
future work. The presumed applications of the DNN to NFA translation, namely vericfiation
and interpretation of DNN, are clearly tailored for DNN with parameters of small size, for
example Quantized Neural Networks [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. Furthermore, the inductive translation approach
seems intractable, due to the amount of redundant states generated and, thus, future work must
focus on establishing a translation of a more direct manner.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Sälzer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Alsmann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Bruse</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lange</surname>
          </string-name>
          ,
          <article-title>Verifying and interpreting neural networks using finite automata</article-title>
          ,
          <year>2022</year>
          . arXiv:
          <volume>2211</volume>
          .
          <fpage>01022</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>X.</given-names>
            <surname>Huang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Kroening</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Ruan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Sharp</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Sun</surname>
          </string-name>
          , E. Thamo,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Yi</surname>
          </string-name>
          ,
          <article-title>A survey of safety and trustworthiness of deep neural networks: Vericfiation, testing, adversarial attack and defence, and interpretability</article-title>
          ,
          <source>Comput. Sci. Rev</source>
          .
          <volume>37</volume>
          (
          <year>2020</year>
          )
          <article-title>100270</article-title>
          . doi:
          <volume>10</volume>
          .1016/ j.cosrev.
          <year>2020</year>
          .
          <volume>100270</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P.</given-names>
            <surname>Barceló</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Monet</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Pérez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Subercaseaux</surname>
          </string-name>
          ,
          <article-title>Model interpretability through the lens of computational complexity</article-title>
          ,
          <source>in: Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems</source>
          <year>2020</year>
          ,
          <article-title>NeurIPS 2020</article-title>
          , December 6-
          <issue>12</issue>
          ,
          <year>2020</year>
          , virtual,
          <year>2020</year>
          . URL: https://proceedings.neurips.cc/paper/2020/hash/ b1adda14824f50ef24f1c05bb66faf3-Abstract.html.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>B.</given-names>
            <surname>Boigelot</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Rassart</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Wolper</surname>
          </string-name>
          ,
          <article-title>On the expressiveness of real and integer arithmetic automata (extended abstract)</article-title>
          ,
          <source>in: Automata, Languages and Programming</source>
          , 25th International Colloquium, ICALP'98,
          <string-name>
            <surname>Aalborg</surname>
          </string-name>
          , Denmark,
          <source>July 13-17</source>
          ,
          <year>1998</year>
          , Proceedings, volume
          <volume>1443</volume>
          of Lecture Notes in Computer Science, Springer,
          <year>1998</year>
          , pp.
          <fpage>152</fpage>
          -
          <lpage>163</lpage>
          . doi:
          <volume>10</volume>
          .1007/BFb0055049.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>I.</given-names>
            <surname>Hubara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Courbariaux</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Soudry</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>El-Yaniv</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Bengio</surname>
          </string-name>
          ,
          <article-title>Binarized neural networks</article-title>
          ,
          <source>in: Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems</source>
          <year>2016</year>
          , December 5-
          <issue>10</issue>
          ,
          <year>2016</year>
          , Barcelona, Spain,
          <year>2016</year>
          , pp.
          <fpage>4107</fpage>
          -
          <lpage>4115</lpage>
          . URL: https://proceedings.neurips.cc/paper/2016/ hash/d8330f857a17c53d217014ee776bfd50-Abstract.html.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>I.</given-names>
            <surname>Hubara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Courbariaux</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Soudry</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>El-Yaniv</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Bengio</surname>
          </string-name>
          ,
          <article-title>Quantized neural networks: Training neural networks with low precision weights and activations</article-title>
          ,
          <source>Journal of Machine Learning Research</source>
          <volume>18</volume>
          (
          <year>2018</year>
          )
          <fpage>1</fpage>
          -
          <lpage>30</lpage>
          . URL: http://jmlr.org/papers/v18/
          <fpage>16</fpage>
          -
          <lpage>456</lpage>
          .html.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>R.</given-names>
            <surname>Paige</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Tarjan</surname>
          </string-name>
          ,
          <article-title>Three partition refinement algorithms</article-title>
          ,
          <source>SIAM Journal on Computing</source>
          <volume>16</volume>
          (
          <year>1987</year>
          )
          <fpage>973</fpage>
          -
          <lpage>989</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J.</given-names>
            <surname>Högberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Maletti</surname>
          </string-name>
          , J. May,
          <article-title>Backward and forward bisimulation minimization of tree automata</article-title>
          ,
          <source>Theoretical Computer Science</source>
          <volume>410</volume>
          (
          <year>2009</year>
          )
          <fpage>3539</fpage>
          -
          <lpage>3552</lpage>
          . doi:https://doi.org/ 10.1016/j.tcs.
          <year>2009</year>
          .
          <volume>03</volume>
          .022, implementation and Application of Automata (CIAA
          <year>2007</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>M.</given-names>
            <surname>Sälzer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lange</surname>
          </string-name>
          ,
          <article-title>Reachability is NP-complete even for the simplest neural networks</article-title>
          ,
          <source>in: Proc. 15th Int. Conf. on Reachability Problems</source>
          , RP'
          <volume>21</volume>
          , volume
          <volume>13035</volume>
          <source>of LNCS</source>
          , Springer,
          <year>2021</year>
          , pp.
          <fpage>149</fpage>
          -
          <lpage>164</lpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>030</fpage>
          -89716-1\_
          <fpage>10</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>T.</given-names>
            <surname>Liang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Glossner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Shi</surname>
          </string-name>
          ,
          <string-name>
            <surname>X. Zhang,</surname>
          </string-name>
          <article-title>Pruning and quantization for deep neural network acceleration: A survey</article-title>
          ,
          <source>Neurocomputing</source>
          <volume>461</volume>
          (
          <year>2021</year>
          )
          <fpage>370</fpage>
          -
          <lpage>403</lpage>
          . URL: https: //doi.org/10.1016/j.neucom.
          <year>2021</year>
          .
          <volume>07</volume>
          .045. doi:
          <volume>10</volume>
          .1016/j.neucom.
          <year>2021</year>
          .
          <volume>07</volume>
          .045.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>