<?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'>A general construction for abstract interpretation of higher-order automatic differentiation</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>10/31/2022</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10404918</idno>
					<idno type="doi">10.1145/3563324</idno>
					<title level='j'>Proceedings of the ACM on Programming Languages</title>
<idno>2475-1421</idno>
<biblScope unit="volume">6</biblScope>
<biblScope unit="issue">OOPSLA2</biblScope>					

					<author>Jacob Laurel</author><author>Rem Yang</author><author>Shubham Ugare</author><author>Robert Nagel</author><author>Gagandeep Singh</author><author>Sasa Misailovic</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[We present a novel, general construction to abstractly interpret higher-order automatic differentiation (AD). Our construction allows one to instantiate an abstract interpreter for computing derivatives up to a chosen order. Furthermore, since our construction reduces the problem of abstractly reasoning about derivatives to abstractly reasoning about real-valued straight-line programs, it can be instantiated with almost any numerical abstract domain, both relational and non-relational. We formally establish the soundness of this construction.            We implement our technique by instantiating our construction with both the non-relational interval domain and the relational zonotope domain to compute both first and higher-order derivatives. In the latter case, we are the first to apply a relational domain to automatic differentiation for abstracting higher-order derivatives, and hence we are also the first abstract interpretation work to track correlations across not only different variables, but different orders of derivatives.            We evaluate these instantiations on multiple case studies, namely robustly explaining a neural network and more precisely computing a neural network’s Lipschitz constant. For robust interpretation, first and second derivatives computed via zonotope AD are up to 4.76× and 6.98× more precise, respectively, compared to interval AD. For Lipschitz certification, we obtain bounds that are up to 11,850× more precise with zonotopes, compared to the state-of-the-art interval-based tool.]]></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>Recent years have seen a resurgence in popularity of Automatic Differentiation (AD) and Differentiable Programming &#347; not only from machine learning applications requiring derivatives (e.g., for training neural networks <ref type="bibr">[Abadi et al. 2016]</ref>), but also in areas as diverse as Computer Graphics <ref type="bibr">[Li et al. 2018</ref>], Physical Simulation <ref type="bibr">[Hu et al. 2020]</ref> and Scientific Computing <ref type="bibr">[Walther and Griewank 2012]</ref>. However, despite the widespread adoption of AD, as pointed out in <ref type="bibr">H&#252;ckelheim et al. [2018]</ref>, there is surprisingly little work on formally verifying that these programs compute correctly. While there have been several works <ref type="bibr">[Di Gianantonio and Edalat 2013;</ref><ref type="bibr">Krawiec et al. 2022;</ref><ref type="bibr">Sherman et al. 2021</ref>] on proving correct the concrete semantics of AD, there is almost no work on defining different abstract AD semantics for the purpose of verifying program properties expressed over derivatives.</p><p>Abstractly interpreting AD programs is further complicated by the fact that these programs do not have the typical concrete semantics of standard numerical programs. One either overloads all operators to have a non-standard interpretation over a tuple of numbers corresponding to the derivatives, such as with dual numbers <ref type="bibr">[Griewank and Walther 2008]</ref>, or one defines the semantics of the differentiable program using reverse-mode program execution. Additionally, most semantics for computing higher-order derivatives are defined over complicated structures, such as derivative towers <ref type="bibr">[Karczmarczuk 2001</ref>] or lazily evaluated data structures as in Pearlmutter and Siskind <ref type="bibr">[2007]</ref>. Hence, given the complexities in existing AD program semantics, adapting existing static analysis techniques, specifically abstract interpretation <ref type="bibr">[Cousot and Cousot 1977]</ref>, to soundly reason about differentiable programs is a notable challenge.</p><p>While there has been limited work for soundly reasoning about AD, the few techniques that have been developed in this area are significantly restricted: they are either limited to the interval domain <ref type="bibr">[Bendtsen and Stauning 1996;</ref><ref type="bibr">Deussen 2021;</ref><ref type="bibr">Laurel et al. 2022a;</ref><ref type="bibr">Sherman et al. 2021]</ref> or do not support higher-order derivatives <ref type="bibr">[Jordan and Dimakis 2021;</ref><ref type="bibr">Laurel et al. 2022a</ref>]. Thus, precisely tracking relational information across higher derivatives is out of the realm of existing abstract interpreters, despite the fact that this precision is needed in tasks such as improving the performance of verified ODE solvers <ref type="bibr">[Immler 2018</ref>]. Furthermore, fundamental questions that arise when constructing an abstract semantics, such as how to systematically construct sound transformers for broad classes of functions or understanding the differences in the precision of different domains, have not been studied &#347; especially for AD involving higher-order derivatives.</p><p>Challenges. We focus on developing a general framework for systematically constructing abstract semantics for AD with arbitrary order derivatives. The first key challenge is that we need to first define a concrete semantics of higher-order AD that lends itself to precise and scalable abstract interpretation &#347; particularly with higher derivatives. This is challenging since the same abstract interpreter can have significantly different cost and precision for different syntactic representations of the same computation.</p><p>The second key challenge is ensuring that this abstract reasoning can then be done generally with expressive relational abstract domains and is not just constrained to the simpler interval domain, as in <ref type="bibr">Bendtsen and Stauning [1996]</ref>; <ref type="bibr">Deussen [2021]</ref>; <ref type="bibr">Laurel et al. [2022a]</ref>. This problem is challenging since unlike in conventional programs, reasoning about higher-order AD requires precise abstract transformers for an exponential number of non-linear assignment statements which result from all the different partial derivative expressions. Designing these abstract transformers manually would require considerable expertise as well as substantial AD domain knowledge to know how the functional forms of different derivatives can be leveraged for precision.</p><p>Therefore, we need a generic construction that can systematically construct sound transformers for all higher-order derivatives by composing the transformers for a small number of primitive functions in our language. We also want to systematically leverage analytical properties of these derivatives to further refine the precision of the abstraction in a way that goes beyond naively composing existing numerical domains' abstract transformers together. Simultaneously addressing all of these challenges is beyond the scope of any existing work.</p><p>Our Work. We present a novel construction for abstractly interpreting higher-order AD to address these challenges. Our construction involves defining a concrete semantics for arbitrary order AD that semantically desugars the computation of derivatives into primitive operations on single variables, and that also leverages data-dependence across derivatives in the program's syntactic representation. Thus, given only a small set of sound transformers for the elementary arithmetic primitives, we can immediately abstractly interpret these transformed AD programs, and still attain precision due to the dependency-aware syntactic representation of the AD program. Hence, we reduce the problem of formally reasoning about complicated AD semantics and having to manually design custom transformers for all possible partial derivatives to reasoning about (straight-line) programs using standard abstract domains. This technique allows us generality in the abstraction &#347; we can easily instantiate the construction with relational domains. We also show how to combine the abstract transformers with domain-specific knowledge about derivatives to further improve the precision of the analysis.</p><p>Contributions. The paper makes the following contributions:</p><p>(1) Concrete AD Semantics: We present a novel concrete semantics for higher-order AD. By designing our concrete semantics to be forward-mode and imperative, and by exposing each variable in a way that captures data dependence across derivatives, we enable one to intuitively define precise abstractions of these concrete semantics.</p><p>(2) Generic Abstract Interpretation of AD: We provide the first generic construction to allow one to abstractly interpret forward-mode AD with arbitrary order derivatives. This construction is fully general and can be instantiated with both relational and non-relational abstract domains. (3) Implementation: We implement our formal construction into a practical tool and instantiate it with the interval and zonotope domains for first and higher derivatives, thus providing the first implementation of higher-order AD with relational abstract domains. Our implementation is publicly available at <ref type="url">https://github.com/uiuc-arc/AbstractAD</ref>  <ref type="bibr">[Laurel et al. 2022c</ref>]. (4) Evaluation: We empirically show the advantages of using a relational abstract domain and the benefits of abstractly interpreting higher-order derivatives through two case studies:</p><p>(1) computing robust interpretations of regression neural networks and (2) bounding the Lipschitz constant of classification neural networks with respect to a semantic perturbation.</p><p>For the robust interpretation task, we are the first to bound both first and second derivatives of a neural network with respect to an input region. First and second derivatives computed via zonotope AD are up to 4.76&#215; and 6.98&#215; more precise, respectively, compared to interval AD. For Lipschitz certification, we obtain bounds that are up to 11,850&#215; more precise with zonotopes, compared to the state-of-the-art interval-based tool of <ref type="bibr">Laurel et al. [2022a]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">EXAMPLE</head><p>We start with a simple illustrative example that highlights the generality of our construction.</p><p>Running Example. Fig. <ref type="figure">1</ref> presents an example neural network (the reader can find a simpler example in the Appendix <ref type="bibr">[Laurel et al. 2022b]</ref>). The network takes two inputs &#119909; 1 and &#119909; 2 , propagates them through an affine layer to get the values of hidden neurons &#119909; 3 and &#119909; 4 , applies a SoftPlus activation to get the values of &#119909; 5 and &#119909; 6 , then passes those results through a final affine layer to get the outputs &#119909; 7 and &#119909; 8 . Our goal is to compute second derivatives of the network's outputs (&#119909; 7 and &#119909; 8 ) with respect to the inputs (&#119909; 1 and &#119909; 2 ). These derivatives are useful for a variety of applications, such as if we want to explain the network by computing interactions between inputs (as in Janizek et al. <ref type="bibr">[2021]</ref>) or if we want to certify input regions where the function is locally concave or convex <ref type="bibr">[Deussen 2021]</ref>. For this example, we study the impact of the interaction between &#119909; 1 and &#119909; 2 on the</p><p>&#119908; 57 = 0.7074 &#119908; 5 8 = -0 .7 0 6 8</p><p>Fig. <ref type="figure">1</ref>. Concrete 2 &#119899;&#119889; order forward-mode AD evaluation network output over a local region. The computation of the neural network output can be described by a straight-line imperative program, where each of the eight neurons is a program variable. However, when interpreting this program with forward-mode AD semantics, our interpreter will add additional augmented variables to keep track of all the derivatives (described in Section 4).</p><p>Second Derivative Analysis. While our prior work <ref type="bibr">[Laurel et al. 2022a</ref>] can propagate 1 &#119904;&#119905; derivatives through a neural network using the interval domain, for computing higher-order interactions of multiple variables, we need to compute higher derivatives with respect to the inputs, in this case 2 &#119899;&#119889; derivatives. To compute 2 &#119899;&#119889; derivatives, we instantiate a 2 &#119899;&#119889; -order instance of our construction.</p><p>A key contribution of our approach is that it provides a general construction for giving both a concrete and abstract semantics for AD of arbitrary order. For this example, each variable &#119909; &#119894; in the original program will have four associated components in the forward-mode AD interpretation. The first of the four components is the &#322;real part&#382;, denoted as &#119909; &#119894; <ref type="bibr">[&#8709;]</ref>, which intuitively corresponds to a &#322;0 &#119905;&#8462; &#382; derivative. Equivalently, &#119909; &#119894; [&#8709;] is just the value of &#119909; &#119894; , if the program were run under standard semantics instead of forward-mode AD semantics.</p><p>The next two components are &#119909; &#119894; 's first derivative terms, &#119909; &#119894; [{1}] and &#119909; &#119894; [{2}], which respectively index the first derivatives with respect to variable 1 and variable 2. Just as dual numbers (the canonical approach for first-order AD) only support differentiation of one variable at a time, our second-order analysis only supports differentiation of two variables at a time, which we explain formally in Theorem 4.11. In this example, variable 1 is just &#119909; 1 and variable 2 is just &#119909; 2 , however this need not always be the case. Hence, for each &#119909; &#119894; , &#119909; &#119894; [{1}] = &#120597;&#119909; &#119894; &#120597;&#119909; 1 and &#119909; &#119894; [{2}] = &#120597;&#119909; &#119894; &#120597;&#119909; 2 . The last of the four components is the 2 &#119899;&#119889; derivative term &#119909; &#119894; [{1, 2}], which tracks the derivative with respect to the first variable, then with respect to the second; equivalently, &#119909; &#119894; [{1, 2}] = &#120597; 2 &#119909; &#119894; &#120597;&#119909; 1 &#120597;&#119909; 2 . Furthermore, because derivatives are symmetric (e.g., &#120597; 2 &#119909; &#119894; &#120597;&#119909; 1 &#120597;&#119909; 2 = &#120597; 2 &#119909; &#119894; &#120597;&#119909; 2 &#120597;&#119909; 1 ), we do not need to worry about terms such as &#119909; &#119894; [{2, 1}]. In our example, we can think of the forward-mode AD semantics as propagating coefficients of a 2 &#119899;&#119889; degree Taylor polynomial that has been truncated to only include these terms. A key point is that our forward-mode AD semantics will automatically transform the original program to include additional variables to track these additional derivatives, which we will also call augmented variables. These derivative will be evaluated not symbolically, but rather at specific points &#347; in this example, all derivatives will be concretely evaluated at the scalar point (&#119909; &#119894;&#119899; 1 , &#119909; &#119894;&#119899; 2 ) &#8712; R<ref type="foot">foot_1</ref> shown in Fig. <ref type="figure">1</ref>. Lastly, to properly initialize the input state so that the concrete evaluation produces correct derivatives with respect to &#119909; 1 and &#119909; 2 , we initialize the first derivative terms of the inputs as</p><p>This initialization is the secondorder analog of how one initializes states for 1 &#119904;&#119905; -order forward-mode AD with dual numbers. Forward-Mode AD. The question then becomes how to correctly propagate these additional terms corresponding to first and second derivatives of each &#119909; &#119894; through the differentiable program (in this example a neural network). For first derivatives, there are the canonical dual numbers which give a standard way to do this. However, for higher derivatives, we must lift all standard calculus rules to higher-order derivatives. For instance, the chain rule must be generalized using the Faa di Bruno formula <ref type="bibr">[Di Bruno 1857]</ref>, and the product rule must be generalized using the general Leibniz rule.</p><p>We next compute the values for &#119909; 3 and &#119909; 4 . Because of the linearity of derivatives, both the first and second derivative terms for &#119909; 3 and &#119909; 4 are also linear combinations of the respective first and second derivative terms of &#119909; 1 and &#119909; 2 . Hence &#119909; 3</p><p>Upon computing all real and derivative coefficients for &#119909; 3 and &#119909; 4 , we then apply a SoftPlus activation to obtain &#119909; 5 and &#119909; 6 , respectively. Computing the first derivative terms &#347; &#119909; 5 [{1}], &#119909; 5 [{2}], &#119909; 6 [{1}], and &#119909; 6 [{2}] &#347; is done virtually identically as with dual numbers. We compute the first derivative of the SoftPlus function which is the sigmoid function, &#120590; (&#119909;), and evaluate it at both &#119909; 3 [&#8709;] and &#119909; 4 [&#8709;], saving these results in unique intermediate variables, &#119889;&#119909; 5 [1] and &#119889;&#119909; 6 <ref type="bibr">[1]</ref>.</p><p>However, for first derivatives, the chain rule tells us that we need not only the derivatives of the sigmoidal function (&#119889;&#119909; 5 [1] and &#119889;&#119909; 6 [1]) we are composing with, but also the first derivative of the inputs (&#119909; 3 [{1}] and &#119909; 4 [{1}]), hence why we must also evaluate &#119909; 5</p><p>Computing the higher-derivative terms for composition with the SoftPlus function is more involved. While computing the higher-derivative terms for affine combinations of variables is easy due to linearity, higher-derivatives of functional composition require Faa di Bruno's formula. In this example, we need to compute the value of the second derivative of the SoftPlus function, which is &#120590; (&#119909;) &#8226; (1 -&#120590; (&#119909;)). Since we have already computed &#120590; (&#119909; 3 [&#8709;]) and &#120590; (&#119909; 4 [&#8709;]), we can reuse these results (respectively stored in &#119889;&#119909; 5 [1] and &#119889;&#119909; 6 [1]), hence why the second derivatives are computed as</p><p>It is important to note that there is a data-dependence across derivatives: for instance, &#119889;&#119909; 6 [2] has data-dependence on &#119889;&#119909; 6 <ref type="bibr">[1]</ref>. This data-dependence is a direct result of how we have set up our concrete AD semantics, as one could have naively had the transformed program recompute terms instead of producing a program that exposes data dependence between lower and higher-order derivatives as we do. We will later see in Section 7 that transforming the program using this technique improves the precision when performing abstract interpretation with a relational domain.</p><p>Lastly, we again apply an affine layer to get the final output of the network. As before, we take linear combinations of not just the &#322;real&#382; parts (&#119909; 5 [&#8709;] and &#119909; 6 [&#8709;]) but also their derivative parts, since derivatives still follow linearity. The final outputs are now the derivatives with respect to the original inputs, &#119909; 1 and &#119909; 2 . Thus, &#119909; 7</p><p>= 0 .7 0 6 8 &#119908; 24 = 0.7074 </p><p>, where the notation &#120597;&#119909; &#119894; &#120597;&#119909; &#119895; ,...,&#120597;&#119909; &#119896; | (&#119909; 1 ,...,&#119909; &#119898; ) &#8712;R &#119898; denotes the partial derivative of some variable (&#119909; &#119894; ) with respect to other variables (&#119909; &#119895; , ..., &#119909; &#119896; ) evaluated at some concrete point (&#119909; 1 , ..., &#119909; &#119898; ) &#8712; R &#119898; . Likewise, we also know that &#119909; 8</p><p>2 ) &#8712;R 2 . Abstract Interpretation. Having shown how the concrete semantics are interpreted and expose each derivative explicitly as a separate variable in memory (indexed by a set), we can think about how we might abstractly interpret these semantics to get formal bounds on all of these derivatives inside a region. Getting bounds on these derivatives is useful as (1) derivatives are canonically used for explaining the behavior (e.g. 1 &#119904;&#119905; -order feature attribution or 2 &#119899;&#119889; -order interactions) of a neural network and (2) prior work has shown that such explanations evaluated at scalar points are not robust <ref type="bibr">[Alvarez-Melis and Jaakkola 2018]</ref>, hence why recent work <ref type="bibr">[Fel et al. 2022</ref>] has focused on computing provably robust explanations using interval abstractions. Abstractly interpreting the AD used to compute the derivatives for these explanations gives us these provable bounds.</p><p>For our example, we instantiate our construction with the zonotope abstract domain <ref type="bibr">[Ghorbal et al. 2009]</ref>, which associates to each variable an affine form written as &#119888; 0 + &#119870; &#119894;=1 &#119888; &#119894; &#120598; &#119894; , where each noise term satisfies &#120598; &#119894; &#8712; [-1, 1]. Since multiple variables can share noise terms, dependencies across variables are preserved to a high-degree; therefore, the zonotope domain is a relational domain.</p><p>For the purposes of this example, we want to compute provable bounds on the derivatives of all variables for the local region</p><p>, its affine form is .5 + .5&#120598; 2 , noting that it has an independent noise term (&#120598; 2 instead of &#120598; 1 ) since the variables are not correlated. Even for the abstract analysis, we still set &#119909; 1 [{1}] = 1 and &#119909; 2 [{2}] = 1 if we wish to differentiate with respect to &#119909; 1 and &#119909; 2 , hence why there are still constants (constants are represented exactly in the zonotope domain).</p><p>For AD, affine transformations on variables correspond to affine transformations on all of their derivatives. Thus, because we will be computing not just one, but 4 affine transformations per variable (one for each component), it is advantageous to have an abstract domain that is as precise as possible for affine transformations. The zonotope domain is exact for affine transformations, thus making it attractive for abstract interpretation of AD. For the &#322;real&#382; parts of &#119909; 3 and &#119909; 4 , we Applying any non-linear function, such as a &#120590; (&#119909;) or SoftPlus(x), to a zonotope or affine form is more challenging, as we must come up with an abstract transformer that employs a sound linearization of that function. Furthermore, for AD, we need a sound linearization for not just the activation function, but also for all of its derivatives. Hence, we need abstract transformers for SoftPlus(x), &#120590; (&#119909;), and multiplication. In Section 6.2, we describe how to automatically construct zonotope transformers for functions like SoftPlus(x) that other works <ref type="bibr">[Jordan and Dimakis 2021;</ref><ref type="bibr">Singh et al. 2018a</ref>] cannot support, using the Chebyshev construction <ref type="bibr">[Stolfi and de Figueiredo 2003]</ref>. The core idea is to add new noise symbols for each application of a non-linear function. The resulting affine forms after applying the SoftPlus(x) are shown above variable &#119909; 5 and below variable &#119909; 6 in Fig. <ref type="figure">2</ref>. Since the &#119889;&#119909; &#119894; [1] and &#119889;&#119909; &#119894; [2] are merely intermediate variables for the computation of each &#119909; &#119894; [{1}], &#119909; &#119894; [{2}], and &#119909; &#119894; [{1, 2}], we omit them for simplicity. However, it is important to recall that because of how we set up the semantics earlier, there is a data dependence between &#119889;&#119909; &#119894; [1] and &#119889;&#119909; &#119894; <ref type="bibr">[2]</ref>. The zonotope domain will be able to leverage this dependence for improved precision.</p><p>We can now finally propagate the zonotope through the last affine layer. As mentioned, for the zonotope domain, this step is exact. The final affine forms (which collectively form the zonotope) for all derivatives are shown in Fig. <ref type="figure">2</ref>. Furthermore, we can ultimately convert this output zonotope to interval bounds for each variable. Fig. <ref type="figure">3a</ref> presents in red the bounds for all first derivatives computed from the zonotopes and likewise Fig. <ref type="figure">3b</ref> shows in red the bounds on the second derivatives. We also show the result of performing the abstraction instantiated with the standard interval domain, denoted by the black bars in the respective plots. Lastly, we show the derivatives at randomly sampled points (&#119909; 1 , &#119909; 2 ) &#8712; [0, 1] &#215; [0, 1] using only the concrete semantics (colored points). Both plots show that zonotopes are more precise for bounding both the first and second derivatives, and both abstractions soundly enclose the derivatives computed at scalar points. There is slightly more over-approximation for the bounds in Fig. <ref type="figure">3b</ref>, as second derivatives require more computations, compounding the over-approximation inherent to the abstraction. For illustration simplicity, the example of Fig. <ref type="figure">2</ref> corresponds to a single pass of (abstract) forward-mode AD. However, to obtain all entries plotted in Figs. <ref type="figure">3a</ref> and<ref type="figure">3b</ref>, we need to rerun forward-mode AD for multiple passes. Theorem 4.11 describes how many separate passes of forward-mode AD are required.</p><p>By understanding bounds on the derivatives, we can interpret and explain the magnitude of the contribution of each variable (1 &#119904;&#119905; derivatives) or the interactive combinations of two variables (2 &#119899;&#119889; derivatives) to the final output, and do this provably for an entire input region. We empirically evaluate this approach further in Section 7.2.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">PRELIMINARIES</head><p>We now detail the necessary mathematical preliminaries to describe forward-mode automatic differentiation, particularly for higher derivatives.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Mathematical Definitions</head><p>As many of our operations involve working with sets we first detail our set-based notation. We let &#119899; &#119896; represent the scalar binomial coefficient &#119899;! (&#119899;-&#119896;)!&#119896;! . We will let P (&#119878;) denote the powerset of a set &#119878;. Furthermore, we will write |&#119878; | to denote the cardinality of &#119878;.</p><p>We will also write P &#119896; (&#119878;) to denote the collection of all subsets of some set &#119878; that have a specific cardinality &#119896;, equivalently {&#119860; &#8712; P (&#119878;) : |&#119860;| = &#119896; }. For instance, P 1 ({1, 2}) = {{1}, {2}}. For finite sets of integers in a given range, we may write {1, ..., &#119863; }, e.g. {1, ..., 4} = {1, 2, 3, 4}. To denote the set of all possible partitions of a finite set of integers, we will write Part (&#119878;).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">Forward-Mode Automatic Differentiation</head><p>The most basic implementation of first-order forward-mode AD is operator overloading with dual numbers <ref type="bibr">[Griewank et al. 2000</ref>]. Intuitively, dual numbers are two-dimensional numbers that correspond to the value of a function at a point, and the value of the function's derivative at that point. Dual numbers are canonically defined as numbers of the form &#119886; + &#119887;&#120598; with &#120598; being an infinitesimal part, similar to the imaginary part of complex numbers. However, because our work later uses &#120598; for denoting zonotope noise symbols, and because it is more intuitive when generalizing to higher derivatives, we present dual numbers simply as two-element tuples.</p><p>Definition 3.1. Dual numbers, are numbers of the form (&#119886;, &#119887;) where &#119886;, &#119887; &#8712; R and for any realvalued differentiable function &#119891; : R &#8594; R, we can lift the interpretation of &#119891; to dual numbers by defining &#119891; (&#119886;, &#119887;) = &#119891; (&#119886;), &#119891; &#8242; (&#119886;) &#8226; &#119887; .</p><p>One may also define all the arithmetic operations over dual numbers. For example for two dual numbers &#119909; = (&#119886; 1 , &#119887; 1 ) and &#119910; = (&#119886; 2 , &#119887; 2 ) one defines &#119909; +&#119910; = (&#119886; 1 +&#119886; 2 , &#119887; 1 +&#119887; 2 ), which intuitively encodes the notion of linearity. Rules for multiplication and division are similar, implicitly encoding the product and quotient rules. Hence, given a set of primitive functions &#119891; &#119894; whose derivatives &#119891; &#8242; &#119894; we know analytically, we can propagate dual numbers through arbitrary compositions of these functions including ones involving arithmetic operations to compute first derivatives compositionally.</p><p>Higher-Order Derivatives. Just as forward-mode automatic differentiation can compute first derivatives using an alternate interpretation of functions and arithmetic, it can be extended to compute higher-order derivatives, as noted in <ref type="bibr">Griewank et al. [2000]</ref>. However, higher-order derivatives are more challenging, because the formulas such as the product or chain rules must be lifted to their higher-order versions. For first derivatives there are 2 elements in the dual number tuple, hence one might expect that for &#119863; th derivatives the generalization of a dual number will be a R 2 &#119863; tuple, which we will indeed show is the case. Intuitively, for a &#119863; th -order derivative, each of the 2 &#119863; tuple elements represents a partial derivative with respect to a subset of the program variables. However, there is no loss of generality; indeed, we will show that this idea still allows one to differentiate with respect to the same variable multiple times.</p><p>This stems from the fact that in forward-mode AD, one is essentially propagating coefficients of a truncated &#119863; degree multi-variate Taylor polynomial, as the coefficients (without the integer factorial division) are precisely the values of the derivatives. We define this intuition formally. Definition 3.2. For a variable &#119909; &#119900; corresponding to some arithmetic function of variables &#119909; 1 through &#119909; &#119863; , a truncated &#119863;-degree multi-variate Taylor polynomial is a 2 &#119863; length tuple of the form</p><p>..&#120597;&#119909; &#119863; ) containing the 0 th through &#119863; th -order partial derivatives with respect to &#119909; 1 ...&#119909; &#119863; . Furthermore, each element will not be symbolic but rather the result of evaluating that derivative at a given input point, hence the tuple is an element of R 2 &#119863; .</p><p>For a fixed &#119863;, there will be &#119863; 0 zeroth derivatives (the single &#322;real&#382; part &#119909; &#119900; ), &#119863; 1 first derivatives ( &#120597; &#120597;&#119909; 1 through &#120597; &#120597;&#119909; &#119863; ) all the way up to &#119863; &#119863; derivatives of order &#119863; &#347; hence we can only compute one &#119863; th -order derivative at a time, which is why the polynomial tuple is considered truncated. Thus, for any &#119889; &#8712; {0, 1, ..., &#119863; }, there will be exactly &#119863; &#119889; derivatives of order &#119889; stored in the tuple. Furthermore, these derivatives will only be with respect to a predefined set of input variables.</p><p>Encoding Truncated Taylor Polynomials. Since each entry of a truncated &#119863;-degree Taylor polynomial is a derivative evaluated at a concrete real value, we will ultimately reduce reasoning about complicated polynomials to reasoning about their individual coefficients. However, to &#322;depackage&#382; a tuple of length 2 &#119863; where each element has a specific semantic meaning (some particular partial derivative), we need an indexing scheme to access the individual elements. This will form a core development of our concrete semantics and will later allow us to capture data dependencies between program variables (corresponding to derivatives) when abstracting the semantics.</p><p>Variable Indexing. As pointed out by <ref type="bibr">Paszke et al. [2021]</ref>, maintaining clarity in how one indexes program variables corresponding to the various derivatives in AD is difficult. Therefore, a part of our contribution is to develop a novel set-based indexing scheme, generalizing existing higherorder AD implementations [Fike and Alonso 2011]. For a &#119863; th -order truncated Taylor polynomial tuple, each of the 2 &#119863; elements corresponds to a particular element of the power-set P ({1, ..., &#119863; }). Furthermore, that element of the power set is exactly the set of variables the partial derivative is with respect to. For instance, the empty set &#8709; corresponds to the real part (e.g. &#119909; &#119900; ) since it is the partial derivative with respect to no variables. Likewise, the singleton set {1} corresponds to &#120597; &#120597;&#119909; 1 and the full set {1, ..., &#119863; } corresponds to the &#119863; th derivative &#120597; &#119863; &#119909; &#119900; &#120597;&#119909; 1 ...&#120597;&#119909; &#119863; . Hence, this indexing scheme respects the semantic meaning of the entries. Lastly, while the natural idea is to associate a unique program variable to each number in the indexing set, we can also associate the same program variable to multiple numbers of the set. Hence, we could associate a variable &#119909; &#119894; to both 1 and 2, meaning the set {1, 2} corresponds to &#120597; 2 &#120597;&#119909; &#119894; &#120597;&#119909; &#119894; . In these cases, some of the tuple elements become redundant copies of the same derivative. More details on input state initialization are in Section 4.4.</p><p>Example 3.3. For the following truncated degree 2 Taylor polynomial, where &#119909; 1 is associated to 1 and &#119909; 2 is associated to 2, given by: &#119879;</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">LANGUAGE SYNTAX AND SEMANTICS</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Syntax</head><p>Figure <ref type="figure">4</ref> presents the syntax of the language. Our language is imperative and syntactically supports arithmetic operations and differentiable function primitives. We will denote the variables in the </p><p>One can translate a pure mathematical function that uses only the differentiable primitives in our syntax into a well-formed program using an ANF conversion <ref type="bibr">[Flanagan et al. 1993</ref>].</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Concrete AD Meta-Semantics</head><p>We now define a meta-semantics, which is a construction that takes as input a maximum derivative order &#119863; to be computed and gives a concrete forward-mode AD semantics for computing derivatives up to that order using truncated Taylor polynomials. While we could map each syntactic variable &#119909; &#119894; in the original program to a 2 &#119863; length real-valued array storing its truncated Taylor polynomial, we instead syntactically desugar this mapping so that each individual coefficient in the Taylor polynomial is identified by its own unique variable. Our novel set-based indexing scheme (Section 3.2) is used to distinguish these individual variables. We call this variable set the augmented variables, or AugVars, to distinguish it from SynVars, and we will access these augmented variables using the indexing scheme. The added benefit is that by semantically exposing each entry as an intuitively indexed, augmented variable, we can (a) reduce reasoning about complicated mathematical objects (Taylor polynomials) to reasoning about standard real-valued programs and (b) we can more easily track correlations between individual variables when later using a relational abstract domain.</p><p>Hence, for forward-mode AD, our concrete states &#120590; will map &#120590; : AugVars &#8594; R. However this means that if we have &#119898; syntactic variables in the program source code (e.g. &#119909; 1 , ..., &#119909; &#119898; ), then AugVars</p><p>Having now defined a concrete AD program state &#120590; (which is what the semantics will ultimately return), we can formally define the concrete domain upon which the meta-semantics will be built.</p><p>Definition 4.3. The concrete domain D is P (AugVars &#8594; R) but this set is isomorphic to P (R |AugVars | ), hence we will also say that D = P (R |AugVars | ).</p><p>Intuitively, for a concrete state &#120590; we can just enumerate all O (&#119898; &#8226; 2 &#119863; ) augmented variables into a single state vector with their corresponding Taylor coefficient value, thus this state vector &#120590; is equivalently an element of R |AugVars | . Because our AD states are now standard mappings of (augmented) variables to real numbers, we can construct an interpreter for &#8226; &#119863; using only a standard interpreter for real-valued imperative programs &#8226; : (&#119875;, D) &#8594; D. We now formally define &#8226; &#119863; in terms of the base interpreter &#8226; .</p><p>Definition 4.4. The base interpreter &#8226; : (&#119875;, D) &#8594; D for assignment statements, and &#119864;&#119909;&#119901;&#119903; : (&#119864;&#119909;&#119901;&#119903;, D) &#8594; R for arithmetic sub-expressions, is given by the rules of Fig. <ref type="figure">5</ref>.</p><p>), the evaluation of &#8226; returns &#8869;. Likewise, any arithmetic operation with &#8869; returns &#8869;. We can now use &#8226; as a subroutine to build an interpreter for performing concrete &#119863; th degree forwardmode AD. Lastly, while &#8226; is defined in Fig. <ref type="figure">5</ref> only for elementary expressions (binary arithmetic and unary functions) we will still notationally write &#119864;&#119909;&#119901;&#119903; when &#119864;&#119909;&#119901;&#119903; is a non-elementary expression, as these are desugared to sequences of elementary operations by merely adding more augmented variables for storing all intermediate sub-expressions.</p><p>Definition 4.5. The concrete meta-semantics for performing forward-mode AD are a parametric semantics given by &#8226; &#119863; : (&#119875;, D) &#8594; D, where the parameter &#119863; &#8712; N &gt;0 is the order of the highest derivative the AD semantics can compute. Each statement's rule is shown in the following section.</p><p>We now give the formal rules for evaluating &#8226; &#119863; . We immediately see why the concrete metasemantics are parametric in &#119863; &#347; choosing a &#119863; governs how many times &#8226; will be called. This is why we refer to these as a meta-semantics &#347; choosing a different &#119863; instantiates a different concrete semantics for each statement and expression. We also mention that in all cases, despite the complex form of the right-hand side expressions used in assignments, the entire expression can always be unpacked into the language primitives of Fig. <ref type="figure">4</ref>, even if it requires introducing additional intermediate variables to store intermediate results. Lastly, this construction is defined imperatively, as these are a state-transformer semantics which update &#120590; after each application of &#8226; .</p><p>Addition. The rule for addition is simple, as higher-order derivatives also follow linearity. The meta-semantics are given, where for all coefficients &#119909; &#119894; [&#119878;] in the truncated Taylor polynomial, we compute that coefficient by adding the corresponding coefficients of syntactic variables &#119909; &#119895; and &#119909; &#119896; .</p><p>Subtraction. Subtraction follows nearly identically to addition, with the only difference being the state gets updated via</p><p>Multiplication. The rule for multiplication follows directly from the Generalized Leibniz formula (&#119878; \ &#119875; is set subtraction of &#119875; from &#119878;).</p><p>While the summation term,</p><p>is given in a general form, the only primitive operations involved are addition and multiplication, hence when instantiating a concrete instance of these semantics for a fixed derivative order &#119863; &#8712; N &gt;0 we can unroll the entire summation into primitive additions and multiplications of existing variables, and thus we can still evaluate each assignment in the for loop with the base interpreter of Fig. <ref type="figure">5</ref>.</p><p>Constants. Constants are simple, as all their higher-order derivatives are zero. Hence, for any non-empty set &#119878;, the coefficient in &#119909; &#119894; 's Taylor polynomial indexed by &#119878; will necessarily be zero.</p><p>Unary Functions. For compositions with unary functions &#119891; : R &#8594; R, we will need to use Faa di Bruno's formula <ref type="bibr">[Di Bruno 1857]</ref> as a generalization of the Chain rule to compute higherorder derivatives. The multivariate Faa di Bruno formula for a &#119863; th -order derivative of a composite function is given below in Def. 4.6: We will see that for the subsequent unary function semantic rules, there is a direct correspondence between each term in Def. 4.6 and the respective rule; in particular, each possible partial derivative needed by the Faa di Bruno formula will be stored in a separate variable. Furthermore, as with the multiplication rule, though the notation is condensed, in the subsequent semantic rules, all primitive arithmetic operations are just additions (from &#119875; &#8712;&#119875;&#119886;&#119903;&#119905; (&#119878;) ), multiplications (from &#119861; &#8712;&#119875; ), variable lookups (e.g. due to &#119909; &#119895; [&#119861;]) or elementary function evaluations of &#119891; and its analytically known derivatives. Further, when fixing a particular order of derivative, &#119863;, all possible partitions of all possible sets (e.g. &#119875; &#8712; &#119875;&#119886;&#119903;&#119905; (&#119878;)) can be precomputed and enumerated (as they are finite), as can |&#119875; |. Hence, these seemingly complicated expressions still reduce to elementary operations.</p><p>The core requirement is that we are able to analytically compute the first through &#119863; th derivatives of &#119891; evaluated at the real part of &#119909; &#119895; (itself stored in &#119909; &#119895; <ref type="bibr">[&#8709;]</ref>). Thus, we restrict &#119891; to only elementary functions whose derivatives of all orders can be known analytically as combinations of the other elementary functions in the language, hence why the language is restricted as shown in Fig. <ref type="figure">4</ref>. Each of the &#119863; derivatives of &#119891; will be stored in a unique &#119863; element array: &#119889;&#119909; &#119894; [0] through &#119889;&#119909; &#119894; [&#119863;] within &#120590;, but as with the Taylor coefficients, each of these elements will be exposed as its own variable. Lastly, this is the only part that changes when defining the meta-semantics of different functions.</p><p>Division. Since Division is composition with the function &#119891; (&#119909;) = 1 &#119909; , we can encode it using the above technique. Furthermore, the derivatives of 1 &#119909; have a known elementary form that can be encoded using only primitive arithmetic operations (multiplications and divisions), which specifically is</p><p>which allows us to capture data dependencies across derivative terms.</p><p>Exp and Log . As before, for log and exp the only difference will be the computation of the &#119863;-derivatives array, which for the exponential function is given as</p><p>For the log function, the first derivative is just 1 &#119909; , hence we can reuse the functional form from the division rule to compute all further derivatives.</p><p>Sigmoid and SoftPlus. The sigmoid function &#120590; &#119886; (&#119909;) = 1 1+&#119890; -&#119886;&#119909; is such that all of its derivatives can be given in terms of an elementary combination of other sigmoid functions. The &#119889; th derivative is given as &#119889; &#119889; &#119889;&#119909; &#119889; &#120590; &#119886; (&#119909;) = &#119889; &#119896;=0 (-1) &#119889;+&#119896; (&#119896;!)(&#119878; &#119889;,&#119896; )(&#119886; &#119889; )&#120590; &#119886; (&#119909;)(1 -&#120590; &#119886; (&#119909;)) &#119896; , where &#119878; &#119889;,&#119896; are Stirling numbers of the second kind (which are just constants). Hence for any fixed &#119889; &#8712; N, we can combinatorially enumerate all the terms in order to have an analytical closed-form expression for the &#119889; th derivative that uses only elementary operations (sums, products and constants) and the sigmoid function itself. This means that we need only compute the sigmoid once, which we do by having the base interpreter evaluate &#119909; &#119894; [&#8709;] = &#120590; &#119886; (&#119909; &#119895; [&#8709;]) (&#120590;), after which we can fetch the variable &#119909; &#119894; [&#8709;] when computing each &#119889;&#119909; &#119894; <ref type="bibr">[&#119889;]</ref> augmented variable. This helps us to capture the dependency across derivatives.</p><p>Furthermore, because the sigmoid function is just the first derivative of the SoftPlus function, the &#119889; th derivative of a SoftPlus is just the &#119889; -1 th derivative of a sigmoid, hence we can leverage the exact same functional form when computing &#119889;&#119909; &#119894; [&#119889;] for the SoftPlus function.</p><p>Sequencing. Having defined the construction to produce a semantics for computing the &#119863; th derivative for individual assignment statements, we now note how sequencing of multiple statements works. We also note that the simplicity in the sequencing rule stems from the fact that programs are assumed to be in SSA form, hence no program variable will be overwritten.</p><p>Remark 1. When &#119863; = 1, &#8226; &#119863; computes exactly the dual numbers <ref type="bibr">[Griewank and Walther 2008]</ref> and when &#119863; = 2, &#8226; &#119863; computes exactly the hyper-dual numbers [Fike and Alonso 2011].</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3">Precision Enhancement</head><p>A key contribution of our concrete semantics is to ensure that the transformed program which computes all derivatives is generated in such a way that the later abstract interpretation will be precise. For AD, the computation of derivatives involves heavy reuse of common sub-expressions, hence by sharing these sub-expressions across multiple variables, the data dependence between different derivatives can be made explicit. For instance, in the case of the exp function, all derivatives, &#119889;&#119909; &#119894; [&#119889;], will be computed as &#119889;&#119909; &#119894; [&#119889;] = &#119909; &#119894; [&#8709;] (&#120590;) where &#119909; &#119894; [&#8709;] already stores the result of computing exp(&#119909; &#119895; ). Likewise, one can see similar data dependencies made explicit in the rules for 1 &#119909; and the &#120590; &#119886; function. While this will not change the execution result of the concrete semantics, it does substantially improve the precision of the abstract interpretation, as will be seen in Section 7.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.4">Correctness</head><p>We now formally state the correctness as well as how one initializes the state to compute derivatives with respect to specific variables.</p><p>Input Variables. We must first decide which input variables we wish to differentiate with respect to. However, we first note the following important remark that provides a limitation on how many input variables we can differentiate with respect to in a single forward execution &#119875; &#119863; (&#120590;).</p><p>Remark 2. For any set of syntactic input variables &#119909; &#119894;&#119899; &#119894; ,..., &#119909; &#119894;&#119899; &#119895; when evaluating &#119875; &#119863; (&#120590;), we can only differentiate with respect to up to &#119863; distinct syntactic variables.</p><p>This means that if the program &#119875; has more syntactic input variables than the maximum derivative order &#119863;, some variables will necessarily be treated as constants (meaning not differentiated). Additionally, if we differentiate with respect to the same syntactic variable more than once (e.g. to compute &#120597; 2 &#120597;&#119909; &#119894; &#120597;&#119909; &#119894; ) the number of distinct variables we will be differentiating with respect to will be strictly less than &#119863;, again meaning some input variables will be treated as constants. However, as we will see, if one wishes to compute more derivatives, one may always rerun &#8226; &#119863; with different input variables initialized to obtain their derivatives. Input State. After deciding which of the (up to &#119863;) syntactic input variables we wish to differentiate with respect to, we must properly initialize each of those syntactic input variables' corresponding augmented variables in the input state, as AD only produces correct derivatives if input states are initialized correctly <ref type="bibr">[Griewank and Walther 2008]</ref>. We generalize this idea to arbitrary order derivatives, as described below.</p><p>Definition 4.7. For &#8226; &#119863; , an initial state &#120590; is valid if for each singleton set &#119878; &#8712; P 1 ({1, ..., &#119863; }), exactly one augmented variable satisfies &#119909; &#119894;&#119899; &#119894; [&#119878;] = 1 while all others satisfy &#119909; &#119894;&#119899; &#119895; [&#119878;] = 0. Furthermore, for each &#119878; &#8712; P &#119896; ({1, ..., &#119863; }) where &#119896; &#8805; 2, all augmented variables satisfy &#119909; &#119894;&#119899; &#119894; [&#119878;] = 0. For different singleton sets &#119878;, &#119878; &#8242; &#8712; P 1 ({1, ..., &#119863; }), where &#119878; &#8800; &#119878; &#8242; , the same input variable &#119909; &#119894;&#119899; &#119894; can satisfy both &#119909; &#119894;&#119899; &#119894; [&#119878;] = 1 and &#119909; &#119894;&#119899; &#119894; [&#119878; &#8242; ] = 1. Setting two different augmented variables that are both associated with the same syntactic variable to 1 allows us to differentiate with respect to the same variable twice (e.g.</p><p>) instead of only being able to differentiate with respect to different variables. We now illustrate an example of a valid initial state.</p><p>Example 4.8. For &#119863; = 2 and &#119875; &#8796; &#119909; 3 = &#119909; &#119894;&#119899; 1 + &#119909; &#119894;&#119899; 2 , and state &#120590; given as</p><p>]] = 0 , then we have that &#120590; is a valid input state to &#119875; &#119863; that can be used to compute</p><p>]] &#8800; 0 then &#120590; would no longer be a valid initial state.</p><p>We next detail a lemma that says a correctly initialized input state computes valid derivatives of the input variables. This lemma also relates the syntactic variables of the program to the augmented variables computed by the interpreter and serves as the base case of our correctness theorem. Lemma 4.9. Let &#120590; be a valid input state. Then for any syntactic input variable &#119909; &#119894;&#119899; &#119894; and any non-empty set &#119878; &#8712; P (&#119863;) \ &#8709;, we have that</p><p>where &#119860;&#119888;&#119905;&#119894;&#119907;&#119890; (&#119878;) is the list of all input variables &#119909; &#119894;&#119899; &#119895; satisfying &#119909; &#119894;&#119899; &#119895; [{&#119904; &#119895; }] = 1 for some &#119904; &#119895; &#8712; &#119878;. Proof. See Appendix. &#9633;</p><p>Computing Derivatives. Having established that a valid input state stores derivatives correctly, the idea is to now show that after executing each statement, the derivatives are still correct.</p><p>Theorem 4.10. Let &#120590; be a valid input state and &#119875; be a well-formed program, and let &#120590; &#8242; = &#119875; &#119863; (&#120590;). Then for any variable &#119909; &#119894; in &#120590; &#8242; and any non-empty set &#119878; &#8712; P (&#119863;) \ &#8709;, we have that</p><p>Proof. (Sketch) We show select cases with all other cases shown in the Appendix.</p><p>&#8226; Constants. For non-empty set &#119878;, and constant &#119888; &#8712; R,</p><p>) &#8712;R &#119898; = 0. However, for any non-empty &#119878;, the interpreter always assigns 0 to &#120590; &#8242; [&#119909; &#119894; <ref type="bibr">[&#119878;]</ref>].</p><p>&#8226; Addition. As the current state &#120590; has been correctly initialized, before executing &#119909; &#119894; = &#119909; &#119895; +&#119909; &#119896; &#119863; (&#120590;)</p><p>we inductively assume (by Lemma 4.9) that for each </p><p>After executing the meta-semantic rule for addition <ref type="bibr">[&#119878;]</ref>] by the rules of the base interpreter in Fig. <ref type="figure">5</ref>. Thus, by substitution</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&#9633;</head><p>Complexity. While Theorem 4.10 tells us that for the predetermined set of input variables, the derivatives will be correctly computed, as mentioned these derivatives are only with respect to a subset of the input variables. To compute all possible derivatives with respect to all possible input variables (for the full Jacobian or Hessian), we must rerun &#119875; &#119863; multiple times for different (valid) input states &#120590;. In the simplest case, for &#119863; = 1 (dual numbers), one needs to rerun &#119875; 1 exactly &#119898; times for functions of the form &#119891; : R &#119898; &#8594; R &#119899; to obtain the entire Jacobian. We can generalize this result for arbitrary &#119863;.</p><p>Theorem 4.11. For a program &#119875; corresponding to a function &#119891; : R &#119898; &#8594; R &#119899; where &#119898; &gt; &#119863;, to compute all possible derivatives up to the &#119863; &#119905;&#8462; order, requires evaluating &#119875; &#119863; exactly &#119898;+&#119863;-1 &#119863; times.</p><p>Proof. (Sketch) We provide the basic intuition here. First, &#119898;+&#119863;-1 &#119863; is the number of ways to select &#119863; items from a set of size &#119898;, with replacement when order does not matter. The &#119863; items we select are precisely the &#119863; variable we wish to differentiate with respect to. The reason why replacement is allowed is because we can differentiate with respect to the same variable multiple times. Likewise, the reason why order does not matter is because &#120597; &#120597;&#119909; &#119894; &#120597;&#119909; &#119895; = &#120597; &#120597;&#119909; &#119895; &#120597;&#119909; &#119894; , hence we do not need to recompute them separately. &#9633;</p><p>As we can see, for dual numbers (&#119863; = 1) this reduces to &#119898; 1 = &#119898; independent forward passes, as is well-known. While the complexity for higher-order AD seems expensive, it is the same complexity given in <ref type="bibr">Griewank and Walther [2008]</ref>, and more recent work [He 2019] has noted that specifically for higher-order derivatives, forward-mode AD is better suited than reverse mode.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">ABSTRACT SEMANTICS OF HIGHER-ORDER AD</head><p>Our construction is the first to provide a generic approach to abstractly interpret the semantics of higher-order AD. The key benefit of our construction is that by exposing each derivative term explicitly in a memory state as an augmented variable, we reduce the problem of reasoning about complex mathematical objects used in AD to reasoning about standard program states. Thus, we can readily apply existing numerical abstract domains. Furthermore, because our formulation is imperative, and our transformed AD program captures data-dependence across derivative terms, we can leverage the state-based semantics during analysis to conveniently use relational abstract domains that also track correlations between variables. This allows us to precisely track correlations across derivatives (including different orders). We first define the preliminaries of abstract interpretation suitable for our setting.</p><p>Definition 5.1. [Abstract Interpretation] The abstract interpretation primitives that our construction requires are given by the following symbols: (D # , &#120574;, &#8869; # , &#8868; # , &#8226; # ) where D # represents the set of abstract program states, &#120574; : D # &#8594; D is a concretization function mapping abstract states to sets of concrete states. Further, &#8869; # and &#8868; # are the abstract domain's respective least and greatest elements. Lastly, &#8226; # are sound abstract transformers for statements in the language of Fig. <ref type="figure">4</ref>.</p><p>Given an abstract domain, we can interpret the same program syntax over the abstract domain in a way that over-approximates the concrete program semantics, which are computed by &#8226; . Definition 5.2. [Soundness] An abstract transformer &#8226; # for statements is sound if the following holds: For any &#120590; # &#8712; D # and any valid syntactic expression &#119864;&#119909;&#119901;&#119903; in the language of Fig. <ref type="figure">4</ref>:</p><p>where</p><p>Hence, we say that the abstract interpreter &#8226; # soundly over-approximates the semantics of the base interpreter &#8226; of Fig. <ref type="figure">5</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Choosing an Abstract Domain</head><p>To construct an abstract interpreter &#8226; # &#119863; to soundly over-approximate &#8226; &#119863; , we use an existing abstract interpreter &#8226; # defined over a numerical abstract domain that soundly over-approximates the semantics of the base interpreter &#8226; . Having defined the primitives needed for the construction in Defs. 5.1 and 5. (4) For any arithmetic expression &#119864;&#119909;&#119901;&#119903; in Fig. <ref type="figure">4</ref>, we require a sound transformer for assignments with that expression, &#119909; &#119894; = &#119864;&#119909;&#119901;&#119903; # : D # &#8594; D # . (5) (Optionally) we need an abstract test transformer &#119909; &#119894; &gt; &#119888; # : D # &#8594; D # for refining abstract states with linear constraints. We also require that &#120574; ( &#119909; &#119894; &gt; &#119888; # (&#120590; # )) &#8838; &#120574; (&#120590; # ).</p><p>We provide detailed explanation of Items 4 and 5 below, but we first note a (non-exhaustive) list of abstract domains satisfying these requirements.</p><p>Remark 3. The Interval domain, Octagon domain, Zonotope domain, DeepPoly domain, and Polyhedra domain can all be endowed with the necessary transformers to satisfy the requirements.</p><p>Assignment of Arithmetic Expressions. The abstract domain must have sound transformers for assignment with arithmetic expressions of Fig. <ref type="figure">4</ref>, which includes arithmetic primitives (e.g., addition and multiplication) and constants but also differentiable unary functions (e.g., exp, log).</p><p>Arithmetic Primitives. The abstract domain must provide sound transformers for all primitive arithmetic operations: +, -, &#8226;, and /, as well as assignments with constants. For the interval domain, there are sound transformers for all of these. For domains like zonotopes, octagons, or polyhedra, one can always employ linearization of the non-linear operations of &#8226; and / as in <ref type="bibr">Stolfi and de Figueiredo [2003]</ref> and <ref type="bibr">Min&#233; [2006]</ref> to construct the necessary transformers. <ref type="bibr">Shi et al. [2019]</ref> has also shown how to construct DeepPoly abstract transformers for &#8226; and /.</p><p>Differentiable Unary Functions. As our language (Fig. <ref type="figure">4</ref>) includes unary functions, the chosen abstract domain must provide sound transformers for the following functions: &#120590; &#119886; , SoftPlus, exp, and log. As mentioned in Section 4.5, the derivatives of each of these functions are given in terms of elementary arithmetic combinations of functions already in the language (e.g., &#120590; &#8242; &#119886; (&#119909;) = &#120590; &#119886; (&#119909;) &#8226; (1 -&#120590; &#119886; (&#119909;)), hence this set of functions is &#322;closed&#382; under n th derivatives. As with the arithmetic primitives, for the interval domain, there are sound transformers for all of these, while for zonotopes and polyhedra, one would need to soundly linearize these non-linear functions, such as the Chebyshev method for zonotopes <ref type="bibr">[Stolfi and de Figueiredo 2003]</ref>, the polyhedral linearization of <ref type="bibr">Min&#233; [2006]</ref>, or using the methods of <ref type="bibr">Ryou et al. [2021]</ref> for the DeepPoly domain.</p><p>Automatically Improving Precision. Beyond naively composing existing abstract transformers from a numerical domain, we also want to devise a method for automatically improving the precision of the analysis. Having an optimal transformer for one primitive function, does not necessarily imply one has an optimal transformer for all derivatives of that function, particularly if the derivative requires the composition of multiple primitive function transformers (e.g., &#120590; &#8242; &#119886; = &#120590; &#119886; (&#119909;) &#8226; (1 -&#120590; &#119886; (&#119909;)) requires composing transformers for &#120590; &#119886; and multiplication), since naive, off-the-shelf composition of numerical abstract transformers can be non-optimal.</p><p>To avoid this issue, we leverage analytical properties of the derivatives of the functions to systematically improve the precision of &#8226; # &#119863; . We now describe an optional requirement on the domain that can improve the abstraction's precision. By using an abstract test operator &#119909; &#119894; &gt; &#119888; # (&#120590; # ), we can refine the abstract state &#120590; # using analytical information about the range of the function's derivatives. This allows us to enforce constraints, such as how every odd derivative of 1 &#119909; is necessarily negative. However, one can always define &#119909; &#119894; &gt; &#119888; # (&#120590; # ) = &#120590; # (the identity), hence why this step is optional. By requiring &#120574; ( &#119909; &#119894; &gt; &#119888; # (&#120590; # )) &#8838; &#120574; (&#120590; # ), this step never loses precision.</p><p>Remark 4. We do not need a widening operator, since all the programs expressible in the syntax of Fig. <ref type="figure">4</ref> are loop-free. We also do not require a join operator &#8852; or meet operator &#8851;.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">Abstract Meta-Semantics</head><p>We now provide an abstract meta-semantics which shows how to leverage an existing numerical abstract domain satisfying our criteria to construct a sound abstract interpreter for &#119863; th -order AD. We highlight that the ease in defining our abstract semantics stems from design choices made in constructing our concrete semantics (Definition 4.5). However, merely using the abstract version of each arithmetic operator naively is imprecise, hence we will also see how the abstract meta-semantics leverages mathematical properties of differentiable functions to improve precision.</p><p>Definition 5.3. The abstract meta-semantics for performing &#119863;-degree Taylor polynomial forwardmode abstract AD are a parametric (abstract) semantics given by &#8226; # &#119863; : (&#119875;, D # ) &#8594; D # , where &#119875; is a program in the syntax of Fig. <ref type="figure">4</ref>. The abstract meta-semantics are parametric in both the order of derivative &#119863;, as well as the underlying numeric abstract domain D # and its associated abstract transformers &#8226; # . The abstract meta-semantics ultimately return an abstract state, &#120590; # at the program exit. This is in contrast to the concrete meta-semantics of Definition 4.5 which are parametric only in &#119863;, (they have a fixed base interpreter, &#8226; ). This is because &#8226; # &#119863; can use any set of abstract transformers &#8226; # satisfying the criteria of Section 5.1, thus the construction is configurable. This also allows the correctness to be easily established &#347; proving that the abstract meta-semantics soundly over-approximate the concrete meta-semantics reduces to showing that the instantiated numerical abstract domain over-approximates the base interpreter at each step.</p><p>Addition. The meta-semantics of abstract addition follow very similarly to the concrete case, by adding respective derivative terms (via linearity) albeit using the abstract interpreter &#8226; # of the chosen numerical abstract domain instead of the base interpreter &#8226; , noting that by the assumptions of Section 5.1, &#8226; # has sound transformers for (abstract) addition of two variables.</p><p>Multiplication. The rule for multiplication follows an abstracted form of the generalized Leibniz formula, again noting by assumption that &#8226; # has sound transformers for assignments involving the sum and product of variables and that &#119878; \ &#119875; represents set subtraction.</p><p>Constants. For this case, we need to assign each augmented variable to a constant (either &#119888; or 0), hence all this requires is that the abstract domain has sound transformers constant assignment.</p><p>Unary Functions. As in the concrete meta-semantics, with unary functions, we must use Faa di Bruno's formula (Def. 4.6). In the computation of the first through &#119863; th derivatives of &#119891; (stored in &#119889;&#119909; &#119894; [1] through &#119889;&#119909; &#119894; [&#119863;]), since we know the derivatives' analytical forms, we also know their valid ranges, hence we can refine the abstract state &#120590; # to use this knowledge via the &#119909; &#119894; &gt; &#119888; # abstract test transformer. This is helpful for enforcing domain-specific knowledge. Since the refinement depends on the particular function, we only show cases for specific unary functions.</p><p>As noted, division is composition with the function &#119891; (&#119909;) = 1 &#119909; , hence we again use Faa di Bruno's formula. Additionally, every odd derivative of 1 &#119909; is necessarily negative, hence we can apply the abstract test operator to refine &#120590; # . Lastly because the derivatives (&#119889;&#119909; &#119894; ) that are used to compute &#119909; &#119894; <ref type="bibr">[&#119878;]</ref> for &#119878; &#8800; &#8709; are given in terms of the real part &#119909; &#119894; [&#8709;], when instantiated with a relational domain like zonotopes, we are tracking correlations across derivative orders.</p><p>Exp and Log. Since all &#119899; &#119905;&#8462; derivatives of exp are also exp, and the exp function is strictly positive, we can always refine the abstract state with this constraint. Additionally, we can exploit the fact that all derivatives of exp are also exp. Therefore, we only need to compute this once via the</p><p>), and then we can merely copy the result into the variables corresponding to each derivative &#119889;&#119909; &#119894; . However, the benefit of this is not only computational savings, but also the potential for improved precision if instantiating the construction with a relational abstract domain. Since all the &#119889;&#119909; &#119894; variables are directly used to compute the &#119909; &#119894; [&#119878;] for &#119878; &#8800; &#8709;, if &#8226; # is instantiated with a relational domain, one is able to track correlations across those derivatives.</p><p>Abstract Sequencing. Abstractly interpreting the sequencing of multiple statements follows similarly to the concrete meta-semantics.</p><p>Proc. ACM Program. Lang., Vol. 6, No. OOPSLA2, Article 161. Publication date: October 2022.</p><p>Remark 5. Since all variables and their derivatives are included in the abstract state &#120590; # , when instantiated with a relational domain (e.g., zonotopes), this construction produces an abstract interpreter that relationally tracks dependencies across derivatives and derivative orders.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.3">Soundness</head><p>Intuitively the soundness follows from construction. By composing abstract transformers at each step that are sound for each primitive, the end construction soundly over-approximates the original concrete semantics. However, we now state this formally.</p><p>Theorem 5.4. (Soundness of Abstraction) For any program &#119875; expressible in the syntax of Fig. <ref type="figure">4</ref>, &#119863; &#8712; N, &#120590; # &#8712; D # and any &#120590; &#8712; &#120574; (&#120590; # ), then we have that &#119875; &#119863; (&#120590;) &#8712; &#120574; ( &#119875; # &#119863; (&#120590; # )). Thus, we can compute a sound over-approximation of the set of values that the (possibly higherorder) derivatives take, provided all the requirements of Section 5.1 are satisfied.</p><p>Proof. (Sketch) We provide sketches of representative cases (others detailed in the Appendix):</p><p>&#8226; Addition: We need to show that for any &#119863;, &#120590; # &#8712; D # with &#120590; &#8712; &#120574; (&#120590; # ) that the following holds:</p><p>in the for loop of the meta-semantic rule for &#119909; &#119894; = &#119909; &#119895; +&#119909; &#119896; &#119863; (&#120590;), there is the corresponding application</p><p>), thus by the initial assumption that &#120590; &#8712; &#120574; (&#120590; # ), and that fact that &#8226; # soundly over-approximates &#8226; (also by assumption) for every application (regardless of &#119863;) we know &#119909; &#119894;</p><p>&#8226; Division: We need to show that for any &#119863;, &#120590; # &#8712; D # with &#120590; &#8712; &#120574; (&#120590; # ) that the following holds:</p><p>The idea is the same, we note that for each application &#120590; = &#119889;&#119909; &#119894; [&#119889;] = -&#119889; &#8226; &#119909; &#119894; [&#8709;] &#8226; &#119889;&#119909; &#119894; [&#119889; -1] (&#120590;) in the concrete meta-semantics, that the corresponding application</p><p>) in the abstract metasemantics soundly over-approximates it. To address the application of &#119889;&#119909; &#119894; [&#119889;] &lt; 0 # (&#120590; # ), we note that in the concrete semantics, &#119889;&#119909; &#119894; [&#119889;] will never be greater than 0 if &#119889; is odd. Thus, even after applying this refinement, we still have that &#120590; &#8712; &#120574; (&#120590; # ). Likewise, for each application </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">INSTANTIATIONS</head><p>We formally describe instantiations of our framework, which we will later evaluate in order to study the effects of first vs. higher derivatives as well as relational vs. non-relational abstract domains.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.1">Interval AD</head><p>While interval arithmetic has been applied to AD, our construction is more general, thus using the interval domain is but one instantiation of our framework.</p><p>Interval Domain. The interval domain, denoted D # = P (IR |&#119860;&#119906;&#119892;&#119881; &#119886;&#119903;&#119904; | ), is among the simplest numeric abstract domains where in an abstract state &#120590; # a variable is mapped to an interval [&#119886;, &#119887;] &#8712; IR, hence &#120590; # : AugVar &#8594; IR. The interval domain is non-relational.</p><p>First Derivatives. Our construction can be used to produce the Dual Interval domain of <ref type="bibr">Laurel et al. [2022a]</ref>. This is an instantiation of our framework where &#119863; = 1 with the interval domain.</p><p>Higher Derivatives. We may also encode an interval abstraction of the hyperdual numbers of Fike and Alonso [2011] using our framework, which allows us to obtain interval bounds on second derivatives. This is done by instantiating our construction with &#119863; = 2 and the interval domain.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.2">Zonotope AD</head><p>To the best of our knowledge, prior to our work, there has been no general zonotope abstract interpretation for forward-mode AD, especially for higher-order derivatives.</p><p>Zonotope Abstract Domain. We first describe the zonotope abstract domain, which we denote with D # = Zono. The abstract state &#120590; # &#8712; Zono maps each variable to an affine form, where an affine form is a tuple (&#119888;, &#119892;) with center &#119888; &#8712; R and &#119892; &#8712; R |generators | where |generators| is the number of noise symbols (also called generators). For a variable &#119909;, to denote its affine form, we will write</p><p>&#119892; &#119894; &#120598; &#119894; , where each noise symbol &#120598; &#119894; &#8712; [-1, 1]. To index a variable's affine form in the abstract state &#120590; # , we may write</p><p>to access the coefficients of the center and noise symbol terms. Because the &#120598; &#119894; are shared across variables, this is a relational domain; furthermore, the set of states encoded by &#120590; # is exactly a zonotope. This can be seen from the concretization function &#120574; : Zono &#8594; P (R |AugVars | ) defined as:</p><p>As mentioned in <ref type="bibr">Albarghouthi [2021]</ref>, |generators| grows as the program executes since new noise symbols (the &#120598; &#119894; &#8712; [-1, 1]) are dynamically added with each non-linear operation (e.g., multiplication, &#120590; &#119886; (&#119909;), etc.). However, the zonotope domain loses no precision when encoding affine transformations, since these can be done precisely in the domain.</p><p>One can also convert an affine form &#119909; = &#119888; + |&#119892; &#119894; |. This will prove useful when constructing sound transformers for arithmetic primitives.</p><p>Differentiable Zonotope Transformers. While the construction of Section 5 shows us how to produce a &#119863; th -order forward-mode AD abstract interpreter &#8226; # &#119863; using the chosen abstract domain D # , it assumes the existence of sound transformers, &#8226; # , for the arithmetic functions and gives no way to produce them. However, for zonotopes, prior works <ref type="bibr">[Jordan and Dimakis 2021;</ref><ref type="bibr">Singh et al. 2018a]</ref> give sound transformers for some (e.g., tanh), but not all of the functions we support. Therefore, when instantiating with zonotopes, we need an automatic construction for sound differentiable function transformers. To do so, we use the Chebyshev construction <ref type="bibr">[Fryazinov et al. 2010;</ref><ref type="bibr">Stolfi and de Figueiredo 2003</ref> . We refer to this formula as the Chebyshev construction for &#119891; . The Chebyshev construction gives us sound zonotope transformers for the following functions: SoftPlus a (&#119909;), log(&#119909;), exp(&#119909;), and 1 &#119909; . For the other functions, we can use existing zonotope transformers (e.g., those in <ref type="bibr">Singh et al. [2018a]</ref>) or just default to the interval domain transformers. We can then collectively use all of these abstract transformers in the general construction of &#8226; # &#119863; . Theorem 6.2. When &#119863; = 2 and when the abstract domain is the zonotope domain, &#8226; &#119863; computes a zonotope abstraction of the hyper-dual numbers of Fike and Alonso <ref type="bibr">[2011]</ref>.</p><p>Precision. For many functions, the zonotope transformers are strictly more precise than the interval ones. As mentioned in <ref type="bibr">[Fryazinov et al. 2010;</ref><ref type="bibr">Stolfi and de Figueiredo 2003]</ref>, the Chebyshev construction is optimal in the input-output plane, hence it gives the same guarantees as <ref type="bibr">Singh et [2018a]</ref>. The zonotope transformers in this case are incomparable to the interval ones. We also found that existing abstract test transformers for zonotopes <ref type="bibr">[Jeannet and Min&#233; 2009;</ref><ref type="bibr">Singh et al. 2017]</ref> do not boost precision, but increase cost. Hence, when instantiating our construction with zonotopes, we use the identity function &#119909; &#119894; &gt; &#119888; (&#120590; # ) = &#120590; # for the tests.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">CASE STUDIES</head><p>We now present a set of case studies that highlight the benefits of an abstraction supporting both higher-order derivatives and more precise abstract domains.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.1">Methodology</head><p>We briefly describe the experimental setup and the network architectures used in our experiments. We ran our experiments on a 3.70 GHz Intel Xeon W-2135 CPU with 32 GB of main memory. For the first case study on the robust interpretation of first-and second-order effects, we trained a 3-layer neural network with 5 inputs, 64 neurons in the first hidden layer, 10 neurons in the second hidden layer, and 1 output neuron to approximate a 5-input, 1-output synthetic function polynomial of degree two with five interactions; the network uses the SoftPlus activation function after every layer. For the Lipschitz certification case study, we trained four fully connected networks on the <ref type="bibr">MNIST [LeCun 1998</ref>] image classification dataset (which contains 70,000 28 &#215; 28 images of handwritten digits) &#347; three are smaller networks with 3, 4, and 5 layers having 100 neurons in each hidden layer, and one is the FFNNBig architecture from <ref type="bibr">Singh et al. [2019]</ref> consisting of 4,106 neurons (4 hidden layers of 1,024 neurons each). Each hidden layer is followed by a SoftPlus activation function. All networks attain over 98% accuracy on the test set. For the perturbation function, we consider the Haze perturbation studied in <ref type="bibr">Paterson et al. [2021]</ref>. For all experiments, we also present runtimes for the analyses.</p><p>Implementation. The instantations of our framework for both first and second derivatives on the interval and zonotope domains were all implemented in PyTorch.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.2">Robust Derivative-Based Interpretations</head><p>As neural networks are notoriously hard to understand, significant work has focused on constructing more interpretable explanations, in order to understand which features are most relevant to the network's outputs. A standard way of interpreting and explaining neural networks involves computing derivatives of the network's outputs with respect to their inputs <ref type="bibr">[Ancona et al. 2018;</ref><ref type="bibr">Janizek et al. 2021</ref>]. However, prior work has shown that it is not enough to generate explanations for scalar points; rather, explanations should be robust, hence why <ref type="bibr">Fel et al. [2022]</ref> used robust interval explanations. Our case study serves to show how our construction allows a user to compute provably robust interpretations via derivative-based first-order feature attributions and secondorder feature interactions. For our experiments, we uniformly generate 5 random inputs in the    range [0, 1) and enclose each input in an interval of &#177;0.01. We then soundly bound the first and second derivatives of the neural network (trained to approximate a polynomial as described in Section 7.1) with respect to these input ranges. We repeat this experiment for 5 different seeds.</p><p>Table <ref type="table">1</ref> and Table <ref type="table">demonstrate</ref> the precision improvement of the zonotope domain on bounding the Jacobian and the Hessian, respectively. In both tables, each cell presents the geometric mean over 5 trials of the ratio of the interval-bounded derivative's width over its zonotope-bounded counterpart. For zonotopes and intervals, the average runtimes across all trials are 0.014 and 0.009 seconds for the first-order information and 0.23 and 0.11 seconds for the second-order information, respectively. This demonstrates that the substantial increase in precision when using the zonotope domain does not incur a large runtime overhead. Furthermore, performing the separate passes to compute each Jacobian or Hessian term takes virtually the same time, meaning that the input one differentiates with respect to does not affect the runtime.</p><p>We next show detailed results for the trial that yields the median improvement in precision when using zonotopes over intervals (the other trials show the same trend). Fig. <ref type="figure">6</ref> presents the bounds on the first derivatives (the Jacobian). The entries on the x-axis correspond to the first derivative of the network's output node with respect to each of the 5 input variables. The value of the y-axis denotes the value of the derivative. We compare derivatives computed at sampled scalar points with both an interval and zonotope instantiation of our framework for first derivatives. The zonotope bounds on the Jacobian entries are much tighter than the bounds computed via the interval domain, both of which enclose the sampled points (shown in multiple colors).</p><p>We also compute the second derivatives to study the magnitude of interactions between input variables over an entire region of the input space. Fig. <ref type="figure">7</ref> presents the results (for the same trial as in Fig. <ref type="figure">6</ref>). The entries along the x-axis represent Hessian terms instead of just individual input derivatives (as in Fig. <ref type="figure">6</ref>). As before, the y-axis represents the magnitude of the (second) derivative. Zonotope bounds on the second derivatives are also much more precise at enclosing the sampled   points than standard interval domain bounds, which stems from the fact that relational domains allow us to preserve correlation across derivative orders, thus improving precision.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.3">Lipschitz Certification</head><p>Our second case study involves bounding the local Lipschitz constant of neural networks with respect to semantic perturbations, as in <ref type="bibr">[Laurel et al. 2022a;</ref><ref type="bibr">Yang et al. 2022</ref>]. We study networks trained on MNIST data and consider the Haze perturbation, defined as the pixelwise transformation &#119901; &#120572; (&#119909; &#119894; ; &#120572;) = (1 -&#120572;)&#119909; &#119894; + &#120572;, where &#119909; &#119894; is the value of each pixel and &#120572; represents the haze amount. Let &#119891; denote a neural network. Then, given an image &#119909;, we compute a sound upper bound on the (local) Lipschitz constant of &#119891; (&#119901; &#120572; (&#119909;; &#120572;)) with respect to &#120572; over a range of haze values, specifically where &#120572; lies in [0, &#120572; &#119898;&#119886;&#119909; ]. The parameter &#120572; &#119898;&#119886;&#119909; represents the maximum haze amount, and we consider values of &#120572; &#119898;&#119886;&#119909; &#8712; {10 -&#119896;/4 &#8226; 2 : &#119896; &#8712; [2, 18]}. We evaluate on the zonotope domain (enabled by this work) and compare with <ref type="bibr">Laurel et al. [2022a]</ref> (as no other work can handle this setting).</p><p>Fig. <ref type="figure">8</ref> shows the Lipschitz certification results for the 3-layer (left), 4-layer (center), and 5-layer (right) MNIST networks. Fig. <ref type="figure">8a</ref> presents the computed Lipschitz constant bounds. The x-axis shows the value of &#120572; &#119898;&#119886;&#119909; , and the y-axis shows the upper bound on the Lipschitz constant computed with the zonotope and interval domains (smaller is better). Fig. <ref type="figure">8b</ref> presents the increase in precision of the zonotope domain. The x-axis again shows the value of &#120572; &#119898;&#119886;&#119909; , and the y-axis shows the ratio of the interval-bounded Lipschitz constants over the zonotope-bounded Lipschitz constants (larger is better). For each plot, the x-axis uses a logarithmic scale, while the y-axis uses a linear scale. Each data point is the average over the first 1,000 correctly classified test set images. For the 3-, 4-, and 5-layer networks, the average zonotope runtimes are 2.8, 4.1, and 5.9 milliseconds per image and the average interval runtimes are 2.9, 3.2, and 4.0 milliseconds per image, respectively. These runtimes showcase how our analysis, even when using a precise relational domain, is fast and scalable.</p><p>AD with zonotopes is always more precise than AD with intervals &#347; the zonotope-bounded Lipschitz constants are always smaller. Compared to intervals, zonotopes are up to 6&#215;, 31&#215;, and 216&#215; more precise and the computed Lipschitz constants are up to 3374, 39105, and 382755 smaller for the 3-, 4-, and 5-layer networks, respectively. This showcases how AD with intervals is much more over-approximate for deeper networks, while zonotope AD retains much more precision.</p><p>For each network, we see a similar trend across values of &#120572; &#119898;&#119886;&#119909; . Fig. <ref type="figure">8a</ref> shows that as &#120572; &#119898;&#119886;&#119909; (i.e., the range of perturbation) increases, the absolute difference between the interval-and zonotopebounded Lipschitz constant increases significantly. For small perturbation ranges (when &#120572; &#119898;&#119886;&#119909; &lt; 10 -3 ), the Lipschitz constant between the two domains are similar in magnitude. Fig. <ref type="figure">8b</ref> shows that for small values of &#120572; &#119898;&#119886;&#119909; , both domains are quite precise, since the input range is very small. For large values of &#120572; &#119898;&#119886;&#119909; , both domains incur larger degrees of over-approximation (though intervals are much more over-approximate). This is why the relative increase in precision of zonotopes over intervals is not as great for both ends of the input range. Zonotopes are relatively most precise for an input range that is around 10 -1.5 . The maxima in Fig. <ref type="figure">8b</ref> exactly correspond to the points in Fig. <ref type="figure">8a</ref> where the zonotope curve already asymptotes (i.e., induces little over-approximation), while the interval curve is still very over-approximate. Zonotopes allow us to obtain much tighter bounds on neural networks' Lipschitz constants with respect to semantic perturbations than the previous interval-domain work of <ref type="bibr">Laurel et al. [2022a]</ref>.  Our approach can also scale to larger networks: Fig. <ref type="figure">9</ref> shows the Lipschitz certification results on the FFNNBig architecture. All axes are in log scale for clarity; as before, each data point is the average over the first 1,000 correctly classified test images. The average zonotope and interval runtimes for this experiment are 0.58 and 0.12 seconds per image, respectively. Compared to the interval domain, our zonotope domain construction obtains Lipschitz constants that are up to 11,850&#215; more precise, and the computed Lipschitz constants are up to 4.67 &#215; 10 8 smaller. Again, we can observe that using the more precise zonotope domain (versus just intervals) increases analysis precision significantly for larger networks, highlighting the importance of our analysis.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8">RELATED WORK</head><p>To the best of our knowledge, there is not any work that provides a general construction for abstract interpretation of higher-order AD.</p><p>Higher-Order AD. Higher-order forward-mode AD has been explored going back to <ref type="bibr">Griewank et al. [2000]</ref> and <ref type="bibr">Karczmarczuk [2001]</ref>. <ref type="bibr">Pearlmutter and Siskind [2007]</ref> also proposed a forward-mode scheme; then, later implementations in JAX <ref type="bibr">[Bettencourt et al. 2019]</ref>, &#120582; &#119878; <ref type="bibr">[Sherman et al. 2021]</ref>, and the work of <ref type="bibr">Huot et al. [2021]</ref> also followed in this spirit. In particular, &#120582; &#119878; also supports Clarke Jacobians. However, all of these works only give concrete (and not abstract) semantics for AD. Additionally, unlike our concrete semantics, <ref type="bibr">Huot et al. [2021]</ref>; <ref type="bibr">Karczmarczuk [2001]</ref>; <ref type="bibr">Krawiec et al. [2022]</ref>; <ref type="bibr">Pearlmutter and Siskind [2007]</ref>; <ref type="bibr">Sherman et al. [2021]</ref> all define their concrete semantics in functional styles, whereas we use an imperative semantics (that generalizes Fike and Alonso <ref type="bibr">[2011]</ref>) for ease in building the formalism. Lastly, while we refer to our semantics as propagating tuples of Taylor coefficients, these are technically closer to Tensor coefficients of <ref type="bibr">Griewank and Walther [2008]</ref>, as our tuple coefficients are unscaled by factorial terms.</p><p>Abstract Interpretation of AD. As pointed out in <ref type="bibr">Laurel et al. [2022a]</ref> and <ref type="bibr">Vassiliadis et al. [2016]</ref>, there is very little work on Abstract Interpretation for AD. Most recently, <ref type="bibr">Laurel et al. [2022a]</ref> developed an interval abstract interpretation for bounding Clarke Jacobians; however, they cannot support relational domains or higher derivatives. <ref type="bibr">Jordan and Dimakis [2021]</ref> provide a way to propagate zonotopes through vector-Jacobian products, but their formalism, soundness guarantees, and implementation are only valid for first derivatives. The benefit of their work is that beyond improving precision, by capturing linear dependencies between derivative terms, they can solve linear programming optimization problems defined over the derivative terms in closed form.</p><p>Other works like <ref type="bibr">Vassiliadis et al. [2016]</ref> and <ref type="bibr">Mangal et al. [2020]</ref> use the interval domain to bound AD, but their works cannot use any relational domain (e.g., zonotopes or polyhedra). <ref type="bibr">Deussen [2021]</ref> can abstract higher-order derivatives and in fact use derivatives up to third order for abstract sensitivity analysis (applied to approximate computing); however, like the other works, they are also restricted to only the interval domain. <ref type="bibr">Immler [2018]</ref> develops a solver to bound the solutions of differential equations using interval and zonotope bounds on first and second derivatives. However, all their derivatives are evaluated purely symbolically, and so they make no use of automatic differentiation; thus, their work suffers scalability problems. Despite their derivative computations being purely symbolic, evaluating those symbolic expressions using zonotopes to capture linear dependencies between first and second-order derivative terms does greatly improve the precision of their verified second-order Runge Kutta solver. Also motivated by verified ODE solutions, <ref type="bibr">Bendtsen and Stauning [1996]</ref> and <ref type="bibr">Stauning [1997]</ref> develop a validated AD framework for computing interval arithmetic liftings of the higher-order derivatives needed to compute higher-order Taylor series expansions of the solution to an ODE, but their work is restricted to only the interval domain.</p><p>Meta-Abstract Interpretation. There are a few works which provide meta-abstract interpretations <ref type="bibr">[Cousot et al. 2019;</ref><ref type="bibr">Reps and Thakur 2016;</ref><ref type="bibr">Singh et al. 2018b;</ref><ref type="bibr">Sotoudeh and Thakur 2020]</ref>, meaning they do not propose a new abstract domain, but rather a new construction that can be instantiated with different abstract domains. However, none of these works target AD. Additionally, there are techniques to automate the construction of transformers for a variety of numerical abstract domains <ref type="bibr">[Min&#233; 2006</ref>], but the precision and scalability of these transformers are usually suboptimal.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="9">CONCLUSION</head><p>We developed the first general construction for abstract interpretation of automatic differentiation that supports both higher-order derivatives and virtually any numerical abstract domain. We instantiate our method with both intervals and zonotopes, and in the latter case, we show how to relationally leverage dependencies across derivatives to further improve precision. Our evaluation demonstrates the applicability and scalability of our technique.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_0"><p>Proc. ACM Program. Lang., Vol. 6, No. OOPSLA2, Article 161. Publication date: October 2022.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>) &#8712;R 2 and Proc. ACM Program. Lang., Vol. 6, No. OOPSLA2, Article 161. Publication date: October 2022.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_2"><p>Received 2022-04-15; accepted 2022-09-01 Proc. ACM Program. Lang., Vol. 6, No. OOPSLA2, Article 161. Publication date: October 2022.</p></note>
		</body>
		</text>
</TEI>
