<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Verifying the Safety of Autonomous Systems with Neural Network Controllers</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>01/31/2021</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10331772</idno>
					<idno type="doi">10.1145/3419742</idno>
					<title level='j'>ACM Transactions on Embedded Computing Systems</title>
<idno>1539-9087</idno>
<biblScope unit="volume">20</biblScope>
<biblScope unit="issue">1</biblScope>					

					<author>Radoslav Ivanov</author><author>Taylor J. Carpenter</author><author>James Weimer</author><author>Rajeev Alur</author><author>George J. Pappas</author><author>Insup Lee</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[This article addresses the problem of verifying the safety of autonomous systems with neural network (NN) controllers. We focus on NNs with sigmoid/tanh activations and use the fact that the sigmoid/tanh is the solution to a quadratic differential equation. This allows us to convert the NN into an equivalent hybrid system and cast the problem as a hybrid system verification problem, which can be solved by existing tools. Furthermore, we improve the scalability of the proposed method by approximating the sigmoid with a Taylor series with worst-case error bounds. Finally, we provide an evaluation over four benchmarks, including comparisons with alternative approaches based on mixed integer linear programming as well as on star sets.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>Following the success of neural networks (NNs) in traditional learning tasks such as image classification <ref type="bibr">[44]</ref> and natural language processing <ref type="bibr">[8]</ref>, learning-enabled components have been introduced to a variety of new domains, including safety-critical systems such as autonomous vehicles <ref type="bibr">[4]</ref> and air traffic collision avoidance systems <ref type="bibr">[23]</ref>. Assuring the safety of such systems, however, has proven challenging due to the brittle nature of modern NNs. For example, slight 7:2 R. <ref type="bibr">Ivanov et al.</ref> input perturbations can cause the NN to switch its output to an arbitrary new class, as is the case with adversarial examples <ref type="bibr">[43]</ref>. Such issues have highlighted the need to formally verify the safety of NN-based systems for different scenarios and for a range of possible inputs to the NN.</p><p>One approach to ensuring the safety of these systems is to analyze the NN in isolation and verify safety properties of the NN's output for given sensitive inputs <ref type="bibr">[12,</ref><ref type="bibr">13,</ref><ref type="bibr">15,</ref><ref type="bibr">18,</ref><ref type="bibr">24,</ref><ref type="bibr">49,</ref><ref type="bibr">50]</ref>. Most of these methods work by exploiting the NN structure, e.g., the piecewise linearity of the rectified linear unit (ReLU), and by transforming the verification problem into an optimization problem such as a satisfiability modulo theory (SMT) program <ref type="bibr">[13,</ref><ref type="bibr">24]</ref>, mixed integer linear program (MILP) <ref type="bibr">[12]</ref>, semi-definite program (SDP) <ref type="bibr">[15]</ref>, or a relaxed linear program <ref type="bibr">[50]</ref>. There also exist techniques that approach the problem from a reachability point of view and approximate the reachable NN output sets using interval analysis <ref type="bibr">[49]</ref> or zonotopes <ref type="bibr">[18]</ref>.</p><p>Analyzing the NN in isolation does not immediately imply the safety of the entire autonomous system, however. To analyze the whole system, one would need to reason about the interaction between the NN and the physical plant (e.g., a car) and verify that all reachable plant states are safe. Several works have been developed to verify the safety of autonomous systems with NN controllers <ref type="bibr">[11,</ref><ref type="bibr">20,</ref><ref type="bibr">22,</ref><ref type="bibr">42,</ref><ref type="bibr">47]</ref>. These approaches combine ideas from NN verification, e.g., transforming the NN into an MILP or an SMT program <ref type="bibr">[11,</ref><ref type="bibr">42]</ref>, with ideas from classical dynamical system reachability <ref type="bibr">[6,</ref><ref type="bibr">25]</ref>, e.g., compute reachable sets for the NN output <ref type="bibr">[22,</ref><ref type="bibr">47]</ref>.</p><p>In our preliminary work, we developed one of the approaches mentioned in the previous paragraph, namely Verisig <ref type="bibr">[22]</ref>. Verisig focuses on NNs with smooth activations, e.g., sigmoid or hyperbolic tangent (tanh), and works by transforming the NN into an equivalent hybrid system. Specifically, since the sigmoid/tanh is the solution to a quadratic differential equation, each neuron could be viewed as a state in a dynamical system, whereas each layer could be mapped to a discrete mode. The NN's hybrid system is then composed with the plant's hybrid system, thereby casting the problem as a hybrid system verification problem that can be solved by an optimized tool such as Flow* <ref type="bibr">[6]</ref>. Verisig was originally evaluated on Mountain Car <ref type="bibr">[34]</ref> (i.e., a reinforcement learning benchmark) as well as on a quadrotor case study in which the NN is used to approximate a model predictive controller <ref type="bibr">[41]</ref> that cannot be executed online. Although Verisig showed promising performance in these case studies, its scalability is limited by the fact that it integrates the sigmoid "dynamics" to obtain the reachable set for each neuron.</p><p>In this article, we develop a more scalable verification approach. In particular, we build on the technique used in Verisig but instead of integrating the sigmoid "dynamics," we adopt the Taylor Model (TM) framework used in hybrid system reachability <ref type="bibr">[6]</ref>. A TM of a function is a polynomial approximation, together with worst-case error bounds. TMs can effectively approximate the flow of various non-linear hybrid systems and scale well when used with interval analysis. To make use of TMs in NNs, we approximate the NN's activations with a Taylor series and obtain error bounds (using Taylor's Theorem) based on bounds on the inputs to each neuron. In this setting, the NN can be viewed as a simple hybrid system with TM resets and no continuous dynamics.</p><p>We compare the TM approach with Verisig both on the original case studies as well as on two additional benchmarks, an automatic cruise control (ACC) system <ref type="bibr">[29]</ref> and a more challenging autonomous racing verification case study presented in our second preliminary work <ref type="bibr">[21]</ref>. In all cases, the TM approach results in an order of magnitude improvement in scalability at no cost in precision (sometimes with much greater precision).</p><p>For further evaluation, we also implemented an alternative verification approach based on an MILP approximation of the sigmoid/tanh, as proposed by Dutta et al. <ref type="bibr">[12]</ref>. Specifically, the sigmoid is upper and lower bounded by piecewise linear functions, which allows us to transform the entire NN into an MILP that can be solved by efficient tools such as Gurobi <ref type="bibr">[36]</ref>. We observe that for small NNs with few inputs, the MILP formulation is comparable with TM Verisig in terms of speed and precision. However, as we increase (1) the NN size, (2) the input uncertainty, or (3) the number of inputs, the MILP approach is significantly slower and results in larger error due to the sigmoid approximation. These results highlight the benefit of the TM approach, both in terms of scalability and of approximation of reachable sets.</p><p>Finally, we provide a comparison between the TM approach and an alternative closed-loop verification tool, namely NNV <ref type="bibr">[47]</ref>. NNV works by approximating the NN's reachable set using star sets, which provide tight approximations while also allowing for efficient computation. For fair comparison, we tune both tools' parameters so as to achieve roughly the same runtimes on the ACC benchmark. For this setup, the TM method results in significantly smaller reachable sets, likely due to the fact that Verisig addresses the problem as a single hybrid system verification instance, whereas NNV performs the plant and NN verification sequentially, thereby potentially introducing additional error due to the composition.</p><p>In summary, the contributions of our preliminary work are (1) a verification approach for closedloop systems with NN controllers using a hybrid system formulation, (2) a theoretical analysis of the decidability of sigmoid-based NN reachability, and (3) evaluation of Verisig on three benchmarks, including a challenging autonomous racing case study. The additional contributions of this article are (1) a TM-based verification approach that builds on the original hybrid system technique; (2) a comparison with the original approach on the first three benchmarks, as well as on the ACC benchmark; and (3) an exhaustive comparison between Verisig and two alternative methods.</p><p>This article is organized as follows. Section 2 formulates the verification problems considered in this work. In Section 3, we analyze the decidability of the considered problem, whereas Sections 4 and 5 present the original and improved versions of Verisig, respectively. All verification benchmarks are described in Section 6, and the evaluation is shown in Section 7. A further comparison between the Verisig approaches and an MILP-based approach is given in Section 8, whereas the comparison with NNV is provided in Section 9. Finally, Sections 10 and 11 discuss related work and provide concluding remarks, respectively.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">PROBLEM FORMULATION</head><p>This section presents the verification problem addressed in this article. A high-level overview is shown in Figure <ref type="figure">1</ref>. We consider a closed-loop system that consists of (1) a physical plant with states x, (2) an environment where the plant operates, (3) measurements y produced as a function of the plant states within the environment, and (4) a NN controller h that maps the measurements to control inputs u. The rest of this section describes each of these components in more detail.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">Plant Model</head><p>We assume that the plant dynamics and measurements are described by a hybrid system. A hybrid system consists of a set of discrete modes and a finite number of continuous variables <ref type="bibr">[27]</ref>. Within each mode, the continuous states evolve according to differential equations with respect to time. Each mode may have a number of invariants that must hold true while the system is in that mode. Finally, transitions between modes may reset the continuous states and are controlled by guards, which are Boolean expressions of the continuous states. The formal definition is shown next.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Definition 1 (Hybrid System</head><p>). A hybrid system with inputs u and outputs y is a tuple H = (X , X 0 , F , E, I , G, R, &#1076;), where</p><p>Note that the relationship between the measurements y and the environment is implicitly captured in the observation model &#1076;. Without loss of generality, this definition assumes that the environment has no state; if this assumption is wrong, then the environment and plant states can be stacked together in a new combined state. Finally, note that, for a given initial set X 0 , the reachable set for a continuous state x at time t is set of all values that x (t ) can take when started from X 0 .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">NN Controller</head><p>As mentioned above, the NN controller h takes measurements y as input and outputs control actions u. For ease of presentation, we assume h is a fully connected NN, although other common NN classes, such as convolutional, residual and recurrent NNs, could also be accommodated by the presented framework. Thus, the controller h could be represented as the composition of its L layers:</p><p>where each layer h i consists of a linear map W i followed by a non-linear activation function a : R &#8594; R (the last layer h L is typically linear but could have an activation as well) <ref type="foot">1</ref> :</p><p>As mentioned in the Introduction, we consider smooth activations, e.g., the sigmoid, &#963; (x ) = 1/(1 + e -x ), and tanh, tanh(x ) = (e xe -x )/(e x + e -x ). Furthermore, we assume that the controller is already trained and all parameters (W 1 , b 1 , . . . ,W L , b L ) are known and fixed.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.3">Composed System</head><p>We assume that the NN controller is executed in a time-triggered fashion. <ref type="foot">2</ref>Verifying the Safety of Autonomous Systems with Neural Network Controllers 7:5</p><p>Definition 2 (Time-triggered Hybrid System). Consider a hybrid system with inputs u and outputs y as in Definition 1. The NN controller h is said to be time-triggered, with period T , if the inputs u are changed every T seconds, i.e.,</p><p>where t k = kT and k = 0, 1, 2, . . .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.4">Problem Statement</head><p>Since verifying safety properties of the closed-loop system presented in this section requires a special approach for the NN, we first investigate the problem of verifying input-output properties of the NN in isolation. Problem 1. Let h be a NN as described in Section 2.2. The NN verification problem, expressed as property &#981;, is to verify a property &#968; on the NN's outputs u given constraints &#958; on the inputs y:</p><p>Once Problem 1 has been addressed, we can also state the closed-loop reachability problem.</p><p>Problem 2. Let S = h || H P be the composition of a NN controller h (Section 2.2) and a plant P, modeled with a hybrid system H P (Section 2.1). Given a set of initial states X 0 of P, the problem, expressed as property &#981; S , is to verify a property &#968; S of the reachable states of P:</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">DECIDABILITY OF SIGMOID-BASED NN VERIFICATION</head><p>Before presenting our verification approach, we first investigate the decidability of the NN verification problem. Note that the verification of ReLU-based NNs is readily shown to be decidable (for linear constraints on the inputs and outputs), as the problem can be transformed into an MILP. However, sigmoid-based NNs are harder to reason about due to the non-linear and smooth nature of the sigmoid/tanh. In this section, we show that verification is decidable for NNs with one hidden layer, under mild assumptions on the parameters. In the general case, we show that if the inputs and outputs are constrained by a real arithmetic property (defined below), then the NN verification problem can be stated as a real arithmetic property with transcendental functions, which is decidable if Schanuel's conjecture is true <ref type="bibr">[51]</ref>. <ref type="foot">3</ref></p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">NNs with Multiple Hidden Layers</head><p>We begin our discussion with the general case of NNs with multiple hidden layers. As stated in Section 2, the NN verification problem has the following form:</p><p>where &#958; and &#968; are properties on the real numbers. Since verifying general properties of the reals is undecidable, we focus on a special class of properties, called real arithmetic properties. These are first-order logic formulas over (R, &lt;, +, -, &#8226;, 0, 1), i.e., the language where &lt; is the relation, +, -, and &#8226; are functions, and 0 and 1 are the constants <ref type="bibr">[45]</ref>; we denote such formulas by R-formulas. Example R-formulas are &#8704;x &#8704;y : xy &gt; 0, &#8707;x : x 2 -2 = 0, and &#8707;w : xw 2 + yw + z = 0. Intuitively, R-formulas are first-order logic statements over polynomial constraints with integer coefficients. Tarski was the first to provide a decision procedure for verifying real arithmetic properties <ref type="bibr">[45]</ref>.</p><p>A related class of properties contains real arithmetic properties with transcendental functions, denoted by R exp -formulas. This is the language (R, &lt;, +, -, &#8226;, exp, 0, 1), which also includes exponentiation. Although it is open whether verifying R exp -formulas is decidable, it is known that decidability is connected to Schanuel's conjecture <ref type="bibr">[51]</ref>. Schanuel's conjecture concerns the transcendence degree of certain field extensions of the rational numbers and, if true, would imply that verifying R exp -formulas is decidable <ref type="bibr">[51]</ref>.</p><p>We investigate the case where &#958; and &#968; are R-formulas. However, the exponentiation in the sigmoid means that &#981; is not a R-formula. The next proposition shows that &#981; can in fact be stated as a R exp -formula, which implies that NN verification is decidable if Schanuel's conjecture is true <ref type="bibr">[51]</ref>. Proposition 1. Let h : R p &#8594; R q be a sigmoid-based NN with L -1 hidden layers (with N neurons each), a linear last layer and rational parameters. The property &#981; (y, u) &#8801; (&#958; (y) &#8743; h(y) = u) &#8658; &#968; (u), where &#958; and &#968; are R-formulas, is an R exp -formula.</p><p>Proof. Since &#968; is an R-formula, it suffices to show that &#981; 0 (y, u) &#8801; &#958; (y) &#8743; h(y) = u can be expressed as an R exp -formula. Note that</p><p>where (w</p><p>jk /q i jk , with p i jk and q i jk &gt; 0 integers, and let d 0 = q 1  11 q 1 12 &#8226; &#8226; &#8226; q L-1 N p . To remove fractions from the exponents, we add extra variables z i and v j i and arrive at an equivalent property &#981; Z , which is an R exp -formula, since all denominators are R exp -formulas:</p><p>where r j i = w j i d 0 are vectors of integers; v j i = b j i are R-formulas, since b j i are rational. Corollary 1 <ref type="bibr">([51]</ref>). If Schanuel's conjecture holds, then verifying the property &#981; (y, u) &#8801; (&#958; (y) &#8743; h(y) = u) &#8658; &#968; (u) is decidable under the conditions stated in Proposition 1.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">NNs with a Single Hidden Layer</head><p>In the case of NNs with one hidden layer, one could show that verification is in fact decidable, assuming interval constraints on the inputs. In particular, the following theorem shows that the NN verification problem can be stated as an R-formula, thereby implying decidability. Theorem 1. Let h : R p &#8594; R q be a sigmoid-based NN with rational parameters and with one hidden layer (with N neurons), i.e., h(x</p><p>Verifying the Safety of Autonomous Systems with Neural Network Controllers 7:7 where y = [y 1 , . . . ,y p ] &#8712; R p , u = [u 1 , . . . ,u q ] &#8712; R q , &#968; is an R-formula, and</p><p>, the Cartesian product of p one-dimensional intervals. Then verifying &#981; (y, u) is decidable if, for all i &#8712; {1, . . . , N } and j &#8712; {1, . . . ,p}, e b i 1 , e &#945; j /d 0 , and e &#946; j /d 0 are rational, i.e., b i 1 = ln(b i r ), &#945; j = d 0 ln(&#945; j r ) and &#946; j = d 0 ln(&#946; j r ) for some rational numbers b i r , &#945; j r , and &#946; j r .</p><p>Proof. The proof technique borrows ideas from Reference <ref type="bibr">[27]</ref>. It suffices to show that &#981; (y, u) is an R-formula. Since &#968; (u) is an R-formula, we focus on the left-hand side of the implication, call it &#981; 0 (y, u):</p><p>where</p><p>To remove fractions from the exponentials, we change the limits of y. Consider the property</p><p>where</p><p>To remove exponentials from the constraints, we use their monotonicity property and transform &#981; Z (x, y) into an equivalent property &#981; e (x, y):</p><p>where</p><p>, and r i 1j is element j of r i 1 . To see that &#981; e (y, u) &#8801; &#981; Z (y, u), take any y &#8712; I Z y and note that exp{-r i 1j y j } = z r i 1j j , with z j = e -y j ; thus, z &#8712; I e x . The final step transforms the property &#981; e (y, u) into an equivalent property &#957; (y, u) to eliminate negative integers r i 1j in the exponents:</p><p>where</p><p>Thus, if e b j 1 , e &#945; i /d 0 , and e &#946; i /d 0 are rational for all i &#8712; {1, . . . ,p}, j &#8712; {1, . . . , N }, then one can show that &#957; (y, u) is an R-formula by multiplying all h i 1 constraints by their denominators. All denominators are positive, since y i and z i are constrained to be positive.</p><p>Note that the technique used to prove Theorem 1 cannot be applied to multiple hidden layers, since the NN becomes an R exp -formula in that case. Also, although the assumption on the NN's weights may appear contrived, it can be easily satisfied by conservatively increasing the interval constraints on the inputs by a small number.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">NN VERIFICATION USING HYBRID SYSTEM REACHABILITY</head><p>Section 3 analyzed the decidability of NN verification to provide intuition on the problem's difficulty. In this section, we present the verification approach used in Verisig, namely converting the NN into an equivalent hybrid system. Given this hybrid system, one can use existing hybrid system verification tools to verify the desired property by computing the hybrid system's reachable sets. The rest of this section presents the verification approach in detail, beginning with the dynamical-system interpretation of the sigmoid. <ref type="foot">4</ref></p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Sigmoids as Solutions to Differential Equations</head><p>The key idea that enables the transformation of a NN into a hybrid system is the fact that the sigmoid derivative can be expressed in terms of the sigmoid itself:<ref type="foot">foot_5</ref> </p><p>Equation ( <ref type="formula">6</ref>) has the flavor of a dynamical system, the main difference being that the partial derivative is not taken with respect to time. We could obtain a true dynamical system by introducing a proxy "time" variable as follows:</p><p>such that &#1076;(1, x ) = &#963; (x ) and, by the chain rule,</p><p>Thus, if x lies in a set X , then the image &#963; (X ) could be obtained by computing the reachable set of &#1076; at time t = 1, starting from an initial condition &#1076;(0, x ) = 0.5 (as can be verified from Equation ( <ref type="formula">7</ref>)) and following the dynamics in Equation <ref type="bibr">(8)</ref>. While the intermediate values of &#1076; are not important, continuously tracing the sigmoid "dynamics" allows us to iteratively construct the sigmoid's reachable set, i.e., the image &#1076;(1, X ). Section 5 presents a more direct method to obtain this reachable set.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">NNs as Hybrid Systems</head><p>Given the dynamical-system interpretation of the sigmoid presented in the previous subsection, we now show how to transform the entire NN into a hybrid system. For ease of presentation, we assume that all hidden layers have the same number of neurons, N , although the formulation can be easily adapted to the more general case. First note that each neuron h i j in hidden layer h i can be written as:</p><p>Verifying the Safety of Autonomous Systems with Neural Network Controllers 7:9</p><p>where (w j i ) is row j of W i and b j i is element j of b i . Given h i j , the corresponding proxy function &#1076; i j is defined as follows:</p><p>where, once again, &#1076; i j (1, x ) = h i j (x ). Also, by the chain rule,</p><p>Thus, each neuron h i j can be captured by a corresponding &#1076; i j with initial condition &#1076; i j (0, x ) = 0.5 and dynamics as shown in Equation <ref type="bibr">(10)</ref>.</p><p>To transform the entire NN, note that the linear mappings between layers in the NN can be thought of as discrete resets in a hybrid system. Thus, each NN layer corresponds to a mode in the hybrid system that computes the sigmoid dynamics in Equation ( <ref type="formula">10</ref>) until t = 1. At time t = 1, a reset occurs that resets all states according to the linear map, after which we continue processing the following layer/mode. Formally, we use N continuous states, x P 1 , . . . , x P N , to represent the proxy variables for each layer; when in mode i, each x P j , j &#8712; {1, . . . , N }, represents neuron h i j in the DNN. The linear resets are stored in states x J 1 , . . . , x J N . The x J i states are necessary, because the inputs to each neuron are functions of the x P i states reached in the previous mode. The full transformation is described in Proposition 2 below. Note that there is an additional mode q 0 , which is used to reset the x P i states to 0.5 and the x J i states to their corresponding values in q 1 . For simplicity, Proposition 2 focuses on the case of one NN output, stored in state u-the case of additional outputs can be handled by adding more u states. Note that denotes Hadamard (element-wise) product. Proposition 2. Let h : R p &#8594; R 1 be a sigmoid-based NN with L -1 hidden layers (with N neurons each) and a linear last layer with one output. The image under h of a given set I y is exactly the reachable set for u in mode q L of the following hybrid system: Proof. First, note that the reachable set of x P in mode q 1 at time t = 1 is exactly the image of I y under h 1 , the first hidden layer. This is true, because at t = 1, x P takes the value of the sigmoid function. Applying this argument inductively, the reachable set of x P in mode q L-1 at time t = 1 is exactly the image of</p><p>Finally, u is a linear function of x P with the same parameters as the last linear layer of h. Thus, the reachable set for u in mode q L is the image of</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3">Illustrative Example</head><p>To illustrate the transformation described in the previous subsection, we present an example in Figure <ref type="figure">2</ref>. In this example, a two-layer NN is transformed into a three-mode hybrid system. According to Proposition 2, the NN and the corresponding hybrid system are equivalent in the sense that the image of the set y 1 &#8712; [2, 3], y 2 &#8712; [1, 2] under the NN is the same as the reachable set for u in mode q 2 of the hybrid system. In particular, since all weights are positive, the output u is in the range [h(2, 1), h(3, 2)]-the same conclusion can be reached about the state u in the hybrid system.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.4">Composing the NN and the Plant</head><p>Once the NN is converted into a hybrid system, we can compose the NN's hybrid system with the plant's hybrid system. The composed hybrid system thus describes the entire closed-loop system. An example is shown in Figure <ref type="figure">3</ref>, where the NN from Figure <ref type="figure">2</ref> is composed with a toy plant hybrid system. We emphasize that the "time" in the sigmoid dynamics, t N N , is local to the NN, whereas t Plant captures the global physical time (note that t Plant does not progress inside the NN modes). <ref type="foot">6</ref>Note that the controller in the example in Figure <ref type="figure">3</ref> is time triggered but that guard can be changed depending on the condition for triggering the control in a given system.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.5">Hybrid System Verification Tools</head><p>Given the composed hybrid system, we can now use existing tools to address the hybrid system verification problem. Multiple tools have been developed in the literature, depending on the system class. SpaceEx <ref type="bibr">[16]</ref> was designed for linear hybrid systems and can scale up to a few thousand states. Although verification is undecidable for general non-linear hybrid systems <ref type="bibr">[3,</ref><ref type="bibr">27]</ref>, several approaches have been proposed that scale well in different scenarios. Flow* works by constructing flowpipe approximations using Taylor Models. Alternatively, dReach <ref type="bibr">[25]</ref> casts the verification problem as an SMT formula and provides &#948; -decidability guarantees. Several other approaches have been proposed as well, e.g., CORA <ref type="bibr">[2]</ref> and C2E2 <ref type="bibr">[10]</ref>, that rely on different computationally convenient approximations of the reachable sets such as zonotopes or simulation-based approximations.</p><p>In this article, we use Flow* due to its scalability on the considered case studies. Furthermore, the TM framework used in Flow* also suggests a natural way to extend the approach presented in this section. In particular, the next section describes a modified method that avoids the sigmoid integration and provides an order of magnitude improvement in scalability at no cost in precision.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">TAYLOR MODEL APPROXIMATION OF THE SIGMOID</head><p>The previous section presented the hybrid-system-based approach used in Verisig. In this section, we build on these ideas and develop a more scalable technique that provides an order of magnitude improvement in scalability. We begin with a brief explanation of the TM framework adopted in Flow*, which serves us a starting point for our improved NN verification approach. To define a TM, we first introduce the concept of polynomial approximation. Let f : D &#8594; R be a function over n variables, with D &#8712; I n , and suppose f is j times continuously differentiable. A polynomial p of degree j is said to approximate f at a point x &#8712; D, written f (x ) &#8801; j p(x ), if all 0 &lt; m &#8804; j partial derivatives of f and p coincide at x.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Hybrid System Reachability Using TMs</head><p>The TM of a function f is defined as follows. Let f : D &#8594; R be a function over n variables, where D &#8712; I n . A Taylor Model of order j &gt; 0 for f over D is a pair (p, I ) of a polynomial p of degree at most j and a remainder interval I such that:</p><p>TMs have shown great promise in hybrid system reachability due to the fact that they can approximate the reachable sets of various non-linear systems and scale well when used with interval analysis <ref type="bibr">[5]</ref>. Specifically, given a set of differential equations and corresponding initial conditions, one can use Picard iteration to obtain a polynomial approximation with error bounds, i.e., a TM approximation, of the reachable set. Once a TM is available, one can use domain contraction <ref type="bibr">[5]</ref> to check whether the reachable set intersects a given unsafe set, i.e., whether the safety property </p><p>to be verified is true or false. Finally, multiple techniques have also been proposed to keep the TM remainder small, such as preconditioning and suppression of the wrapping effect <ref type="bibr">[31]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">Neural Networks as Taylor Models</head><p>We begin with a general outline of the proposed TM-based approach for NN reachability, followed by the specific treatment of the sigmoid and tanh activations. The main idea of the new approach is to approximate every neuron with a TM, thereby avoiding the sigmoid integration used in the original method. This way, we not only drastically reduce the computation, but we also obtain better approximations, since we can analytically derive tight remainder bounds.</p><p>To get a TM approximation of each neuron, we use Taylor's Theorem, which allows us to construct a polynomial approximation with bounded error over a given interval. For completeness, we first state Taylor's Theorem (with the Lagrange form of the remainder) to show how it can be used to derive a TM for a given function.</p><p>Theorem 2 (Taylor's Theorem.). Let k &#8805; 1 be an integer, let I &#8712; I and let f : R &#8594; R be k + 1 times differentiable at the point a &#8712; I . Then for any</p><p>where (for</p><p>where q and Q satisfy q &#8804; f (k+1) (x ) &#8804; Q for all x &#8805; a. Similar bounds can be derived for the case when x &lt; a.</p><p>Taylor's Theorem can be used to derive a TM (with the bounds on R k as the error bounds) for any function with bounded inputs and derivatives. Thus, to obtain a TM for each neuron n of the NN, one needs to find interval bounds I on the inputs to n, compute a Taylor series approximation of the sigmoid around the center of I , and bound the sigmoid derivative on I .</p><p>Using this intuition, Algorithm 1 illustrates how to transform the entire NN into a composition of TMs. The input to the algorithm is a TM for the measurements, call it T M y . To obtain T M y , we use the fact that the plant itself is part of the reachability problem, i.e., TMs are available for the reachable set of the measurements y. From T M y and the initial condition, one first performs the linear part of each layer (Line 3). Given the resulting TM, can then obtain interval bounds using interval analysis (Line 4), thereby obtaining interval bounds on the inputs to the sigmoid that are used in Taylor's Theorem (Line 5). Taylor's Theorem provides a TM for each neuron's activation, which is composed with the linear TM to produce the final TM for that layer (Line 6). This process repeats as TMs are propagated through the NN layers. Note that the interval analysis in Line 4 is only used to obtain bounds on the TM input range so that we can bound the sigmoid Taylor series approximation error; however, each layer is still represented by a TM that is propagated using standard TM reachability techniques <ref type="bibr">[5]</ref>.</p><p>It is important to emphasize that Algorithm 1 not only allows us to avoid the sigmoid integration involved in the original version of Verisig, but it also enables us to analytically control the approximation error by choosing a sufficiently high TM order that achieves the desired error. The NN can now be seen as a simple hybrid system, with no dynamics and with TM resets between modes. The composition with the plant is performed in the same manner as before, as illustrated in Figure <ref type="figure">3</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.3">TMs for Sigmoid and Tanh</head><p>Since sigmoid and tanh are infinitely differentiable, Taylor series are easily derived for these functions. Furthermore, as shown in prior work <ref type="bibr">[32]</ref>, the sigmoid (and tanh) derivative coefficients can be mapped to Eulerian numbers, which can be precomputed offline; thus, high derivatives can be computed quickly using table look-ups. Derivative bounds over a given interval I can be obtained by finding all local optima <ref type="foot">7</ref> and checking where the endpoints of I lie. Two illustrative examples are shown next.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.4">TM Examples</head><p>This subsection provides two examples to illustrate the technical aspects of Algorithm 1.</p><p>Example 1 (Obtaining Interval Bounds for a Given TM). This example illustrates how one could use interval analysis to obtain interval bounds for the inputs to the NN. Consider a system with two continuous states, x 1 and x 2 , and initial condition x 1 &#8712; [0, 0.1], x 2 &#8712; [-0.1, 0.5]. Suppose the system has access to one measurement y, and suppose a second-order TM for y is available:</p><p>Using interval analysis, one obtains the following interval bounds for y: Example 2 (Using Taylor's Theorem to Obtain a TM for Each Neuron). Consider the above example again, and suppose that the measurement y is sent as input to a single-neuron sigmoid layer: h 1 (y) = &#963; (0.2y + 0.1). To compute a TM for h 1 , we use interval analysis in a similar way and obtain</p><p>1 , we obtain a second-order Taylor series approximation of the sigmoid around the center of I T M 1 , c = 0.1854:</p><p>where &#963; (c) = 0.2479, &#963; (c) = -0.0229, q = -0.1208, Q = -0.1157, q(0.0914</p><p>!), and 0.0914 is the largest deviation from c to any point in I T M 1 . Thus, the final TM for h 1 is T M &#963; 1 (0.2T M y + 0.1).  The quadrotor follows its plan to reach the goal without colliding into obstacles.</p><p>Fig. <ref type="figure">6</ref>. Autonomous racing car navigation scenario.</p><p>There are three different regions depending on how many walls can be reached using LiDAR.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.5">Implementation</head><p>We implemented the TM approach on top of Flow*. Since Flow* provides an interface for dynamical system reachability using TMs, it is a logical choice as a starting point for our tool. The source code is available at github.com/verisig.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">EVALUATION BENCHMARKS</head><p>We evaluate our approaches on four different benchmarks. These benchmarks were chosen to expose different challenges in terms of scalability and approximation. In particular, these are systems with the following diverse properties: (1) a hybrid plant model with a continuous-valued controller, (2) a continuous plant model with a discrete-valued controller, (3) a continuous plant model with a continuous-valued controller, and (4) a continuous plant model with a hybrid high-dimensional observation model and a continuous-valued end-to-end controller. These benchmarks also illustrate different ways in a which a NN could be trained: In benchmarks 1 and 4, the NN was trained using reinforcement learning; in benchmark 2, the NN was trained using a safe learning algorithm based on model predictive control; in benchmark 3, the NN was trained using supervised learning. The remainder of this section describes each benchmark in more detail.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.1">Mountain Car</head><p>Mountain Car (MC) is a reinforcement learning benchmark in which the task is to train a controller to drive an underpowered car up a hill <ref type="bibr">[34]</ref>, as shown in Figure <ref type="figure">4</ref>. The car does not have enough power to accelerate up the hill, so it needs to drive up the left hill first and gather momentum. The car has two states, position and velocity, that evolve in discrete time as follows:</p><p>where u k is the control and p k and v k are the car's position and velocity, respectively, with p 0 chosen uniformly at random from [-0.6, -0.4] and v 0 = 0. The car states are constrained as follows: During training, a reward of -0.1u 2 k is received after each step, which forces a control policy that applies as little thrust as possible. A reward of 100 is received upon reaching the goal. In our Verifying the Safety of Autonomous Systems with Neural Network Controllers 7:15 preliminary work <ref type="bibr">[22]</ref>, we used deep deterministic policy gradient (DDPG) reinforcement learning <ref type="bibr">[28]</ref> to train a NN controller. The controller has two hidden layers with sigmoid activations with 16 neurons per layer and a tanh output layer with one neuron. The controller takes p k and v k as input and produces u k . The machine learning task is considered solved if an average reward above 90 is obtained over 100 random runs. We can now strengthen the definition of a "solved" task and verify that the reward is above 90 for any initial condition, i.e., p 0 &#8712; [-0.6, -0.4].</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.2">Quadrotor with a NN Controller</head><p>In the second benchmark a NN is trained to approximate a model predictive controller (MPC) with safety guarantees <ref type="bibr">[41]</ref>. In particular, one can train the NN to follow a piecewise-linear plan and bound the deviation from the plan by simulating against a worst-case planner from a given point <ref type="bibr">[41]</ref>. To guarantee a bounded deviation over sets of initial conditions, however, one would need to formally verify such a bound, which is the problem considered in this benchmark.</p><p>We consider an unmanned quadrotor with a NN controller that is following a piecewise-linear plan avoiding obstacles, as illustrated in Figure <ref type="figure">5</ref>. The quadrotor dynamics are modeled as a sixdimensional control-affine system, whereas the planner dynamics are piecewise linear, as follows:</p><p>where p q x , p q y , p As described in prior work <ref type="bibr">[41]</ref>, the optimal controller for the model in Equation ( <ref type="formula">11</ref>) is a "bangbang" controller, i.e., it is effectively a classifier mapping plant states to a finite set of control actions. To train the NN controller, we follow the approach described in prior work, i.e., we sample multiple points from the state space over a bounded horizon and train a sequence of controllers, one for each control sampling step. When two consecutive NNs have similar error, we interrupt training and pick the last one as the final controller. We trained a NN with two hidden layers with 20 neurons each (with tanh activations) and a linear last layer with eight neurons (i.e., the number of possible control actions). The property to be verified is that the quadrotor does not deviate by more than 0.32 m from the planner, for initial conditions (p r x (0), p r y (0)) &#8712; [-0.05, 0.05] &#215; [-0.05, 0.05] (the other states are initialized at 0), where we define the vector of relative states as r := [p r</p><p>x , p r y , p r z , v r x , v r y , v r z ] = qp.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.3">Adaptive Cruise Control</head><p>In the ACC benchmark <ref type="bibr">[29]</ref>, there are two vehicles, the ego and the lead vehicle, going in a straight line. The control task is to make sure the ego vehicle follows the lead vehicle at a safe distance.</p><p>The two cars' dynamics are the same, modulo the control inputs, and are given as follows:</p><p>where x c is position, v c is velocity, &#947; c is acceleration, a c is the control thrust applied to the car, u = 0.0001 is the friction control, and the subscript c &#8712; {e&#1076;o, lead}. The lead car has an MPC as described in prior work <ref type="bibr">[29]</ref>, with a target velocity V set = 30 m/s. The ego vehicle has a NN controller that takes five inputs: V set , T &#1076;ap = 1.4s, v e&#1076;o , x leadx e&#1076;o , v leadv e&#1076;o . The NN was trained using supervised learning <ref type="bibr">[29]</ref> and has three hidden layers with 20 neurons per layer (with tanh activations) and a linear last layer with one neuron. In the considered scenario, the lead car applies a sudden brake (with a lead = -2), and the problem is to verify that a safety distance is maintained over the next 5 s. Specifically, the safety property to be verified is <ref type="bibr">10,</ref><ref type="bibr">11]</ref>, v e&#1076;o (0) &#8712; [30, 30.05], &#947; e&#1076;o (0) = 0.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.4">Autonomous Racing Car</head><p>The last benchmark is a more challenging case study in which an autonomous car must navigate a structured environment using LiDAR measurements. Specifically, we consider the scenario illustrated in Figure <ref type="figure">6</ref>, in which the car starts in the middle of a hallway and must safely make a right turn. This case study is motivated by the F1/10 autonomous racing competition <ref type="bibr">[1]</ref>. A more detailed description of this case study is provided in our preliminary work <ref type="bibr">[21]</ref>.</p><p>The car is modeled with a kinematic bicycle model <ref type="bibr">[38,</ref><ref type="bibr">39]</ref>, which is a standard model for cars with front steering. The car dynamics are given as follows:</p><p>where v is the car's linear velocity, &#952; is the car's orientation, &#946; is the car's slip angle, and x and y are the car's position; u is the throttle input, and &#948; is the heading input; c a is an acceleration constant, c m is a car motor constant, c h is a hysteresis constant, and l f and l r are the distances from the car's center of mass to the front and rear, respectively. Since tan -1 is not supported by Flow*, we assume that &#946; = 0; this is not a limiting assumption in the considered case study as the slip angle is typically fairly small at low speeds. The parameter values were identified as follows:</p><p>The throttle is constant at u = 16 (resulting in a top speed of roughly 2.4 m/s), i.e., the controller only controls heading. The car has access to 21 laser imaging, detection and ranging (LiDAR) rays, as illustrated in Figure <ref type="figure">6</ref>. Each ray can be modeled as a function of the car's position and orientation within the hallway. As shown in the figure, there are three regions the car can be in, depending on how many walls can be reached by LiDAR. We present the model for Region 2 only, as the other regions are special cases. We consider a LiDAR scan with a 230 &#8226; field of view and a 5-m range. Let &#945; 1 , . . . , &#945; 21 denote the relative angles for each ray with respect to the car's heading, i.e., &#945; 1 = -115, &#945; 2 = -103.5, . . . , &#945; 21 = 115. One can determine which wall each LiDAR ray hits by Verifying the Safety of Autonomous Systems with Neural Network Controllers 7:17 comparing the &#945; i for that ray with the relative angles to the two corners of that turn, &#952; l and &#952; r in Figure <ref type="figure">6</ref>. The model for each ray y i k , i &#8712; {1, . . . , 21} is given as follows:</p><p>where k is the sampling step (the sampling rate is assumed to be 10 Hz) and</p><p>k are distances to the four walls, as illustrated in Figure <ref type="figure">6</ref>, and can be derived from the car's position (x, y). <ref type="foot">8</ref> Note that this observation model is quite challenging, both due to its non-linear and hybrid nature. In particular, if the reachable set for the car's state is large, then a given ray might reach different walls, which would mean that different paths through the hybrid system are taken-in this case, all paths need to be verified separately, thereby introducing a combinatorial aspect to the verification task.</p><p>As described in our preliminary work <ref type="bibr">[21]</ref>, we trained multiple controllers using both DDPG and a twin delayed deep deterministic policy gradient (TD3) algorithm <ref type="bibr">[17]</ref>. For comparison, we only use one of the controllers, namely a NN with two hidden layers (with tanh activations) with 64 neurons per layer and a single-neuron output layer with a tanh activation. The safety property to be verified is that the car does not get within 0.3 m of either wall for 7s (which is enough to make the right turn and get roughly to the middle of the next hallway). The initial condition is x (0) &#8712; [-0.1, 0.1], i.e., a 0.2-m interval in the middle of the first hallway.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">VERIFICATION RESULTS</head><p>This section presents the comparison between the hybrid-system based version of Verisig and the improved, TM-based, version. The next section provides a separate comparison between both versions of Verisig and an MILP approach to verification.</p><p>The comparison in this section is purely based on the time it takes to verify the safety properties in the different benchmarks. The next section will also explore the quality of approximation of reachable sets obtained using the different algorithms. A common theme across all benchmarks is that the initial conditions need to be subdivided into smaller sets to maintain a small approximation error. If the initial condition is too large, then the uncertainty can magnify over time, thus making it impossible to verify the safety property (even if it is true). Thus, for each benchmark, we (manually) partition the initial set and present the verification times for each instance. Exploring an automated refinement procedure of the initial set is left for future work.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.1">Mountain Car</head><p>As noted in Section 6, the initial condition for MC is p 0 &#8712; [-0.6, -0.4]. During the verification, we found a counter-example at p 0 = -0.6, i.e., the car goes up the hill with a reward of less than 90. That is why, we only verify the property over the initial set p 0 &#8712; [-0.59, -0.4], which is partitioned as follows: [-0. Notably, when started from the right end of the initial set, the car hits the left boundary of the environment, thereby causing a branch in the hybrid model such that each branch needs to be verified separately. The verification times for all the instances are presented in Figure <ref type="figure">7(a)</ref>. The TM version of Verisig is roughly an order of magnitude faster for all instances-most instances take about half a minute to verify with the TM approach and more than 10 minutes with the original approach. The last two instances took considerably longer to verify due to the branch in the hybrid system.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.2">Quadrotor</head><p>The initial condition for this benchmark, (p r x (0), p r y (0)) &#8712; [-0.05, 0.05] &#215; [-0.05, 0.05], was subdivided into 16 equal-size subintervals, by offsets of 0.025 along each axis. Note that the "bang-bang" nature of the controller means that there is an exponentially increasing number of paths (in the number of control sampling steps) that need to be verified. This is true, because, depending on the uncertainty, at each step the controller might take a different discrete action. Thus, this benchmark is challenging not only due to the presence of the NN, but also due to the hybrid plant model.</p><p>The verification times are presented in Figure <ref type="figure">7</ref>(b). Once again, the TM approach is significantly faster for all instances. The differences are less pronounced in this case, since verifying the plant dynamics, which is the same for both approaches, takes a bigger fraction of the entire computation.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.3">Adaptive Cruise Control</head><p>The initial set for ACC is subdivided into 20 instances, by offsets of 1 along the x lead axis. The verification times are shown in Figure <ref type="figure">7(c</ref>). Similarly to the MC case study, the TM approach is an order of magnitude faster, with verification times of roughly 25 minutes, as opposed to over 9 hours for the original approach. Note that this model is not hybrid, so the verification times do not vary greatly across instances for each method.</p><p>The higher dimensionality of the ACC benchmark's initial set also allows us to explore another issue related to scalability, namely how much uncertainty can be tolerated along different dimensions of the state-space. Answering this question is important, as it would suggest better ways to partition the initial set than the uniform partitioning used in this work. In particular, we compare how much initial uncertainty can be tolerated along the lead car position, p lead , dimension vs. the ego car velocity, v e&#1076;o , dimension. Figure <ref type="figure">8</ref> provides the reachable sets, as projected to the v leadv e&#1076;o plain, computed by TM Verisig for different combinations of initial conditions for these two variables (all other states have the same initial conditions as before). As can be seen in the figure, while the true reachable sets do not vary greatly across setups, the reachable sets computed by Verisig are much more affected by velocity uncertainty, with Figure <ref type="figure">8</ref>(d) having the largest degree of overapproximation error. This suggests that higher-order terms (e.g., velocity) have a much bigger effect on the accuracy of reachable sets than lower-order terms (e.g., position). </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.4">Autonomous Racing Car</head><p>The initial condition for the car, x (0) &#8712; [-0.1, 0.1], is subdivided into 40 regions, by offsets of 0.005. We emphasize again that this case study is not only challenging due to the larger NNs but also due to the hybrid LiDAR model. Please consult our preliminary work <ref type="bibr">[21]</ref> for an exhaustive discussion of the various challenges presented by this case study.</p><p>The comparison is presented in Figure <ref type="figure">7</ref>(d). We observe the same trend of the TM approach being significantly faster, with verification times less than an hour, as compared with some instances taking more than a day with the original approach. It is also worth noting that different instances can take drastically different times to verify, which is due to the LiDAR model challenges.</p><p>In summary, the TM version of Verisig is able to verify the same properties as the original version, but with an order of magnitude improvement in scalability. We observe similar trends across different plant models and NN architectures. The next section demonstrates that TM Verisig also results in better approximations than the original version, in addition to being faster.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8">COMPARISON WITH AN MILP APPROACH</head><p>For better evaluation, this section provides a comparison with an alternative verification approach for sigmoid/tanh NNs, namely an MILP-based approach. The MILP approach was suggested in prior work <ref type="bibr">[12]</ref> as a possible way to verify sigmoid/tanh NNs, similar to Sherlock, i.e., the MILP approach used for ReLUs <ref type="bibr">[12]</ref>. A comparison with another recently released tool for closed-loop verification, NNV <ref type="bibr">[47]</ref>, is provided in Section 9.</p><p>The main idea of the approach is to transform the NN into an MILP. Since sigmoids are not linear, they could be bounded from above and below by piece-wise linear functions. Once such functions are obtained, one could formulate the MILP by adding a binary variable for each linear piece of each piece-wise linear function and use the big M method, as described in prior work <ref type="bibr">[12]</ref>. Finally, one could use an optimized solver such as Gurobi <ref type="bibr">[36]</ref> to verify safety about the NN's outputs given (linear) bounds on the inputs. Note that this approach can only be used on the NN in isolation, so we only provide a comparison in terms of NNs, ignoring the plant. To verify the closed-loop system, one could combine the output of Gurobi with polynomial regression to obtain a TM for the NN, similar to the way Sherlock was extended to closed-loop systems <ref type="bibr">[11]</ref>.</p><p>The main consideration when implementing the MILP approach is how many linear pieces to use to approximate the sigmoid. Adding more pieces reduces the approximation error but it significantly complicates the MILP (since the solver may need to search over all combinations of binary variables). In this comparison, we use roughly 100 pieces, which results in an approximation error of around 10 -4 per sigmoid. As the rest of this section indicates, however, while this approximation Fig. <ref type="figure">9</ref>. Comparison in terms of verification times between the two versions of Verisig and the MILP-based approach. In 9(a)-(d), the number of neurons is fixed and number of layers varies from two to 10. In (e), the number of layers is fixed to two, and the number of neurons varies from 100 to 1,000.</p><p>is good enough for small uncertainties and small NNs, it becomes insufficient for larger NNs and larger initial conditions, as compared with Verisig.</p><p>For fair comparison, we compare the different approaches in terms of both verification time and approximation error. We also compare them on two different benchmarks, MC and ACC. As discussed at the end of the section, the MILP approach cannot be directly applied to the autonomous racing car, which is another limitation of approaches of this type.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.1">Comparison on MC</head><p>In the first comparison, we train NNs of increasing size on the MC benchmark and compare the verification times of the different approaches for a fixed initial set, namely p 0 &#8712; [-0.5, -0.48]. In particular, we train NNs with 16, 32, 64, and 128 neurons per layer, respectively, and vary the number of layers from 2 to 10. Furthermore, we train networks of increasing width, where we fix the number of layers to two but vary the number of neurons per layer from 100 to 1,000.</p><p>The comparison is shown in Figure <ref type="figure">9</ref>. As can be seen in the figure, the MILP approach achieves comparable times with TM Verisig for small NNs. However, as the NN size increases, both in terms of number of neurons and depth, the MILP approach suffers from the exponential complexity of the problem and is eventually even slower than the original version of Verisig. In contrast, both versions of Verisig scale linearly with the number of layers, since the same computation is performed for each layer/mode. Finally, the runtimes for all approaches increase super-linearly as the NN width is increased, as shown in Figure <ref type="figure">9</ref>(e). While, the MILP approach can sometimes handle even the biggest NNs that were tested, TM Verisig is in general faster and more predictable. It is worth noting that, although not shown in the graphs, the memory requirements increase substantially as well, as NNs with 1,000 neurons per layer have more than one million parameters that need to be encoded. We also compare verification times as the initial uncertainty is increased. Specifically, we vary the initial uncertainty as follows: <ref type="figure">10</ref>(a) and (b) shows the verification times of the three approaches for two of the NNs with two layers from Figure <ref type="figure">9</ref>, one with 16 neurons per layer and one with 128 neurons per layer. Similarly to the first comparison, the MILP approach is comparable with TM Verisig on the small NN but is greatly affected by the uncertainty on the big one and is eventually slower than the original version of Verisig as well. As before, the Verisig approaches are not greatly affected by the initial uncertainty.</p><p>Finally, we also consider the approximation error incurred by the different methods. Performing a fair comparison is not easy, since the MILP approach only outputs bounds for the NN outputs, whereas the Verisig approaches output TMs. The metrics we use are as follows: (1) for the Verisig approaches we use the TM remainder in the NN's output, and (2) for the MILP approach, we report the approximation error as compared with ground truth (estimated numerically by sampling the two-dimensional NN input space). Using these metrics, the comparison is shown in Figure <ref type="figure">10(c</ref>) and (d). As can be seen in these figures, the MILP error is comparable with the TM Verisig remainder for the small NN, but is significantly larger than either Verisig version for the larger NN. Note also that the TM version of Verisig results in a much smaller remainder than the original version.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.2">Comparison on ACC</head><p>For further comparison, we also consider the ACC case study, where the NN inputs are not just states but rather functions of states. This benchmark is more challenging for the MILP approach, since interval ranges for all inputs need to be obtained, thereby losing the connection between the inputs (which is retained in a TM). We present the same comparison as in Figure <ref type="figure">10</ref>, the main difference being that we use only one NN for comparison, namely the NN that was used in Section 7. We vary the initial condition as follows:</p><p>The comparison is presented in Figure <ref type="figure">11</ref>. Similarly to Figure <ref type="figure">10</ref>, the MILP approach quickly becomes infeasible and takes more than an hour for most instances (some were terminated after 24 hours). Furthermore, the approximation error of the MILP approach is an order of magnitude larger than the TM approach (for the instances that finished execution). As in the other comparisons, the Verisig runtimes are not significantly affected by the initial uncertainty. Furthermore, the TM approach once again results in a significantly smaller remainder than the original version.</p><p>In summary, we observe similar trends in both benchmarks: The MILP approach is greatly affected by the initial uncertainty, both in terms of runtime and approximation error. In contrast, the Verisig approaches have similar runtimes regardless of the initial condition. While the Verisig Fig. <ref type="figure">11</ref>. Comparison on the ACC benchmark in terms of verification times and approximation error between the two versions of Verisig and the MILP-based approach. In each figure, the initial set uncertainty is gradually increased with the instance index. The MILP instances were terminated after 24 hours. approaches also result in higher remainders as the uncertainty increases, TM Verisig consistently produces much lower remainders than the other techniques.</p><p>Finally, it is worth mentioning that the MILP approach cannot be directly applied to benchmarks with observations such as the autonomous racing one. This is due to the fact that, as the number of inputs to the NN increases, simply using interval ranges for each input (without considering the relationship between inputs) will result in a vast overapproximation of the output set. This is another benefit of the TM method, as it maintains these relationships at all times.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="9">COMPARISON WITH NNV</head><p>For further evaluation of the TM approach, this section provides a comparison with a recently released closed-loop verification tool, namely NNV <ref type="bibr">[47]</ref>. NNV computes NN reachable sets using a star set approach <ref type="bibr">[46]</ref>. The star set allows one to compute exact reachable sets for NNs with ReLU activations; for NNs with smooth activations, the sets provide tighter approximations than other convex sets such as zonotopes, as discussed in prior work <ref type="bibr">[46]</ref>. Using star sets is also appealing as they can be computed in parallel, thereby enabling a great speed-up on multi-core machines. Finally, NNV uses CORA <ref type="bibr">[2]</ref> to compute the plant reachable sets.</p><p>Since NNV only supports continuous (non-hybrid) plant models, we perform a comparison on the ACC benchmark. Note that both tools have parameters, e.g., the flowpipe step size in Flow* and CORA, that can be tuned to improve the approximation performance at the expense of runtime. For fair comparison, we tune both tools to have similar runtimes and compare the resulting reachable sets. Specifically, we use a 0.005-s step size in Flow* and a 0.001-s step size in CORA.</p><p>Recall from Section 6 that the initial set for the ACC benchmark is x lead (0) &#8712; [90, 110], v lead (0) = [32, 32.05], &#947; lead (0) = 0, x e&#1076;o &#8712; <ref type="bibr">[10,</ref><ref type="bibr">11]</ref>, v e&#1076;o (0) &#8712; [30, 30.05], &#947; e&#1076;o (0) = 0. As before, we split this initial set into subsets along the x lead axis. We use the notation S [a,b] to denote the initial subset where x lead (0) &#8712; [a, b], and the other states have the same initial conditions as before.</p><p>Figure <ref type="figure">12</ref> illustrates the comparison between the two tools. We first compare the reachable sets computed by the two tools for the initial set S <ref type="bibr">[90,</ref><ref type="bibr">91]</ref> . Figure <ref type="figure">12</ref>(a) provides a number of simulated trajectories, projected to the plane of the two cars' velocities, v lead and v e&#1076;o . As can be seen, the true reachable sets (progressing from right to left) initially contract but eventually expand again; this behavior in general makes it difficult for reachability tools to compute tight approximations. This is clearly shown in Figure <ref type="figure">12</ref>(b), which shows the reachable sets computed by each tool. Figure <ref type="figure">12</ref>(b) shows that both tools eventually result in large overapproximation errors, due to the complexity of the verification task. Yet, the reachable sets computed by Verisig are significantly tighter, with the NNV reachable sets being more than three times larger at the end of the scenario (left side of Figure <ref type="figure">12(b)</ref>). To illustrate the effect of larger initial uncertainty, Figure <ref type="figure">12</ref>(c) shows reachable sets for the initial set S <ref type="bibr">[90,</ref><ref type="bibr">92]</ref> . Again, Verisig produces tighter reachable sets (with NNV reachable sets being two times larger at the end of the scenario as shown on the left side of the figure), although both tools have an even bigger approximation error. Finally, Figure <ref type="figure">12(d)</ref> shows the runtimes for both tools over all initial instances used in Section 7, i.e., S [90,91] , . . . , S <ref type="bibr">[109,</ref><ref type="bibr">110]</ref> . The figure shows that Verisig is between 50% and 100% slower per instance (for the tool parameters described above). However, it is important to emphasize we were not able to obtain significantly tighter reachable sets for NNV for any other parameter setting that we tried.</p><p>In summary, despite the challenging nature of the ACC benchmark, Verisig results in significantly tighter reachable sets (with NNV reachable sets being two-to-three times larger at the end of the scenario) at a small cost in verification time. The difference in approximation error is likely due to the fact that Verisig treats the system as a single hybrid system and propagates reachable sets in a symbolic fashion through TMs. In contrast, NNV switches between NN reachable sets, represented as star sets, and plant reachable sets, represented as polytopes in CORA, which introduces additional error.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="10">RELATED WORK</head><p>Multiple techniques have been proposed to evaluate and improve a NN's robustness, both during training and post training <ref type="bibr">[52]</ref>. During training, researchers have developed adversarial training <ref type="bibr">[30,</ref><ref type="bibr">33]</ref> and robust training <ref type="bibr">[7,</ref><ref type="bibr">19]</ref> methods to alleviate the NN's vulnerability to adversarial examples. Once a NN is trained, approaches exist to test the NN's sensitivity to input perturbations <ref type="bibr">[37]</ref>, generate new adversarial examples <ref type="bibr">[26]</ref>, or perform physical attacks <ref type="bibr">[14]</ref>. Finally, several formal verification and robustness works have been recently proposed to verify safety properties of a trained NN's outputs given constraints on the inputs <ref type="bibr">[12,</ref><ref type="bibr">13,</ref><ref type="bibr">15,</ref><ref type="bibr">18,</ref><ref type="bibr">24,</ref><ref type="bibr">49,</ref><ref type="bibr">50,</ref><ref type="bibr">53]</ref>. These techniques exploit the specific form of NNs' activation functions, e.g., ReLUs, by adapting existing SMT <ref type="bibr">[13,</ref><ref type="bibr">24]</ref> and MILP <ref type="bibr">[12]</ref> solvers or by otherwise overapproximating the NN's output set <ref type="bibr">[18,</ref><ref type="bibr">53]</ref>.</p><p>A few techniques have also been developed to analyze properties of closed-loop systems with NN components. Dreossi et al. <ref type="bibr">[9]</ref> and Tuncali et al. <ref type="bibr">[48]</ref> develop falsification approaches by adapting existing falsifiers to the case of NN components. Verisig <ref type="bibr">[22]</ref> can verify safety properties of closed-loop systems with sigmoid-and tanh-based NN controllers by transforming the NN into an equivalent hybrid system. Sun et al. <ref type="bibr">[42]</ref> propose an SMT-based approach to verify properties of linear systems with ReLU-based NN controllers. Dutta et al. <ref type="bibr">[11]</ref> extend their MILP-based tool <ref type="bibr">[12]</ref> to the closed-loop case by approximating the NN using polynomial regression. Furthermore, NNV <ref type="bibr">[47]</ref> computes NN reachable sets using a star set formulation that is exact for ReLU activations and allows for parallelization. Finally, ReachNN <ref type="bibr">[20]</ref> is similar to the work by Dutta et al. <ref type="bibr">[11]</ref> as it approximates the NN locally with a polynomial; however, ReachNN uses Bernstein polynomials, which allows it to achieve arbitrary approximation precision. Although ReachNN is similar to Verisig, since it is based on TMs, Verisig provides an analytic approximation of the sigmoid/tanh, whereas ReachNN (being agnostic of the specific activation function used) relies on sampling methods that may require large amounts of sampling to achieve the desired precision.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="11">CONCLUSION</head><p>This article presented Verisig, a method to verify safety properties of autonomous systems with NN controllers. Verisig transforms the NN into an equivalent hybrid system and casts the problem as a hybrid system verification problem. We improved the approach by approximating each neuron with a TM such that no integration of the sigmoid "dynamics" is necessary. We analyzed the decidability of NN verification and provided conditions under which the problem is decidable. Finally, we presented an exhaustive evaluation over four benchmarks.</p><p>The novelty of the area presents multiples avenues for future work. First, it is important to develop verification approaches for image-based systems, as this is where NNs greatly outperform other learning methods. Furthermore, scalability improvements are necessary, especially to handle convolutional NNs, which are very effective for analyzing images. Finally, it would be interesting to identify verification problems in other safety-critical domains, e.g., cyber security applications.</p><p>Finally, it would be interesting to explore hybrid-system-based techniques for verifying ReLUbased NNs, since the ReLU is arguably the most common activation function in use today. One approach would be to approximate the ReLU with a smooth function (e.g., the Swish function <ref type="bibr">[40]</ref>) and then apply the TM method described in this article.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_0"><p>ACM Transactions on Embedded Computing Systems, Vol. 20, No. 1, Article 7. Publication date: December 2020.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_1"><p>We abuse notation by allowing a to also take a vector of inputs. In this case, the output of a is a vector in which a is applied separately to each element.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_2"><p>Although an event-triggered formulation could be used as well, we only present the time-triggered version in the interest of clarity. ACM Transactions on Embedded Computing Systems, Vol. 20, No. 1, Article 7. Publication date: December 2020.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="3" xml:id="foot_3"><p>Note that all results presented in this section hold for NN sigmoid activations, but similar results can be derived for tanh. ACM Transactions on Embedded Computing Systems, Vol. 20, No. 1, Article 7. Publication date: December 2020.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="4" xml:id="foot_4"><p>Note that this section focuses on the case of sigmoid activations; the treatment of tanh activations is almost identical-the differences are noted in the relevant places in the section.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="5" xml:id="foot_5"><p>The corresponding differential equation for tanh is (dtanh/dx )(x ) = 1tanh 2 (x ). ACM Transactions on Embedded Computing Systems, Vol. 20, No. 1, Article 7. Publication date: December 2020.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="6" xml:id="foot_6"><p>The example in Figure 3 assumes that the NN computation occurs instantaneously. If one would like to also model the time it takes to execute the NN, then the composition would need to also include a zero-order hold for the NN output. ACM Transactions on Embedded Computing Systems, Vol. 20, No. 1, Article</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="7" xml:id="foot_7"><p>Publication date: December 2020.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="7" xml:id="foot_8"><p>Local optima for sigmoid and tanh can be found analytically up to the fourth derivative. For higher derivatives, conservative bounds can be obtained numerically.ACM Transactions on Embedded Computing Systems, Vol. 20, No. 1, Article 7. Publication date: December 2020.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="8" xml:id="foot_9"><p>If &#952; k + &#945; i [-180, 180], then &#952; k + &#945; i needs to be normalized by adding/subtracting 360. ACM Transactions on Embedded Computing Systems, Vol. 20, No. 1, Article 7. Publication date: December 2020.</p></note>
		</body>
		</text>
</TEI>
