<?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 dual number abstraction for static analysis of Clarke Jacobians</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>01/16/2022</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10319480</idno>
					<idno type="doi">10.1145/3498718</idno>
					<title level='j'>Proceedings of the ACM on Programming Languages</title>
<idno>2475-1421</idno>
<biblScope unit="volume">6</biblScope>
<biblScope unit="issue">POPL</biblScope>					

					<author>Jacob Laurel</author><author>Rem Yang</author><author>Gagandeep Singh</author><author>Sasa Misailovic</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[We present a novel abstraction for bounding the Clarke Jacobian of a Lipschitz continuous, but not necessarily differentiable function over a local input region. To do so, we leverage a novel abstract domain built upon dual numbers, adapted to soundly over-approximate all first derivatives needed to compute the Clarke Jacobian. We formally prove that our novel forward-mode dual interval evaluation produces a sound, interval domain-based over-approximation of the true Clarke Jacobian for a given input region.            Due to the generality of our formalism, we can compute and analyze interval Clarke Jacobians for a broader class of functions than previous works supported – specifically, arbitrary compositions of neural networks with Lipschitz, but non-differentiable perturbations. We implement our technique in a tool called DeepJ and evaluate it on multiple deep neural networks and non-differentiable input perturbations to showcase both the generality and scalability of our analysis. Concretely, we can obtain interval Clarke Jacobians to analyze Lipschitz robustness and local optimization landscapes of both fully-connected and convolutional neural networks for rotational, contrast variation, and haze perturbations, as well as their compositions.]]></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 growing adoption of machine learning (ML) models in several safetycritical domains, including autonomous driving <ref type="bibr">[Bojarski et al. 2016]</ref> and healthcare <ref type="bibr">[Esteva et al. 2019</ref>]. The first derivatives specified via the Jacobian matrix are the backbone of many prominent learning paradigms and are used in all facets of the machine learning pipeline, from training to testing. Automatic Differentiation (AD), and more broadly, Differentiable Programming, have been developed to offer a principled, language-based method of compositionally computing derivatives. However, the needs of ML researchers have rapidly outpaced formal development on the programming languages side. For instance, ML techniques regularly must differentiate through functions that may have points of non-differentiability, such as the commonly used ReLU activation in neural networks, which is not differentiable at 0. In practice, for such a situation, existing AD frameworks just return any arbitrary number in the interval [0, 1]. While such an ad-hoc approach may suffice in many practical scenarios, for critical domains requiring formal certification of properties defined over the first derivatives, this lack of rigor is troubling. To resolve this limitation, programming language researchers have begun using generalizations of the Jacobian for describing AD semantics <ref type="bibr">[Sherman et al. 2021]</ref>, such as the Clarke Generalized Jacobian <ref type="bibr">[Clarke 1990</ref>] for non-smooth, but Lipschitz continuous functions.</p><p>However, these developments still cannot provide the desired formal guarantees for practical verification tasks, such as obtaining formal bounds on the Lipschitz constant (which measures how rapidly a function's output changes) of the composition of a non-differentiable perturbation and a differentiable network within an input region. Lipschitz constants can be used as a metric to compare the stability and smoothness of the output of neural networks prior to deployment, as a network with a smaller constant is often preferable <ref type="bibr">[Lin et al. 2019]</ref>. Formal bounds on the Lipschitz constant can also be used during training to learn classifiers that are certifiably robust to adversarial perturbations <ref type="bibr">[Tsuzuku et al. 2018]</ref>, robust to quantizations <ref type="bibr">[Lin et al. 2019]</ref>, or to improve interpretability by making network explanations themselves more robust <ref type="bibr">[Alvarez-Melis and Jaakkola 2018]</ref>. Further, analyzing the Lipschitz constant has direct applications in algorithmic fairness <ref type="bibr">[Dwork et al. 2012</ref>] and differential privacy <ref type="bibr">[Dwork et al. 2006]</ref>, where fairness and privacy are established by certifying a small Lipschitz constant. Beyond using the Jacobian for formally bounding Lipschitz constants, a Jacobian analysis can also be used to formally reason about the local geometry of ML models <ref type="bibr">[Zhang et al. 2019</ref>], which has applications in explainability, e.g., why a network works well for certain inputs but not for others.</p><p>Challenges. We focus on designing a static analysis that can formally reason about not only Jacobians of functions that are differentiable (e.g., tanh), but can also handle non-differentiable behavior due to functions like ReLU and the branching that can arise in differentiable programs. Furthermore, we must also handle high-dimensional computational graphs with arbitrary arithmetic (instead of, e.g., solely neural networks that avoid non-scalar multiplication and division). Simultaneously handling all of these requires a theoretical formalism that is beyond the scope of the existing works <ref type="bibr">[Edalat and Maleki 2017;</ref><ref type="bibr">Jordan and Dimakis 2020;</ref><ref type="bibr">Mangal et al. 2020;</ref><ref type="bibr">Zhang et al. 2019]</ref>. One of the main difficulties arises from the fact that generalized notions of Jacobians do not always obey the same rules as classical Jacobians. For example, the Clarke Jacobian cannot simply be computed by concatenating partial Clarke derivatives into a matrix <ref type="bibr">[Clarke 1990;</ref><ref type="bibr">Khan and Barton 2013]</ref>. In this same light, we want our desired generality to also come with compositionality: we want to be able to combine different functions together instead of restricting ourselves to a non-compositional analysis limited to a specific, fixed type of function (e.g., a DNN) or input perturbation. More practically, we want this analysis to be scalable and fully end-to-end, specifically for real-world problems such as analyzing Lipschitz robustness with respect to multiple input perturbations. This has proven challenging, as most formalisms that aim for broad theoretical generality cannot scale beyond toy examples <ref type="bibr">[Di Gianantonio and Edalat 2013]</ref>, do not have implementations <ref type="bibr">[Edalat and Lieutier 2004;</ref><ref type="bibr">Edalat et al. 2013;</ref><ref type="bibr">Edalat and</ref><ref type="bibr">Maleki 2017, 2018]</ref>, or lack end-to-end integration with specific analyses for practical problems. Moreover, the Lipschitz robustness analyses that go beyond toy examples, such as RecurJac <ref type="bibr">[Zhang et al. 2019]</ref> and ProLip <ref type="bibr">[Mangal et al. 2020]</ref>, are either tailored for handling fully-connected architectures (like RecurJac) and therefore cannot immediately analyze the state-of-the-art convolutional architectures, or are heavily restricted in the activation functions supported (like ProLip). These issues substantially limit the practical applicability of these tools.</p><p>Results. We implement DeepJ and evaluate it on two tasks:</p><p>&#8226; Lipschitz Robustness: Certifies bounds on the local Lipschitz constant of a given input region.</p><p>&#8226; Local Optimization Landscape: Uses the Clarke Jacobian to analyze a function's local geometry in a specified input region to determine the absence of stationary points. We apply DeepJ to neural networks with both fully-connected and convolutional layers that are trained on the CIFAR10 <ref type="bibr">[Krizhevsky et al. 2009]</ref> and <ref type="bibr">MNIST [LeCun et al. 1998</ref>] datasets. For each of our analyses, we compose the neural networks with three perturbation functions: haze (which models images as foggy), contrast variation (which accentuates the differences between bright and dark pixels), and rotation (which rotates the image by a specified angle &#120579; with bilinear interpolation). Analyzing the Jacobian of a network with respect to these perturbations is out of reach of the existing techniques.</p><p>For each perturbation, DeepJ is able to leverage its fully localized analysis, which computes Clarke Jacobians solely for the specified input region, to obtain local Lipschitz constants that can be up to several orders of magnitude smaller than a baseline analysis based on <ref type="bibr">Gouk et al. [2021]</ref> (which multiplies a network's global Lipschitz constant by the perturbation's local Lipschitz constant instead of being fully localized). DeepJ can also extend the analysis to compositions of multiple perturbations. Furthermore, the localized Jacobian analysis can certify the absence of stationary points in a network's optimization landscape. DeepJ's parallel CPU-based implementation is efficient: it can precisely analyze 100 CIFAR10 images on our largest convolutional network containing &gt; 62K neurons within a median time of 15 seconds each for haze and contrast variations, and under 1.4 minutes for rotation. It can also compute precise results for 10 CIFAR10 images on the same network within a median time of 9 seconds for contrast variation composed with haze, and under 51 seconds for contrast variation or haze composed with rotation. Our largest network has the same architecture as the one commonly handled by state-of-the-art CPU-based robustness verifiers <ref type="bibr">[Singh et al. 2018</ref><ref type="bibr">[Singh et al. , 2019;;</ref><ref type="bibr">Urban and Min&#233; 2021</ref>]. The differences in the computed constants between the DeepJ versions with and without sound floating-point rounding are negligible, with 2.8-4.1x execution time overhead for the sound version.</p><p>Contributions. This paper makes the following main contributions:</p><p>(1) A new dual number-based interval abstraction for analyzing Clarke Jacobians. Our domain soundly over-approximates the Clarke Generalized Jacobian of locally Lipschitz and piecewise differentiable functions, allowing it to soundly handle functions like max, ReLU, and limited branches. Furthermore, as our abstraction is defined for sets of points, we can analyze local properties of locally Lipschitz functions beyond the scope of prior work. (2) A novel Clarke Jacobian analysis and Lipschitz certification of neural networks composed with non-differentiable perturbations. (3) A scalable, optionally floating-point sound, implementation of our method which supports both convolutional and fully-connected neural networks. (4) An extensive evaluation against multiple perturbation types on several deep neural networks, showing that DeepJ can (a) achieve orders of magnitude tighter bounds on local Lipschitz constants compared to a baseline analysis and (b) certify the absence of stationary points within a given input region.</p><p>DeepJ is available at <ref type="url">https://github.com/uiuc-arc/DeepJ</ref>. Our implementation exploits CPU-level parallelism. We believe that DeepJ can be easily parallelized over GPUs to boost the scalability to even larger architectures, such as those considered by GPU-based verifiers <ref type="bibr">[M&#252;ller et al. 2021</ref>]. The GPU extension of DeepJ may help train networks to be robust to semantic non-differentiable perturbations like rotation and contrast variation, which is beyond the reach of existing robust training methods <ref type="bibr">[Balunovi&#263; et al. 2019;</ref><ref type="bibr">Mirman et al. 2018</ref><ref type="bibr">Mirman et al. , 2019;;</ref><ref type="bibr">Zhang et al. 2021</ref><ref type="bibr">Zhang et al. , 2020]]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">OVERVIEW</head><p>In this section, we start with a small illustrative example that showcases a real-world use of our abstraction for a scenario not handled by any prior work.</p><p>Running Example: Contrast Variation Perturbation. We consider the simple fully-connected network shown in Fig. <ref type="figure">1</ref>. For simplicity, the network takes two inputs in the input layer, and we assume the network has been fully trained. The network contains a single hidden layer and all activation functions in both the hidden and output layers are tanh (with no biases). Most importantly, we compose the network with a perturbation function modeling contrast variation. We are interested in knowing precisely how sensitive the network's outputs are to inputs that are perturbed by contrast variation, which often arises when the image passed to a network was obtained with a fixed aperture lens <ref type="bibr">[Paterson et al. 2021</ref>]. Hence, instead of passing input image pixels &#119909; 1 and &#119909; 2 directly into the input layer, we pass their perturbed values, &#119909; &#8242; 1 and &#119909; &#8242; 2 . The contrast variation</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Input Layer Contrast Variation Perturbation</head><p>Hidden Layer Output Layer tanh tanh Fig. <ref type="figure">1</ref>. Composition of a Neural Network with the Contrast Variation Perturbation perturbation for a pixel &#119909; &#119894; is given in <ref type="bibr">Paterson et al. [2021]</ref> as</p><p>where &#120572; specifies the amount of contrast variation. We apply this perturbation to every input pixel (there are only two in this example). We can thus think of the perturbation as a function of the perturbation parameter &#120572;.</p><p>Jacobian Analysis. We will measure the sensitivity of the network with respect to the perturbation by computing the Jacobian of the composition of the network with the perturbation. This allows us to analyze how sensitive and robust the network's outputs are with respect to a change in &#120572; in some local region. For this example, the local region we are interested in is when &#120572; &#8712;[0, 0.1]. This allows us to analyze what happens when the amount of perturbation ranges from none up to a modest amount. Because of the combination of both non-differentiable (max and min) and differentiable (tanh) functions, as well as the division in the perturbation function, computing a Jacobian for the composition of the network and the perturbation is beyond the capabilities of existing frameworks.</p><p>Abstract Domain. To perform the analysis, we need to compute bounds on the Jacobian of the composition of the network and the perturbation. However, this is complicated by the fact that (a) we cannot settle for the derivatives at a single point (as standard automatic differentiation gives) and instead need a bound on the derivatives for an entire input region, (b) max and min are Lipschitz, but not differentiable, thus we need a more general notion of differentiation that works for such functions, and (c) the analysis cannot be restricted to only neural networks, since it needs to be able to compositionally handle arbitrary combinations of functions. As mentioned, prior work cannot address these challenges, thus our solution necessitates a novel abstract domain. The full formalism is described in Sections 5 and 6. Our abstract domain associates to each variable an interval bounding the variable itself and an interval bounding that variable's Clarke derivative via a dual interval of the form [&#119886;, &#119887;] + [&#119888;, &#119889;]&#120598;, where &#119886;, &#119887;, &#119888;, &#119889; &#8712; R &#8746; {&#177;&#8734;}, &#119886; &#8804; &#119887; and &#119888; &#8804; &#119889;. We will call [&#119886;, &#119887;] the real part and [&#119888;, &#119889;] the dual part. Dual intervals are an adapted interval-domain abstraction of the canonical dual numbers of forward-mode automatic differentiation. The key benefit of this approach is that we can leverage an existing numerical system to track derivatives instead of relying on non-extensible, ad-hoc approaches as in <ref type="bibr">Edalat et al. [2013]</ref>; <ref type="bibr">Mangal et al. [2020]</ref>; <ref type="bibr">Zhang et al. [2019]</ref>. However, a naive adaptation is not sufficient, as one still has to contend with non-differentiable functions like max. Furthermore, all primitive operations must be reinterpreted for dual interval arithmetic.</p><p>Abstract Interpretation of the Perturbation and Network. We now step through the abstract interpretation of the composition of the neural network and the contrast variation perturbation, which  is detailed in Fig. <ref type="figure">2</ref>. As every term in the abstract domain must be a dual interval, to perform the analysis, we first must lift the constant edge weights &#119908; &#119894; to dual intervals of the form [&#119908; &#119894; , &#119908; &#119894; ] + [0, 0]&#120598;, as shown in Fig. <ref type="figure">2</ref>. Upon lifting all constants and edge weights to the abstract domain, we start from the inputs &#119909; 1 , &#119909; 2 and the perturbation parameter &#120572;. As our goal is to compute the sensitivity solely with respect to &#120572;, we set its dual part to [1, 1]&#120598;. This means that we treat &#119909; 1 and &#119909; 2 as constant; since we do not need to compute derivatives with respect to &#119909; 1 and &#119909; 2 , the analysis sets their dual part to [0, 0]&#120598;. Furthermore, as &#119909; 1 and &#119909; 2 are pixel values of some fixed image, their real parts are just the degenerate interval of their pixel intensities: [0.95, 0.95] and [0.2, 0.2], respectively.</p><p>We begin by propagating the dual interval inputs through the contrast variation perturbation function in Eq. 1. This requires that all arithmetic operations (+, -, &#8226;, /) and function primitives (min and max) be redefined for dual intervals. Section 6 presents a full formalization of dual intervals.</p><p>For each pixel &#119909; &#119894; , we first compute &#119909; &#119894; -0.5&#8226;&#120572; 1-&#120572; inside the min function. Though not shown in the function, the constants 0.5 and 1 are actually interpreted as the dual intervals [0.5, 0.5] + [0, 0]&#120598; and [1, 1] + [0, 0]&#120598;, respectively. The numerator &#119909; 1 -0.5&#8226;&#120572; abstractly evaluates to [0.9, 0.95] + [-0.5, -0.5]&#120598; and likewise &#119909; 2 -0.5 &#8226; &#120572; evaluates to [0.15, 0.2] + [-0.5, -0.5]&#120598;. These follow from the rules of dual interval arithmetic: scaling by a constant scales a term's real and dual part, and dual interval addition between terms adds their respective real and dual components. Therefore, we have implicitly encoded the notion of linearity of the derivative.</p><p>To compute the entire quotient for each variable, we next perform dual interval division (described in Section 6.1). The terms &#119909; 1 -0.5&#8226;&#120572; 1-&#120572; and &#119909; 2 -0.5&#8226;&#120572; 1-&#120572; ultimately evaluate to [0.9, 1.05]+[0.4, 0.62]&#120598; and [0.15, 0.22] + [-0.43, -0.25]&#120598;, respectively. Dual interval division implicitly encodes the quotient rule of differentiation.</p><p>Non-Differentiable Functions. Upon computing &#119909; 1 -0.5&#8226;&#120572; 1-&#120572; and &#119909; 2 -0.5&#8226;&#120572; 1-&#120572; , we now must take the min of each with [1, 1] + [0, 0]&#120598;. This is highly challenging as min is not differentiable. To resolve this, we must use a more general notion of differentiation, specifically the Clarke Jacobian <ref type="bibr">[Clarke 1990</ref>], which has also recently emerged in the programming languages literature <ref type="bibr">[Di Gianantonio and Edalat 2013;</ref><ref type="bibr">Sherman et al. 2021</ref>]. The Clarke Jacobian can compute a generalized derivative for non-differentiable, but Lipschitz functions like min, max, ReLU, abs, and even functions defined by conditional branching statements (provided one proves such functions are continuous and piecewise differentiable). The Clarke Jacobian does so by returning a convex set of points as the "derivative" instead of just a single point. To perform the Clarke differentiation through the min function, one takes the standard derivative of whichever of the min function's two arguments attains the minimum. The caveat is that if both arguments attain the minimum, one must take the convex hull of both arguments' derivatives. However, this becomes even more difficult for the interval domain, as due to the inherent uncertainty when two intervals overlap, it is possible that either could attain the minimum. Thus, if the real parts of two dual intervals overlap, our analysis must take the convex hull of their respective dual parts.</p><p>Recall that for &#119909; 1 we must take the min of [1, 1] + [0, 0]&#120598; and &#119909; 1 -0.5&#8226;&#120572; 1-&#120572; =[0.9, 1.05]+[0.4, 0.62]&#120598;. In this case, the real parts overlap, so we must take the convex hull (denoted by co) of their respective dual parts: [0, 0] and [0.4, 0.62], as shown in Eq. 2.</p><p>min 1,</p><p>For &#119909; 2 , when computing the min of [1, 1] + [0, 0]&#120598; and &#119909; 2 -0.5 Finally, as the contrast variation perturbation is also composed with the max function, we must repeat the same procedure, albeit with max instead of min. For &#119909; 1 and &#119909; 2 , we compute: The dual part of the result is also multiplied by the dual part of the input ([-0.43, 0.37]), implicitly encoding the chain rule. In this example, &#119891; 3 evaluates to [0.78, 0.84] + [-0.17, 0.14]&#120598;. Likewise for &#119891; 4 , the input to the tanh function is the sum of &#119909; &#8242; 1 and &#119909; &#8242; 2 scaled by the edge weights, which is just [0.67, 0.85] + [0.25, 1.05]&#120598;. Hence, &#119891; 4 evaluates to [0.59, 0.69] + [0.13, 0.68]&#120598;. As our analysis is fully compositional, we easily repeat this procedure for the subsequent (final) layer. Multiplying &#119891; 3 and &#119891; 4 by their respective edge weights, then passing these values to the tanh activations, allows us to determine that &#119891; 5 =[0.88, 0.91]+[-0.01, 0.19] &#120598; and &#119891; 6 =[0.09, 0.24]+[-0.84, 0.012]&#120598;.</p><p>Interval Clarke Jacobian. Upon computing the outputs &#119891; 5 and &#119891; 6 , we take their dual parts as the Interval Clarke Jacobian. This is because we show in Section 6.3 that abstractly evaluating functions with dual intervals is equivalent to computing the Interval Clarke Jacobian, which in turn soundly over-approximates the true Clarke Jacobian. Since we are modeling the composition of the network and the perturbation as a function of only &#120572; (while holding all other inputs fixed), the Interval Clarke Jacobian is a 2 &#215; 1 interval matrix, as the network has 2 outputs. In this case, it is [[-0.01, 0.19],[-0.84, 0.012]] &#119879; . Practical Applications. Upon computing this over-approximation of the Clarke Jacobian, we can use it for several practical applications. For instance, we can compute the local Lipschitz constant in the region &#120572; &#8712; [0, 0.1] by taking the maximum norm of the Interval Clarke Jacobian, which intuitively gives us a point summary of the network's sensitivity to perturbations by &#120572; in this local region. For this example, the Lipschitz constant (with respect to the &#8467; &#8734; -norm) evaluates to 0.84.</p><p>We can also use the over-approximation of the Clarke Jacobian to analyze the local landscape of the composition of the network and the perturbation for stationary points. If a point is a local extremum, then the Clarke Jacobian at that point contains 0. Therefore, if any entry of the Interval Clarke Jacobian does not contain 0, it certifies that no point in the input range is a local extremum. In this example, as both entries contain 0, the analysis determines that the input region &#120572; &#8712; [0, 0.1] could still contain a local extremum.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">PRELIMINARIES</head><p>We define all the mathematical preliminaries needed to describe automatic differentiation, as well as the Clarke Jacobian. We start with the definition of the standard Jacobian.</p><p>Definition 3.1. The Jacobian of a function &#119891; :</p><p>When &#119898; = &#119899; = 1, the Jacobian is merely the classical derivative: J(&#119891; , x 0 ) = &#119889; &#119891; &#119889;&#119909; | &#119909;=x 0 . Dual Numbers. The question then arises, how do we automatically compute this Jacobian? The most popular method is via Automatic Differentiation, or AD. AD has two modes: reverse and forward. The former recursively evaluates derivatives of sub-expressions, and can be thought of as a generalization of backpropagation. We focus on the latter, as forward-mode automatic differentiation is much easier to implement and excels when the function's input dimension is small (as will be in our use cases). To implement forward-mode automatic differentiation, one may overload all primitive arithmetic operations to work on dual numbers, which we now describe. Definition 3.2. Dual numbers are numbers of the form &#119886; + &#119887;&#120598;, where &#119886;, &#119887; &#8712; R and &#120598; is a symbolic variable (akin to &#119894; for imaginary numbers). We denote the set of all dual numbers as D. Dual number arithmetic is given by the following rules:</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&#120598;</head><p>The above arithmetic rules for dual numbers implicitly encode linearity, the product rule, and the quotient rule in the computation of their dual part. To access the real part of a dual number, we write fst(&#119886; +&#119887;&#120598;) = &#119886;, and likewise the dual part is accessed by snd(&#119886; +&#119887;&#120598;) = &#119887;. For any differentiable function &#119891; : R &#8594; R, we use the standard lifting of &#119891; to dual numbers &#119891; : D &#8594; D given as</p><p>Therefore, the dual part of a dual number corresponds to the value of the function's derivative evaluated at the real part, &#119886;. Further, multiplying the derivative &#119891; &#8242; (&#119886;) by the existing dual part &#119887; implicitly encodes the chain rule of calculus.</p><p>A Dual Number Abstraction for Static Analysis of Clarke Jacobians 56:9</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Lipschitz Continuity</head><p>We subsequently show how to extend the previous concepts to non-differentiable but locally Lipschitz functions. Hence, we first define the local Lipschitz property.</p><p>where &#8741; &#8226; &#8741; &#120572; and &#8741; &#8226; &#8741; &#120573; are arbitrary &#119901;-norms over R &#119898; and R &#119899; , respectively. Furthermore, if for a given point &#119909; 0 &#8712; R &#119898; , there exists a positive real &#120575; &gt; 0 such that &#119891; is locally Lipschitz within a ball of radius &#120575; centered at &#119909; 0 , we say &#119891; is Lipschitz near &#119909; 0 .</p><p>Lipschitz Constant. The constant &#119870; &#120572;,&#120573; is called the (local) Lipschitz constant, which provides a formal bound on how much a function's output can change (measured by the &#8741; &#8226; &#8741; &#120573; norm) given a change in input (measured by the &#8741; &#8226; &#8741; &#120572; norm). The constant can easily be obtained once one has the Jacobian J. For a Lipschitz function &#119891; : R &#119898; &#8594; R &#119899; that is differentiable, one can compute the local Lipschitz constant on a region &#119883; by taking the maximum dual norm of the Jacobian over &#119883; :</p><p>where the dual norm of any matrix &#119872; &#8712; R &#119899;&#215;&#119898; is given as &#8741;&#119872; &#8741; &#120572;,&#120573; = sup &#8741;&#119907; &#8741; &#120572; &#8804;1 &#8741;&#119872;&#119907; &#8741; &#120573; . For common values of &#120572; and &#120573;, there is a closed-form expression for &#8741;&#119872; &#8741; &#120572;,&#120573; . For instance, &#8741;&#119872; &#8741; 1,1 = max 1&#8804; &#119895; &#8804;&#119898; ( &#119899; &#119894;=1 |&#119872; &#119894;,&#119895; |), thus we simply take the norm of the Jacobian (over all points in &#119883; ) that has the maximum absolute column sum.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">Clarke Generalized Jacobian</head><p>However, the following question arises: what if we need to compute the derivative at a point where it is not defined, such as ReLU(&#119909;) at &#119909; = 0? Can one extend Jacobians (and methods to compute them) to non-differentiable functions? We follow recent work by <ref type="bibr">Sherman et al. [2021]</ref> and employ the notion of the Clarke Generalized Jacobian <ref type="bibr">[Clarke 1990</ref>] for this extension. Intuitively, this generalizes the notion of a Jacobian to non-differentiable, but still Lipschitz continuous functions.</p><p>Convexity. The Clarke Jacobian of a function &#119891; : R &#119898; &#8594; R &#119899; evaluates to a convex set of &#119899; &#215; &#119898; matrices, hence we define the following operators. Let Co(R &#119899;&#215;&#119898; ) denote all convex sets of &#119899; &#215; &#119898; real matrices. Further, let co : P (R &#119899;&#215;&#119898; ) &#8594; Co(R &#119899;&#215;&#119898; ) be the convex hull operator, which given a set of matrices, takes their convex hull. We can now define the Clarke Generalized Jacobian. Definition 3.4. <ref type="bibr">(Clarke Thm. 2.5</ref>.1 <ref type="bibr">[Clarke 1990</ref>]) Let &#119891; : R &#119898; &#8594; R &#119899; be a function that is locally Lipschitz at x 0 &#8712; R &#119898; , where the set of non-differentiable points of &#119891; has Lebesgue measure 0 (we denote that set as &#119878; &#8834; R &#119898; ). The Clarke Generalized Jacobian of &#119891; at the point x 0 is denoted with the following signature</p><p>, and is given as:</p><p>We first detail this definition when x 0 is a point of non-differentiability of &#119891; . Intuitively, since we cannot compute the actual Jacobian J at a point of non-differentiability, we instead take any sequence of points that converges to that point of non-differentiability, such that the Jacobian is defined for all points in that sequence; we then compute what the Jacobians evaluated at those points in the sequence converge to. The Clarke Jacobian is then just the convex hull over all such sequences' respective limiting Jacobians. Thus, we obtain a convex set of matrices. When the function is differentiable at the point x 0 , this limit reduces to exactly the standard Jacobian at x 0 (and the convex hull becomes superfluous), hence &#120597; &#119888; (&#119891; , x 0 ) will be a singleton set containing exactly J(&#119891; , x 0 ).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">LANGUAGE SYNTAX AND SEMANTICS</head><p>We describe our differentiable programming language, which is based upon &#120582; &#119878; <ref type="bibr">[Sherman et al. 2021]</ref> but with additional branching primitives. Our language is first-order and purely functional (no side-effects), yet expressive enough to encode neural networks and locally Lipschitz perturbations.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Syntax</head><p>Figure <ref type="figure">3</ref> presents the syntax of the language. DeepJ syntactically supports standard arithmetic operations, differentiable function primitives, and limited branching for encoding Lipschitz but non-differentiable functions like min and max. One can encode neural networks in DeepJ; however, instead of encoding them as a series of edge-weight matrix multiplications, our syntax constructs them inductively via compositions: &#8226;, Cartesian products: &#215;, and branching (e.g., for ReLU networks).</p><p>Arithmetic Operations. We support all of the key arithmetic primitives: addition, multiplication, and division. While syntactically speaking, these are only defined for functions of a single output variable, one can easily encode multi-variable versions (e.g., vector addition) by also making use of the Cartesian product, &#215;, where</p><p>Differentiable Functions. Syntactically, we support as primitives all the standard primitive differentiable functions (e.g., &#119890; &#119909; , sin(&#119909;), tanh(&#119909;), etc.). Hence, we denote these as &#119862; 1 because each function is &#119862; 1 -smooth, meaning the function is continuous and differentiable everywhere on its domain, and the first derivative is also continuous everywhere on its domain.</p><p>Non-differentiable, Lipschitz Functions. We support a branching primitive, &#119891; 0 &gt; 0 ? &#119891; 1 : &#119891; 2 , to implement Lipschitz, but not necessarily differentiable functions such as abs, ReLU, min, and max (and by extension max-pooling). For example, abs can be implemented as &#119909; &gt; 0 ? &#119909; : -&#119909;. However, one could easily define a discontinuous function such as &#119909; &gt; 0 ? 1 : 0 using our syntax. Thus, for the computed Jacobian (and by extension Lipschitz constant) to be semantically meaningful and valid, we restrict the type of branching we support. We will later show that checking for these restrictions is undecidable in Section 4.2, and thus the responsibility of ensuring that the restrictions are satisfied rests upon the programmer or an (incomplete) program analysis. Lastly, even though we restrict the type of branches we support, more complex branches with arbitrary Boolean predicates can be systematically desugared into simpler ones. For example, the branch &#119888; 1 &lt; &#119909; &#8743; &#119909; &lt; &#119888; 2 ? &#119891; 1 : &#119891; 2 can be desugared into &#119888; 1 &lt; &#119909; ? &#119909; &lt; &#119888; 2 ? &#119891; 1 : &#119891; 2 : &#119891; 2 . Disjunctions and negations of Booleans can be encoded similarly.</p><p>Type System. As our language only employs real-valued functions, the typing rules for a function are simple and based on standard real-valued arithmetic. For instance, when adding two functions, their dimensions must agree. Likewise, when dividing by a function &#119891; 1 (as in 1/&#119891; 1 ), the output dimension of the function &#119891; 1 must be 1. The full typing rules can be seen in Fig. <ref type="figure">3</ref>, where &#915; corresponds to the typing context that maps all arithmetic expressions (including intermediate ones) to their types.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Standard Interpretation</head><p>As our language is an augmented differentiable programming language, the semantic interpretation of a function &#119891; is its derivative, which in our case corresponds to its Clarke Generalized Jacobian &#120597; &#119888; (&#119891; , &#8226;). Our language is inspired by <ref type="bibr">Sherman et al. [2021]</ref>, hence we follow their convention of lifting the Clarke Jacobian to become a total function by defining the result to be &#8868; whenever &#120597; &#119888; would be undefined, such as trying to evaluate the Clarke Jacobian of log(&#119909;) at &#119909; = 0. Because of this, &#8868; corresponds to the entire space of all real &#119899; &#215; &#119898; matrices (R &#119899;&#215;&#119898; ).</p><p>The semantic rules for recursively defining the Clarke Generalized Jacobian of each language primitive are shown in Figure <ref type="figure">4</ref>. Unlike the regular Jacobian, these rules use &#8838; instead of equality. This means that the exact Clarke Jacobian is not computable; however, our end goal is to compute a sound over-approximation.</p><p>Convex Arithmetic Operations. We denote + &#119888; : Co(R &#119899;&#215;&#119898; ) &#215; Co(R &#119899;&#215;&#119898; ) &#8594; Co(R &#119899;&#215;&#119898; ) to be the addition of two convex sets (Minkowksi addition), where &#119860; + &#119888; &#119861; = {&#119886; + &#119887; : &#119886; &#8712; &#119860;, &#119887; &#8712; &#119861;}. Likewise, we denote</p><p>&#119907; &#8226; &#119886; : &#119886; &#8712; &#119860;} to be convex scalar multiplication and division, respectively. Lastly, as mentioned, we let co : P (R &#119899;&#215;&#119898; ) &#8594; Co(R &#119899;&#215;&#119898; ) be the convex hull operator that takes the convex hull of a set of matrices. We now detail the rules of Fig. <ref type="figure">4</ref>.</p><p>Variables and Constants. The Clarke Jacobian of a single variable &#119909; &#119894; is {1}, but if we compute it with respect to x 0 &#8712; R &#119898; , the Clarke Jacobian will be &#119898;-dimensional, hence denoted as {e &#119894; }, where the &#119894; &#119905;&#8462; entry of e &#119894; is 1 and all other &#119898; -1 entries are 0. Equivalently, &#119891; &#8796; &#119909; &#119894; can be thought of as a projection function going from R &#119898; &#8594; R that takes the &#119894; &#119905;&#8462; component of x 0 . Similarly, the Clarke Jacobian of any constant is just the vector of &#119898; zeroes, denoted as {0}.</p><p>Cartesian Product. The Clarke Jacobian of the Cartesian product of two functions (defined over the same input) is a subset of the matrix concatenation of each function's respective Clarke Jacobians. This follows directly from proposition 2.6.2 (e) of <ref type="bibr">Clarke [1990]</ref>.</p><p>Addition. The Clarke Jacobian does not obey exact linearity; however, the Clarke Jacobian of the sum of two functions is contained in the Minkowski sum of each function's respective Clarke Jacobian. This rule follows directly from Proposition 2.3.3 of <ref type="bibr">Clarke [1990]</ref>.</p><p>Multiplication and Division. The Clarke Jacobian follows both a product and quotient rule, but as with the other rules, the relationship is of containment instead of strict equality. These follow directly from Propositions 2.3.13 and 2.3.14 of <ref type="bibr">Clarke [1990]</ref>.</p><p>Composition. To ensure our language is fully compositional, we can exploit the fact that the Clarke Jacobian follows a chain rule, when the outermost function is &#119862; 1 -smooth. This result follows directly from Theorems 2.3.9 and 2.6.6 of <ref type="bibr">Clarke [1990]</ref>.</p><p>&#119862; 1 Functions. For the &#119862; 1 primitive functions, the Clarke Jacobian reduces to the standard Jacobian J(&#119862; 1 , &#8226;). Furthermore, one can catch erroneous behavior by leveraging knowledge about the known domain of each &#119862; 1 primitive function. For instance, if one tries to evaluate &#120597; &#119888; (sqrt(-&#119877;&#119890;&#119871;&#119880; (&#119909; &#119894; )), 1), this would require evaluating J(sqrt, -1). However, since -1 lies outside the domain of sqrt, this result is undefined; thus, the expression will evaluate to &#8868;, and errors will be caught at this step. One can then propagate &#8868; up the remainder of a function's expression tree, since all other rules in Fig. <ref type="figure">4</ref> first check if any sub-expression evaluates to &#8868; (in which case they will also evaluate to &#8868;).</p><p>Branching. Branching is absent in Clarke's original formulation. Furthermore, &#120582; &#119878; <ref type="bibr">[Sherman et al. 2021</ref>] and Di Gianantonio and <ref type="bibr">Edalat [2013]</ref> also do not support a branching primitive. This is because a branch can introduce the possibility of encoding a discontinuous function, such as &#119891; (&#119909;) = &#119909; &gt; 0 ? 1 : 0. As a branch can be thought of as "splitting" a function into two separate pieces, we need to ensure that the entire function is still locally Lipschitz continuous (on the region of interest containing x 0 ) for it to have a well-defined Clarke Jacobian at x 0 . Thus, to formally establish the necessary conditions for the well-definedness of the Clarke Jacobian of a branching function, we use results from the theory of piecewise differentiable functions [Khan and Barton 2013; <ref type="bibr">Scholtes 2012]</ref>. We first state a useful lemma. Lemma 4.1. Let &#119891; : R &#119898; &#8594; R &#119899; be a function expressible using the syntax of Figure <ref type="figure">3</ref> that does not contain branches. For any x 0 where J(&#119891; , x 0 ) is defined, we have that &#120597; &#119888; (&#119891; , x 0 ) = {J(&#119891; , x 0 )}.</p><p>Proof. (Sketch) Since a function that does not have branches is a constant or only uses addition, composition with a &#119862; 1 function, multiplication, division, or the Cartesian product, one can directly compute J(&#119891; , x 0 ) using linearity, chain rule, product or quotient rule, or the direct computation of the derivative (for &#119862; 1 functions and constants), provided J(&#119891; , x 0 ) is well-defined (e.g., there is no division by 0). Furthermore, by Proposition 2.2.4 of Clarke <ref type="bibr">[Clarke 1990</ref>], if a function has a well-defined Jacobian at a point, the Clarke Jacobian reduces to that value.</p><p>&#9633;</p><p>We now formally define piecewise differentiability.</p><p>Definition 4.2. (Piecewise Differentiability <ref type="bibr">[Scholtes 2012</ref>]) A function &#119891; : R &#119898; &#8594; R &#119899; is piecewise differentiable on an open set X &#8838; R &#119898; if &#119891; is continuous on X and for every &#119909; &#8712; X there exists an open neighborhood &#119874; &#8838; X and a finite number of differentiable functions, denoted {&#119892; 1 , ..., &#119892; &#119896; }, such that for any &#119909; &#119900; &#8712; &#119874;, &#119891; (&#119909; &#119900; ) &#8712; {&#119892; 1 (&#119909; &#119900; ), ..., &#119892; &#119896; (&#119909; &#119900; )}. We will refer to the set of differentiable functions {&#119892; 1 , ..., &#119892; &#119896; } as the selection set.</p><p>Any function &#119891; that is differentiable on a set X &#8838; R &#119898; (meaning J(&#119891; , &#8226;) exists) is trivially piecewise differentiable on X, albeit with a single piece. A piecewise differentiable function has a well-defined Clarke Jacobian that can be given in terms of the convex hull of the standard Jacobian of constituent pieces, provided an active set is known a priori <ref type="bibr">[Scholtes 2012</ref>]. If &#119891; has the selection set of differentiable functions {&#119892; 1 , ..., &#119892; &#119896; }, then (by Proposition 4.3.1 of <ref type="bibr">Scholtes [2012]</ref>):</p><p>where &#119860;(&#119891; , x 0 ) &#8838; {1, ..., &#119896; } is the active set, which denotes at x 0 which of the &#119896; selection functions satisfy &#119892; &#119894; (x 0 ) = &#119891; (x 0 ). To adapt this to our setting, we start with the simplest branching function &#119891; &#8796; &#119891; 0 &gt; &#119888; ? &#119891; 1 : &#119891; 2 where &#119891; 1 , &#119891; 2 are branch-free (meaning they are compositions, sums, or products of &#119862; 1 functions). Since &#119891; 1 and &#119891; 2 do not contain branches, one can compute J(&#119891; &#119894; , x 0 ) directly in accordance with Lemma 4.1. Hence, &#119891; 1 and &#119891; 2 are the selection set, as they are differentiable (by assumption) and the value of &#119891; 0 &gt; &#119888; ? &#119891; 1 : &#119891; 2 for some &#119909; 0 will necessarily be in {&#119891; 1 (&#119909; 0 ), &#119891; 2 (&#119909; 0 )}. Therefore, when writing a branch, the selection set is known by construction. So all that remains for &#119891; to be piecewise differentiable (and have a well-defined &#120597; &#119888; ) is to ensure that it is continuous, which is true provided &#119891; 1 (&#119909;) = &#119891; 2 (&#119909;) for {&#119909; : &#119891; 0 (&#119909;) = &#119888;}.</p><p>We do not need to restrict to cases where &#119891; 1 and &#119891; 2 are branch-free. We can nest branches arbitrarily deeply, provided they agree on the decision boundary {&#119909; : &#119891; 0 (&#119909;) = &#119888;}, as all this does is increase the number of selection functions (or pieces) by finitely many. This is because we do not allow infinite recursion or while loops that would permit expressing countably infinite possible branches. Intuitively, we recursively "unroll" the nested branches into all possible innermost functions (which themselves will no longer contain branches). This ultimately yields a finite set of branch-free functions &#119891; &#119894; for which we can compute J(&#119891; &#119894; , &#8226;) directly (as in Lemma 4.1). Using these notions, we can now formally describe necessary conditions for the Clarke Jacobian of the branching primitive to be well-defined. Theorem 4.3. (Well-Definedness of the Clarke Jacobian of a Branch) The function given by the branch &#119891; 0 &gt; &#119888; ? &#119891; 1 : &#119891; 2 is piecewise differentiable on an open set X &#8838; R &#119898; if &#119891; 1 is piecewise differentiable on {&#119909; &#8712; X : &#119891; 0 (&#119909;) &#8805; &#119888;}, &#119891; 2 is piecewise differentiable on {&#119909; &#8712; X : &#119891; 0 (&#119909;) &#8804; &#119888;}, and &#119891; 1 (&#119909; 0 ) = &#119891; 2 (&#119909; 0 ) for all &#119909; 0 &#8712; {&#119909; &#8712; X : &#119891; 0 (&#119909;) = &#119888;}.</p><p>Proof. (Sketch) Since &#119891; 1 is piecewise differentiable on {&#119909; &#8712; X : &#119891; 0 (&#119909;) &#8805; &#119888;}, it has some selection set {&#119892; 1 , ..., &#119892; &#119896; }; hence, &#119891; 0 &gt; &#119888; ? &#119891; 1 : &#119891; 2 is also piecewise differentiable on {&#119909; &#8712; X : &#119891; 0 (&#119909;) &#8805; &#119888;}, with the same selection set on that region. Likewise, since &#119891; 2 is piecewise differentiable on {&#119909; &#8712; X : &#119891; 0 (&#119909;) &#8804; &#119888;}, it has some selection set {&#8462; 1 , ..., &#8462; &#119897; }; thus, &#119891; 0 &gt; &#119888; ? &#119891; 1 : &#119891; 2 is also piecewise differentiable on {&#119909; &#8712; X : &#119891; 0 (&#119909;) &#8804; &#119888;}, with the same selection set. Furthermore, since {&#119909; &#8712; X :</p><p>&#9633;</p><p>We now present the rule for computing the Clarke Jacobian for a branching function, using the notions of piecewise differentiability. Formally, for &#119891; 0 : R &#119898; &#8594; R, &#119891; 1 , &#119891; 2 : R &#119898; &#8594; R &#119899; , and x 0 &#8712; R &#119898; :</p><p>When &#119891; 0 (x 0 ) &gt; &#119888;, the active set is &#119860;(&#119891; 0 , x 0 ) = {&#119891; 1 }; similarly, when &#119891; 0 (x 0 ) &lt; &#119888;, the active set is &#119860;(&#119891; 0 , x 0 ) = {&#119891; 2 }. Along the decision boundary, both &#119891; 1 and &#119891; 2 are in the active set, hence the Clarke Jacobian is the convex hull, co, of both of their respective Clarke Jacobians. In the rule shown in Eq. 5, we evaluate &#120597; &#119888; (&#119891; 1 , x 0 ) and &#120597; &#119888; (&#119891; 2 , x 0 ) instead of J(&#119891; 1 , x 0 ) and J(&#119891; 2 , x 0 ) as in Eq. 4. This recursive definition allows us to capture the notion of unrolling a nested branch, as once &#119891; 1 and &#119891; 2 are themselves branch free, &#120597; &#119888; (&#119891; &#119894; , x 0 ) and J(&#119891; &#119894; , x 0 ) become equivalent (by Lemma 4.1); thus, this equation would coincide with Eq. 4.</p><p>Example 4.4. We can encode ReLU(&#119909;) &#8796; &#119909; &gt; 0 ? &#119909; : 0, and hence &#120597; &#119888; (&#119909; &gt; 0 ? &#119909; : 0</p><p>Despite the elegant theory of <ref type="bibr">Scholtes [2012]</ref>, which allows us to characterize the conditions and well-definedness of the Clarke Jacobian of a piecewise differentiable function (or branch in our language), the problem of statically checking that these conditions are satisfied is undecidable. This is because even the smaller problem of ensuring that a branch is continuous along the decision boundary is known to be undecidable <ref type="bibr">[Chaudhuri et al. 2010;</ref><ref type="bibr">Di Gianantonio and Edalat 2013;</ref><ref type="bibr">Griewank 2013</ref>]. As those works do not target the exact framework we focus on, we offer a short self-contained result: Lemma 4.5. (Undecidability of Ensuring Piecewise Differentiability) Let &#119891; 1 : R &#119898; &#8594; R &#119899; and &#119891; 2 : R &#119898; &#8594; R &#119899; be arbitrary functions in the language, and let X &#8838; R &#119898; be an arbitrary set on which &#119891; 1 and &#119891; 2 are both defined. Checking if &#119891; 1 (&#119909;) = &#119891; 2 (&#119909;) for all &#119909; &#8712; X where &#119891; 0 (&#119909;) = &#119888; is undecidable.</p><p>Proof. (Sketch) Reduction using Richardson's Theorem <ref type="bibr">[Richardson 1969</ref>]. &#9633;</p><p>Existing works can heuristically check for this condition using SMT solvers <ref type="bibr">[Chaudhuri et al. 2010]</ref>, or restrict the language to only pre-specified operators (e.g., max, min, ReLU and abs) <ref type="bibr">[Beck and Fischer 1994;</ref><ref type="bibr">Di Gianantonio and Edalat 2013;</ref><ref type="bibr">Sherman et al. 2021]</ref>. Despite the difficulties introduced by a branching primitive, it will prove immensely useful in making the static analysis more precise, particularly for functions such as bilinear interpolation. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">INTERVAL CLARKE JACOBIAN</head><p>Having now defined the syntax and the standard Clarke Jacobian, we now formalize a computable, sound over-approximation: the Interval Clarke Jacobian, &#120597; &#119868;&#119899;&#119905; . We will then show how to scalably implement our abstraction with an equivalent formulation that leverages a sound abstraction of forward-mode automatic differentiation.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Interval Domain</head><p>To soundly approximate the Clarke Jacobian, we use the interval domain as it is fully computable and can soundly abstract the convex set of matrices corresponding to the original Clarke Generalized Jacobian, since interval matrices are necessarily convex sets.</p><p>Preliminaries. Denote the set of real-valued intervals of the form [&#119886;, &#119887;] where &#119886;, &#119887; &#8712; R &#8746; {&#177;&#8734;} and &#119886; &#8804; &#119887; as IR. The set of &#119899; &#215; &#119898; matrices of intervals is denoted as IR &#119899;&#215;&#119898; . We will use the notation x 0 instead of x 0 to distinguish matrices and vectors whose entries are intervals instead of scalars. Similarly, to denote the evaluation of a function &#119891; where all of its operations are lifted to interval arithmetic, we will write &#119891; ( x 0 ). To denote the lower and upper bounds of an interval x 0 = [&#119886;, &#119887;], we will write &#119897;&#119887; ( x 0 ) and &#119906;&#119887; ( x 0 ), respectively. We denote + IR , &#8226; IR , and / IR as the interval arithmetic versions of addition, multiplication, and division, respectively. Likewise, we denote &#8852; : IR&#215;IR &#8594; IR to be the standard interval join, which returns the smallest interval enclosing both arguments. We may also apply &#8852; element-wise to matrices in IR &#119899;&#215;&#119898; . Lastly, we denote &#8868; = IR &#119899;&#215;&#119898; , which is the entire space of &#119899; &#215; &#119898; interval matrices. We now define the Interval Clarke Jacobian, &#120597; &#119868;&#119899;&#119905; .</p><p>Definition 5.1. The Interval Clarke Jacobian &#120597; &#119868;&#119899;&#119905; : R &#119898; &#8594; R &#119899; &#215; IR &#119898; &#8594; IR &#119899;&#215;&#119898; for a function &#119891; : R &#119898; &#8594; R &#119899; and interval vector x &#8712; IR &#119898; is denoted &#120597; &#119868;&#119899;&#119905; (&#119891; , x 0 ) and is given by the rules of Fig. <ref type="figure">5</ref>.</p><p>The interpretation of the Jacobian of a function &#119891; is now an interval matrix that over-approximates the convex set of matrices corresponding to the original Clarke Jacobian. This will be necessary to be able to define the local neighborhood of points for which we want to abstractly analyze or compute a Lipschitz constant. We now detail each abstract transformer.</p><p>Constants and Variables. The Interval Clarke Jacobian of a constant function is nearly identical to the respective Clarke Jacobian (in that &#120597; &#119868;&#119899;&#119905; of a constant is 0); it is lifted to become the constant interval [0, 0] of the same dimension as x 0 , which we denote as 0 &#8712; IR &#119898; . Likewise, the Interval Clarke Jacobian of a single variable &#119909; &#119894; is also the constant vector where the &#119894; &#119905;&#8462; component is 1 and all other &#119898; -1 components are 0, again lifted to become a constant interval, which we denote as e &#119894; &#8712; IR &#119898; .</p><p>Cartesian Product. The Interval Clarke Jacobian of a Cartesian product of functions is just the concatenation of their respective Interval Clarke Jacobians.</p><p>Addition. The Interval Clarke Jacobian obeys linearity exactly.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Multiplication and Division. The Interval Clarke Jacobian satisfies a lifted interval arithmetic version of the product and quotient rules.</head><p>Composition. For compositions with &#119862; 1 -smooth functions, the Interval Clarke Jacobian satisfies a chain rule as well, where J &#119868;&#119899;&#119905; is the classical Jacobian of the &#119862; 1 -smooth function, just interpreted using interval arithmetic instead of ordinary arithmetic.</p><p>Example 5.2.</p><p>Just as with &#120597; &#119888; , primitive &#119862; 1 functions are where we can check if the Jacobian is undefined (in which case &#120597; &#119868;&#119899;&#119905; evaluates to &#8868;), which we likewise propagate up the function's expression tree. Branching. If the lower bound of &#119891; 0 ( x 0 ) is larger than &#119888;, we definitively know that &#119891; 1 is the only possible function of the active set. Similarly, if the upper bound of &#119891; 0 ( x 0 ) is smaller than &#119888;, we definitively know that &#119891; 2 is the only possible function of the active set. If &#119888; &#8712; &#119891; 0 ( x 0 ), then it is possible that both &#119891; 1 and &#119891; 2 are in the active set, thus we have to consider both possibilities.</p><p>In either case, we can also refine our information about x 0 . For example, when evaluating &#120597; &#119868;&#119899;&#119905; of the function &#119891; (&#119909;) &#8796; &#119909; &gt; 0 ? &#119891; 1 : &#119891; 2 on the interval x 0 = [-1, 1], conditional upon entering the true branch, we should only evaluate &#120597; &#119868;&#119899;&#119905; (&#119891; 1 , [0, 1]). Likewise, conditional upon entering the false branch, we should only evaluate &#120597; &#119868;&#119899;&#119905; (&#119891; 2 , [-1, 0]). We denote the refinement of x 0 for a Boolean guard of the form &#119891; 0 &gt; &#119888; as &#119891; 0 &gt; &#119888; ( x 0 ). However, the general problem of determining how to optimally refine the input x 0 , conditioned on the information of the branch &#119891; 0 &gt; &#119888;, is undecidable. Therefore, we follow the approach of Min&#233; <ref type="bibr">[Min&#233; 2017</ref>] and refine x 0 when the function &#119891; 0 in the Boolean guard has a simple form: a single variable &#119909; &#119894; , and then use the fallback transformer (the identity function) for all other cases (which can then be simplified to get the rule from Fig. <ref type="figure">5</ref>): </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">Soundness of the Abstraction</head><p>We now state the soundness of &#120597; &#119868;&#119899;&#119905; . We first define the concretization &#120574;.</p><p>Definition 5.3. Define the concretization &#120574; : IR &#119899;&#215;&#119898; &#8594; Co R &#119899;&#215;&#119898; for an interval matrix &#119878; &#8712; IR &#119899;&#215;&#119898; as follows:</p><p>This is because an interval matrix is already by definition a convex set of matrices. The soundness theorem is now given as follows.</p><p>Theorem 5.4. (Soundness) Let &#119891; : R &#119898; &#8594; R &#119899; be any function constructible according to Fig. <ref type="figure">3</ref> and<ref type="figure">x</ref> </p><p>Proof. See Appendix A.2 <ref type="bibr">(Laurel et al. [2022]</ref>). &#9633;</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">DUAL INTERVAL DOMAIN</head><p>While we could compute &#120597; &#119868;&#119899;&#119905; recursively in a reverse-mode pass, a key contribution of our work is to provide an equivalent, forward-mode version of the static analysis based on dual numbers. We can lift the ordinary arithmetic operators to dual intervals. We define dual interval addition, + ID : ID &#215; ID &#8594; ID as follows:</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.1">Dual Interval Arithmetic</head><p>It will also be useful to define a join for dual intervals,</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.2">Forward-Mode Abstract Evaluation with Dual Intervals</head><p>We now describe how to perform a forward-mode abstract evaluation where all operations are lifted to operate on dual intervals using the abstract interpreter &#119864;&#119907;&#119886;&#119897; ID .</p><p>Definition 6.2. The abstract interpreter &#119864;&#119907;&#119886;&#119897; ID : R &#119898; &#8594; R &#119899; &#215; ID &#119898; &#8594; ID &#119899; takes a real-valued function &#119891; : R &#119898; &#8594; R &#119899; and evaluates it abstractly by lifting the interpretation of all operations to dual interval arithmetic, as shown in Fig. <ref type="figure">6</ref>.</p><p>Because our language is functional, there is no "state. " However, the second argument to &#119864;&#119907;&#119886;&#119897; ID is the input, which serves the same purpose. We now detail the rules shown in Fig. <ref type="figure">6</ref>.</p><p>Constants and Variables. The abstract evaluation of a constant is that constant, albeit abstracted to a (degenerate) dual interval. Likewise, the evaluation of a single variable &#119909; &#119894; is the &#119894; &#119905;&#8462; element of the input dual interval (denoted by the [&#119894;] accessor).</p><p>Cartesian Product. To abstractly evaluate the Cartesian product of two functions &#119891; 1 and &#119891; 2 on a given input x 0 + y 0 &#120598;, we abstractly evaluate each one, then take the Cartesian product of the results.</p><p>Addition. To abstractly evaluate the sum of two functions, we abstractly evaluate each on the given input x 0 + y 0 &#120598;, then take the dual interval sum + ID of the respective results.</p><p>Multiplication and Division. As with addition, to abstractly evaluate the product of two functions or their quotient, we first abstractly evaluate the individual functions on the input, then use the dual interval forms of multiplication &#8226; ID and division / ID .</p><p>Composition. The abstract evaluation of the composition of any function &#119891; 1 with a &#119862; 1 function for an input dual interval x 0 + y 0 &#120598;, is the composition of the successive abstract evaluations: &#119891; 1 is abstractly evaluated on the input, then the &#119862; 1 function is abstractly evaluated on that result.</p><p>Branching. When evaluating a branch abstractly, we only use the real part of the dual interval, denoted &#119891; &#119904;&#119905; (&#119864;&#119907;&#119886;&#119897; ID (&#119891; 0 , x 0 + y 0 &#120598;)), to select which branch to take (or whether to abstractly evaluate both). While this may seem strange, one will note that in Eq. 5, the Clarke Jacobian is only computed for the piece that is ultimately chosen -&#119891; 1 or &#119891; 2 (possibly both) -and not the threshold function &#119891; 0 . In fact, &#119891; 0 is only used to select which branch to take, hence its derivative information (which corresponds to its dual part) is unnecessary. If the lower bound &#119897;&#119887; (&#119891; &#119904;&#119905; (&#119864;&#119907;&#119886;&#119897; ID (&#119891; 0 , x 0 + y 0 &#120598;))) is larger than &#119888;, we definitively know to take only the true branch. Conversely, if the upper bound of the real part &#119906;&#119887; (&#119891; &#119904;&#119905; (&#119864;&#119907;&#119886;&#119897; ID (&#119891; 0 , x 0 + y 0 &#120598;))) is less than &#119888;, we only take the false branch. Otherwise, we abstractly evaluate both branches then take their join &#8852; ID . In all cases, we can refine the information of the real part x 0 but not the dual part y 0 , as there is no way of knowing which sub-regions of x 0 correspond to which sub-regions in y 0 , since the interval domain is non-relational.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.3">Equivalence</head><p>We now prove that &#119864;&#119907;&#119886;&#119897; ID can be used to compute exactly the same result as &#120597; &#119868;&#119899;&#119905; .</p><p>Theorem 6.3. (Equivalence of &#120597; &#119868;&#119899;&#119905; and &#119864;&#119907;&#119886;&#119897; ID ) Let &#119891; : R &#119898; &#8594; R &#119899; and let x 0 &#8712; IR &#119898; . Then</p><p>Proof. We show the sketch for select cases; the full proof is in Appendix A.4. Base Cases. Constants and single variables are straightforward.</p><p>&#119904;&#119899;&#119889; &#119864;&#119907;&#119886;&#119897; ID (&#119888;,</p><p>Arithmetic Operations. Equivalence for arithmetic primitives is straightforward, though it requires the inductive hypothesis and using the definitions of + ID , &#8226; ID , / ID . We now detail addition:</p><p>= &#119904;&#119899;&#119889; &#119864;&#119907;&#119886;&#119897; ID (&#119891; 1 , x 0 + e 1 &#120598;) &#119879; &#215; ... &#215; &#119864;&#119907;&#119886;&#119897; ID (&#119891; 1 , x 0 + e &#119898; &#120598;) &#119879; (Ind. Hyp.)</p><p>The case for the Cartesian product proceeds analogously. Composition also uses the inductive hypothesis and relies upon the fact that</p><p>). Branching. As stated in Lemma 4.1, up to this point, without branching the language is just a standard differentiable programming language, thus the result is not surprising. However, with branching, establishing this equivalence is more challenging. We split the proof into three cases:</p><p>(1) &#119897;&#119887; (&#119891; ( x 0 )) &gt; &#119888;, (2) &#119906;&#119887; (&#119891; ( x 0 )) &lt; &#119888;, and (3) &#119888; &#8712; &#119891; ( x 0 ). Starting with &#119897;&#119887; (&#119891; 0 ( x 0 )) &gt; &#119888;:</p><p>And for any &#119894; &#8712; {1, .., &#119898;}, &#119897;&#119887; (&#119891; 0 ( x 0 )) &gt; &#119888; iff &#119897;&#119887; (&#119891; &#119904;&#119905; (&#119864;&#119907;&#119886;&#119897; ID (&#119891; 0 , x 0 + e &#119894; &#120598;))) &gt; &#119888;, hence:</p><p>By induction and the definitions of &#119864;&#119907;&#119886;&#119897; ID (&#119891; 0 &gt; &#119888; ? &#119891; 1 : &#119891; 2 , x 0 + e &#119894; &#120598;) and &#120597; &#119868;&#119899;&#119905; (&#119891; 1 , &#119891; 0 &gt; &#119888; ( x 0 )):</p><p>The case where &#119906;&#119887; (&#119891; 0 ( x 0 )) &lt; &#119888; proceeds exactly the same by symmetry. When we assume &#119888; &#8712; &#119891; 0 ( x 0 ), we must take the join. Starting from the desired right-hand side:</p><p>of &#120597; &#119868;&#119899;&#119905; and Ind. Hyp.) &#9633;</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.4">Complexity</head><p>The key insight of Theorem 6.3 is that, as with standard forward-mode AD, the dual interval abstraction requires as many forward passes as there are inputs. Therefore, for &#119891; : R &#119898; &#8594; R &#119899; , we require &#119898; independent passes of &#119864;&#119907;&#119886;&#119897; ID in order to compute the full interval over-approximation of the Clarke Jacobian. However, they can be computed in parallel (as we do). Hence, as with standard forward-mode AD, our method is better suited for functions where the input dimension is small. Additionally, the real part for each pass will be the same, and need only be computed once. Furthermore, for the basic arithmetic functions, dual interval arithmetic requires more primitive operations than the same operation defined over the reals. For example, multiplication of two dual intervals as shown in Section 6.1 requires 12 primitive multiplications to perform all the interval arithmetic multiplications for both the real and dual parts, as well as 2 primitive additions. However, for all arithmetic operations {+, -, &#8226;, /}, the amount of additional primitive operations required for the dual interval version (vs. the real-valued version) is still just a constant factor more.</p><p>While it has been established that for standard AD, the amount of primitive operations of a single pass of forward-mode evaluation with dual numbers is at most a constant amount (typically 2 -3x) more than the number of operations to evaluate the function itself <ref type="bibr">[Griewank and Walther 2008]</ref>, this is not the case for our analysis. A key complexity issue arises due to our support of branching. As the abstract evaluator &#119864;&#119907;&#119886;&#119897; ID could potentially evaluate both branches of a conditional, we may have exponentially many more evaluations compared to evaluating the function with ordinary real numbers. Thus, if &#119874;&#119875;&#119878; (&#119891; ) denotes the number of primitive arithmetic operations to evaluate &#119891; (not its Jacobian) over real numbers, then O (2 &#119874;&#119875;&#119878; (&#119891; ) ) is the upper bound on the number of primitive arithmetic operations required to evaluate a single pass of the dual interval lifted version of &#119891; . For the evaluation, the ReLU function as well as the contrast variation and rotation perturbations employ branching. Yet, despite the theoretically worst-case exponential operation complexity, in practice, DeepJ's implementation of &#119864;&#119907;&#119886;&#119897; ID was still quite fast. Lastly, each term will always have only two intervals associated to it (the real and dual parts). Hence, unlike affine interval arithmetic <ref type="bibr">[De Figueiredo and Stolfi 2004]</ref> or tools like Rosa <ref type="bibr">[Darulova and Kuncak 2017]</ref>, the number of intervals we must track per variable does not grow as a function of the expression size.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">METHODOLOGY</head><p>We next describe the experimental setup, including the perturbation functions and networks used in our experiments. We also detail the training procedures and accuracies of these networks. We ran our experiments on a 2.20 GHz 14 core Intel Xeon Gold 5120 CPU with 256 GB of main memory.</p><p>Implementation. We implemented our analysis in a tool called DeepJ, written in C++. DeepJ employs operator and function overloading to allow dual interval inputs to be propagated through arbitrary perturbation functions and neural networks. Even though our formalization is from a purely functional view, one can easily use an ANF conversion <ref type="bibr">[Flanagan et al. 1993</ref>] to produce imperative code, since our programs do not have recursions or while loops. All code, neural networks, and results are available at <ref type="url">https://github.com/uiuc-arc/DeepJ</ref>. Perturbation Functions. We consider three previously studied image perturbations affecting pixel intensity and image geometry, as well as compositions of these perturbations. We assume that the images' pixel values are in the range [0, 1].</p><p>(1) Haze <ref type="bibr">[Paterson et al. 2021</ref>  <ref type="formula">4</ref>) Composition: We look at three ways of composing the above functions -haze followed by rotation, contrast followed by rotation, and contrast followed by haze.</p><p>The contrast, rotation, and composite perturbations described above are non-differentiable but Lipschitz continuous, and cannot be handled by prior work <ref type="bibr">[Edalat and Maleki 2017;</ref><ref type="bibr">Jordan and Dimakis 2020;</ref><ref type="bibr">Mangal et al. 2020;</ref><ref type="bibr">Zhang et al. 2019</ref>]. In our experiments, we consider &#120572; &#119898;&#119886;&#119909; &#8804; 0.63 for the haze and contrast perturbations, and &#120579; &#119898;&#119886;&#119909; &#8804; 0.32 radians (which corresponds to approximately &#177;18 &#8226; ) for rotation.</p><p>Network Architectures. We trained three ReLU networks each for the CIFAR10 and MNIST datasets. The first network (FFNN) is a 7-layer fully-connected architecture from RecurJac <ref type="bibr">[Zhang et al. 2019]</ref>. The other networks are convolutional networks from <ref type="bibr">Mirman et al. [2018]</ref> -ConvMed features two convolutional and two fully-connected layers, while ConvBig features four convolutional and three fully-connected layers. Details on these networks are in Appendix A.5. Our largest network is the CIFAR ConvBig network containing &gt; 62 K neurons. These network sizes are comparable to those of other state-of-the-art verification techniques <ref type="bibr">[Singh et al. 2019]</ref>. Furthermore, for the local optimization landscape experiment, we trained 7 fully-connected networks on the MNIST dataset, varying the total number of layers from 3 to 9. Each hidden layer contains 30 neurons, and a ReLU activation is applied after every layer (including the final layer).</p><p>Data Transformation. For all MNIST networks, we transformed the training set so that for each image, we padded it by 4 and took a random 28x28 crop of the resulting 32x32 image. For the CIFAR10 networks, we introduced random cropping with padding 4 and randomly flipping each image horizontally with probability 0.5. Afterwards, we normalized the images using &#120583; = 0.1307, &#120590; = 0.3081 for MNIST and &#120583; = (0.4914, 0.4822, 0.4465), &#120590; = (0.2023, 0.1994, 0.2010) for CIFAR10.</p><p>Training Hyperparameters. For the 7 networks trained for the local optimization experiment, we used the Adam optimizer [Kingma and Ba 2014] with a learning rate of 10 -4 and L2-regularization with &#120582; = 0.001; we trained with a batch size of 500 for 60 epochs, using 6,000 images from the training set for validation. For all other networks, we used the Adam optimizer with a learning rate of 10 -3 on MNIST and 10 -4 on CIFAR10. We trained the MNIST networks with a batch size of 500 for 30 epochs, using 6,000 images from the training set for validation; we trained the CIFAR10 networks with a batch size of 64 for 60 epochs, using 5,000 images from the training set for validation. In all cases, we then picked the model that attained the highest validation accuracy out of all epochs.</p><p>Network Accuracies. The fully-connected networks trained for the local optimization landscape experiment all attain test accuracy of at least 92%. The classification accuracies for the networks in the Lipschitz experiments are shown in Table <ref type="table">1</ref>. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8">EXPERIMENTAL EVALUATION</head><p>We evaluate the effectiveness of our approach on two tasks: (i) Lipschitz robustness certification and (ii) optimization landscape analysis. Both tasks are defined across a variety of datasets, perturbation functions, and neural network architectures, demonstrating our language's flexibility and scalability.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.1">Lipschitz Robustness</head><p>We compute an upper bound on the Lipschitz constant of functions of the form &#119891; &#8226; &#119899; &#8226; &#119901;, where &#119901; denotes one or more perturbation functions, &#119899; is an input normalization function (which simply rescales images by a constant), and &#119891; is a neural network. The correctness of bounding the Lipschitz constant via the Interval Clarke Jacobian is proved in Appendix A.3. We use the &#8467; &#8734; -norm for the calculation of all Lipschitz constants. For both individual and composite perturbations, we consider five versions of our tool: DeepJ with the given range for the input perturbation parameter(s) and four versions of DeepJ where the input intervals are subdivided uniformly, denoted DeepJ &#119896;x, where &#119896; represents how many subintervals are used per input parameter. When using splitting, we compute the upper bound on the Lipschitz constant separately for each split and take the maximum constant across the splits. Each pass of our analysis per image and split is completely independent of one another, and is thus parallelized in our implementation. Since no existing work can handle functions of the form &#119891; &#8226; &#119899; &#8226; &#119901; considered in our evaluation, we employ a baseline combining global and local Lipschitz analysis. The baseline computes &#119871; &#119897;&#119900;&#119888; (&#119901;) &#8226; &#119871; &#119892;&#119897;&#119900;&#119887;&#119886;&#119897; (&#119899;) &#8226; &#119871; &#119892;&#119897;&#119900;&#119887;&#119886;&#119897; (&#119891; ), where &#119871; &#119897;&#119900;&#119888; and &#119871; &#119892;&#119897;&#119900;&#119887;&#119886;&#119897; are the local and global Lipschitz constants of their corresponding functions. As &#119901; is not globally Lipschitz, we obtain &#119871; &#119897;&#119900;&#119888; (&#119901;) with DeepJ. We compute &#119871; &#119892;&#119897;&#119900;&#119887;&#119886;&#119897; (&#119899;) as the reciprocal of the standard deviation (MNIST) or the reciprocal of the smallest standard deviation of the three RGB channels (CIFAR10) used for normalizing the input. We calculate &#119871; &#119892;&#119897;&#119900;&#119887;&#119886;&#119897; (&#119891; ) by multiplying the norm of each layer's weights using the tool from <ref type="bibr">Gouk et al. [2021]</ref>.</p><p>Results for Individual Perturbations. input to our function is in radians and covers the same range of interval sizes as the other two perturbations, but we convert the units to degrees for clearer presentation. In all cases, DeepJ is more precise than the baseline, often obtaining Lipschitz bounds orders of magnitude smaller than the baseline. The computed bounds become larger as the perturbation size is increased. It can also be seen that increased splitting leads to more precise results, with DeepJ 25x achieving much lower bounds than vanilla DeepJ (which does not do splitting).</p><p>Table <ref type="table">2</ref> shows statistics on the runtime of the different methods for the same networks as in Figure <ref type="figure">7</ref>. We consider all values of the parameters on the x-axis shown in Fig. <ref type="figure">7</ref>. The runtimes for the remaining networks can be found in Appendix A.5. We report the minimum, median, and maximum runtimes across the 100 images for each function. DeepJ 25x takes the longest to run due to more splits, while the baseline usually runs the fastest, except for rotation on large angles. In some cases, splitting may be faster than the baseline or vanilla DeepJ, since without splitting, intervals can become too over-approximate; evaluating conditionals on over-approximate intervals often requires evaluating both branches, which may lead to the exponential blowup phenomenon discussed in Section 6.4. For rotation with bilinear interpolation, we empirically observed this beyond &#177;0.1 radians. The computation of &#119871; &#119897;&#119900;&#119888; (&#119901;) via our method contributes the most to the runtime of the baseline. For all versions of DeepJ, the rotation perturbation has the highest runtime. For a given perturbation type, the runtime increases with the size of the network. On the most expensive rotation perturbation with the CIFAR ConvBig network, the median time for DeepJ to finish is under 1.4 min per 100 images. Finally, the precision of our analysis can be improved by increasing the number of splits (as seen in Figure <ref type="figure">7</ref>) at the cost of additional runtime (as seen in Table <ref type="table">2</ref>).</p><p>Results for Composite Perturbations. Figure <ref type="figure">8</ref> shows the upper bounds on the Lipschitz constant computed for compositions of perturbations on the same networks as in Figure <ref type="figure">7</ref>. The results for the remaining networks can be found in Appendix A.5. Haze-Rotation denotes a haze perturbation composed with a rotation, in that order; the terminology is similar for the other composite perturbations. We use the same interval width when perturbing each parameter independently; the x-axis shows this width. For compositions that involve rotation, if the interval size on the x-axis is denoted &#119904;, we utilize the real interval [-&#119904;/2, &#119904;/2] for rotation and the interval [0, &#119904;] for the other perturbation. The y-axis shows the upper bound on the Lipschitz constant computed by each method. Again, both axes use logarithmic scales. Each data point is the average over 10 correctly classified images, taking the first correctly classified test-set image from each output category. We use &#119904; &#8712; {10 -&#119896;/4 &#8226; 2 | &#119896; &#8712; {4, 7, 10, 13, 16, 19}} for all experiments.</p><p>As with individual perturbations, DeepJ is better than the baseline in all cases, obtaining upper bounds on the Lipschitz constants orders of magnitude smaller than the baseline, as seen in Figure <ref type="figure">8</ref>. DeepJ 9x with the largest number of splits is the most precise. The Lipschitz constants for both the Haze-Rotation and Contrast-Rotation perturbations are nearly identical, since the entries in the Clarke Jacobian corresponding to the rotation variable have much higher magnitudes. Thus, these entries dominate the &#8467; &#8734; -norm, overshadowing the effect of the other perturbation.  Table <ref type="table">3</ref> shows the runtime statistics for the different methods in the same way as Table <ref type="table">2</ref>. The results for the remaining networks can be found in Appendix A.5. We observe similar trends in the relative runtimes of the different methods as with individual perturbations. For all versions of DeepJ and for the baseline, the compositions that take the longest time to analyze are those containing rotations. On the most expensive composite perturbation (Haze-Rotation) with the CIFAR ConvBig network, the median time for DeepJ to finish is under 51 seconds per 10 images. As with individual perturbations, the precision of DeepJ can be improved by considering more splits at the cost of additional runtime.</p><p>Our tool, though implemented via floating-point, assumes real arithmetic. To ensure this assumption does not lead to substantially different results, we also implemented a floating-point sound version using the techniques in <ref type="bibr">[Min&#233; 2004</ref>]. We ran floating-point sound experiments for vanilla DeepJ. Table <ref type="table">4</ref> shows that the difference in the computed Lipschitz constants is negligible (&lt; 10 -10 ) in all cases. However, ensuring floating-point soundness adds up to 4.1x runtime overhead. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.2">Local Optimization Landscape Analysis</head><p>Obtaining an Interval Clarke Jacobian allows us to study the local geometry of &#119891; &#8226; &#119899; &#8226; &#119901;. We focus on finding the largest input regions where no stationary point exists. To prove that a given region does not contain a stationary point, we check if there exists an interval entry [&#119897; &#119894;,&#119895; , &#119906; &#119894;,&#119895; ] in the Interval Clarke Jacobian such that &#119897; &#119894;,&#119895; &gt; 0 or &#119906; &#119894;,&#119895; &lt; 0. If this holds, then we can guarantee that the Clarke Jacobian matrix will not become zero, and therefore no stationary point exists within the given input region (which follows from Theorem 2.3.2 of <ref type="bibr">[Clarke 1990]</ref>). Hence, similar to RecurJac <ref type="bibr">[Zhang et al. 2019]</ref>, we study the relationship between network depth and the maximal interval size for which the absence of stationary points can still be guaranteed. However, RecurJac cannot handle functions of the form &#119891; &#8226; &#119899; &#8226; &#119901; considered in our work. We define the set of input intervals to analyze as {[0, 10 -&#119896;/4 &#8226; 2] | &#119896; &#8712; [2, 21]} for haze and contrast and {[-10 -&#119896;/4 , 10 -&#119896;/4 ] | &#119896; &#8712; [2, 21]} for rotation. We consider 100 test images from MNIST that are correctly classified, using the first 10 correctly classified test images from each category. For each combination of perturbation type and network, we compute the largest input region where a stationary point does not exist. For each image, we uniformly split every input interval into 25 subintervals, computing the Interval Clarke Jacobians separately for each subinterval. Next, we identify the subintervals where the entry in the Interval Clarke Jacobian corresponding to the correctly classified class is either strictly positive or negative. We sum the widths of all such subintervals, then compute the maximum of these sums across all candidate widths. Figure <ref type="figure">9</ref> shows that as the depth of the fully-connected network increases, the maximal interval size that guarantees a non-zero Jacobian decreases for all perturbations. Further, we use the same procedure to obtain maximal interval sizes for the networks used in Section 8.1, as shown in Table <ref type="table">5</ref>. We observe that rotation requires noticeably smaller interval sizes as it is a more complex perturbation involving interpolation, whereas the other two are simpler pixel-wise operations. Furthermore, we can certify the absence of stationary points for larger regions on MNIST compared to CIFAR10, due to the former's smaller input dimension.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="9">RELATED WORK</head><p>While there is considerable work on the static analysis of input-output properties of ML models specified via constraints on the network inputs and outputs <ref type="bibr">[Balunovi&#263; et al. 2019;</ref><ref type="bibr">Ehlers 2017;</ref><ref type="bibr">Huang et al. 2017;</ref><ref type="bibr">Katz et al. 2017</ref><ref type="bibr">Katz et al. , 2019;;</ref><ref type="bibr">Singh et al. 2018</ref><ref type="bibr">Singh et al. , 2019;;</ref><ref type="bibr">Sotoudeh and Thakur 2020;</ref><ref type="bibr">Urban and Min&#233; 2021]</ref>, such as for robustness and safety, much less work has been done on formally analyzing the Jacobian matrix.</p><p>From the programming languages (PL) and automatic differentiation (AD) literature, prior works <ref type="bibr">[Di Gianantonio and Edalat 2013;</ref><ref type="bibr">Edalat et al. 2013;</ref><ref type="bibr">Khan and Barton 2013;</ref><ref type="bibr">Sherman et al. 2021</ref>] have examined AD through the Clarke Jacobian <ref type="bibr">[Clarke 1990</ref>]. However, many define their semantics for computing the Clarke Jacobian at a single point [Khan and <ref type="bibr">Barton 2012</ref><ref type="bibr">Barton , 2013]]</ref>, instead of an abstraction of points. Additionally, the works that can formally analyze Jacobians for sets of input points are insufficient for our tasks. Di Gianantonio and <ref type="bibr">Edalat [2013]</ref> restrict functions' domains to <ref type="bibr">[-1,1]</ref> and require all Lipschitz constants be less than 1, thus their analysis cannot be used for local Lipschitz certification. The work by <ref type="bibr">Edalat and Lieutier [2004]</ref> is restricted to functions of a single variable with input domain on [0, 1]. Follow-up works <ref type="bibr">[Edalat et al. 2013;</ref><ref type="bibr">Edalat and</ref><ref type="bibr">Maleki 2017, 2018]</ref> all suffer other restrictions, namely requiring the output dimension be one and only supporting limited arithmetic operations (e.g., no division), which render them unable to analyze both neural networks and our perturbations. Furthermore, these techniques provide only a theoretical discussion, with no implementation of their approaches. &#120582; &#119878; <ref type="bibr">[Sherman et al. 2021]</ref> presents semantics for the Clarke Jacobian for concrete input points, extended partially to intervals (described in their appendix) as compared to our approach, which presents a sound abstract interpretation of the Clarke Jacobian that we compute with a set of fully compositional dual interval domain transformers, whose behavior is specified exactly for all language primitives. Another closely related PL work by <ref type="bibr">Chaudhuri et al. [2011]</ref> aims to establish Lipschitz robustness of programs, but they use the classical Jacobian and do not support AD. Follow-up works showed how to analyze Lipschitz robustness of non-differentiable programs by analyzing their smooth approximation <ref type="bibr">[Chaudhuri and Solar-Lezama 2011]</ref>, stemming from the fact that several PL works focus on differentiable approximations of non-differentiable programs and ML models <ref type="bibr">[Chaudhuri and Solar-Lezama 2010;</ref><ref type="bibr">Laurel and Misailovic 2020]</ref>. In contrast, DeepJ can analyze Lipschitz properties of programs with points of non-differentiability directly without using approximations, by employing the more general Clarke Jacobian.</p><p>In addition, while the practical problem of Lipschitz certification of neural networks has been studied <ref type="bibr">[Jordan and Dimakis 2020;</ref><ref type="bibr">Scaman and Virmaux 2018;</ref><ref type="bibr">Weng et al. 2018a,b;</ref><ref type="bibr">Zhang et al. 2019]</ref>, to the best of our knowledge, none of these works can bound local Lipschitz constants for composite, non-smooth perturbations. Both <ref type="bibr">Mangal et al. [2020]</ref> and <ref type="bibr">Jordan and Dimakis [2020]</ref> use proof techniques that require the classifier function analyzed be piecewise linear, hence they cannot support arbitrary activations. Additionally, RecurJac <ref type="bibr">[Zhang et al. 2019</ref>] cannot support arbitrary arithmetic primitives like non-scalar multiplication or division. Hence, none of these works can reason about non-differentiable input perturbations, such as those generated by rotation <ref type="bibr">[Balunovi&#263; et al. 2019]</ref> or contrast variation <ref type="bibr">[Paterson et al. 2021]</ref>.</p><p>Our work also bears similarity with Rosa <ref type="bibr">[Darulova and Kuncak 2017]</ref>, as they also bound Jacobians to compute Lipschitz constants. However, unlike us, they do not support bounding Clarke Jacobians. Further, while their abstract domain tracks "&#120598;-terms," the semantics of these terms do not correspond to first derivatives, but rather numerical round-off error effects.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="10">CONCLUSION</head><p>We developed a novel abstraction for bounding the Clarke Jacobian of a Lipschitz, but not necessarily differentiable function for local input regions. Our domain, based upon dual numbers, soundly over-approximates all first derivatives needed to compute the Clarke Jacobian. We implemented our analysis in tool named DeepJ and showed that it can efficiently compute Lipschitz bounds and analyze the local geometry of multiple deep neural networks with respect to multiple nondifferentiable input perturbations. Our work is the first to address the problem of local Lipschitz certification of non-smooth perturbations, such as haze, contrast variation, rotation with bilinear interpolation, and their compositions.</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. POPL, Article 56. Publication date: January 2022.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_1"><p>&#119862; 1 ::= sin(&#119909;) | cos(&#119909;) | &#119890; &#119909; | log(&#119909;) | sqrt(&#119909;) | &#120590; (&#119909;) | tanh(&#119909;) &#915; &#8866; &#119888; : R &#119898; &#8594; R &#915; &#8866; &#119909; &#119894; : R &#119898; &#8594; R &#915; &#8866; &#119891; 1 : R &#119898; &#8594; R &#119899; &#915; &#8866; &#119891; 2 : R &#119898; &#8594; R &#119901; &#915; &#8866; &#119891; 1 &#215; &#119891; 2 : R &#119898; &#8594; R &#119899;+&#119901; &#915; &#8866; &#119891; 1 : R &#119898; &#8594; R &#915; &#8866; &#119891; 2 : R &#119898; &#8594; R &#915; &#8866; &#119891; 1 + &#119891; 2 : R &#119898; &#8594; R &#915; &#8866; &#119891; 1 : R &#119898; &#8594; R &#915; &#8866; &#119891; 2 : R &#119898; &#8594; R &#915; &#8866; &#119891; 1 &#8226; &#119891; 2 : R &#119898; &#8594; R &#915; &#8866; &#119891; 1 : R &#119898; &#8594; R &#915; &#8866; 1/&#119891; 1 : R &#119898; &#8594; R &#915; &#8866; &#119891; 1 : R &#119898; &#8594; R &#915; &#8866; &#119862; 1 &#8226; &#119891; 1 : R &#119898; &#8594; R &#915; &#8866; &#119891; 0 : R &#119898; &#8594; R &#915; &#8866; &#119891; 1 : R &#119898; &#8594; R &#119899; &#915; &#8866; &#119891; 2 : R &#119898; &#8594; R &#119899; &#915; &#8866; &#119891; 0 &gt; &#119888; ? &#119891; 1 : &#119891; 2 : R &#119898; &#8594; R &#119899;</p></note>
		</body>
		</text>
</TEI>
