F Leblanc

S Curry

On Mars' atmospheric sputtering after MAVEN first two years

Mars may have lost a significant part of its atmosphere into space along its history, in particular since the end of its internal dynamo, 4.1 Gyr ago. The sputtering of the atmosphere by precipitating planetary picked up ions accelerated by the solar wind is one of the processes that could have significantly contributed to this atmospheric escape. We here present a two years base analysis of MAVEN observation of the precipitating flux, in particular the dependency of the precipitating intensity with solar zenith angle and used this measurement to model the expected escape rate and exosphere induced by this precipitation.

MAVEN measurements

In order to reconstruct the flux of precipitating picked-up ion measured by MAVEN, we used the same approach as in [START_REF] Leblanc | Mars heavy ion precipitating flux as measured by Mars Atmosphere and Volatile EvolutioN[END_REF], that is, we used all available measurements of the ion mass and energy distributions realized between 200 and 350 km in altitude by SWIA (cs product) and STATIC (ca and d0 products). We selected the anodes covering the 75° cone angle oriented along the zenith direction and reconstructed the energy distribution. As shown in Figure 1, there is globally a good agreement between the measured flux by SWIA and STATIC, knowing that SWIA field of view allows a better coverage of the cone angle pointing towards the zenith than STATIC. Moreover, the comparison between STATIC d0 product for masses between 15 and 17 amu and SWIA cs suggests that most of the precipitating ion measured by SWIA with energy larger than few tens of eV are O + ions. Compared to the predicted energy flux distribution [START_REF] Wang | Statistical studies on Mars atmospheric sputtering by precipitating pickup O+: Preparation for the MAVEN mission[END_REF], Figure 1 highlighted the good agreement between prediction and measurements. In Figure 2, we plotted the integrated flux in a MSO longitude/latitude frame. This shows that the precipitating flux is organized between day and night sides with a 1.7 times higher intensity of the dayside precipitating flux.

EPSC Abstracts

Induced atmospheric escape

Reconstructing the precipitating flux between day and night sides, we simulated the fate of precipitating pick-up O + ions into Mars' atmosphere using Exospheric Global Model (EGM) [START_REF] Leblanc | Mars' exosphere observation and modelling: HELIOSARES view of MAVEN's measurements[END_REF] coupled to LMD-GCM [START_REF] Chaufray | 3D Martian Ionosphere model : II Effect of transport processes without magnetic field[END_REF] in order to calculate the induced exosphere and atmospheric escape by the precipitating ion (Figure 1, red line). EGM is a multispecies parallelized 3D model describing, for any season and solar conditions, how energetic ion will interact with Mars' upper atmosphere (composed of CO2, CO, O, N and N2) by transferring energy and momentum to the atom and molecule and ejecting atmospheric species into the exosphere. To describe the collision, we used at low energy the universal collision scheme of [START_REF] Lewkow | Precipitation of energetic neutral atoms and induced non-thermal escape fluxes from the Martian atmosphere[END_REF] and at high energy molecular dynamic scheme [START_REF] Leblanc | Role of molecular species in pickup ion sputtering of the Martian atmosphere[END_REF] in order to take into account the possibility of molecular dissociation.

Conclusion

Based on the average measured precipitating flux during the first two years of MAVEN observations, and using a model to determine the potentially induced atmospheric escape, we concluded that 5×10 23 O/s, 8×10 22 CO2/s, 4×10 22 CO/s, 1×10 23 C/s, 1.6×10 24 N/s and 4×10 23 N2/s should have escaped Mars' atmosphere between December 2014 and October 2016.

  Figure 1 displays the average precipitating flux measured by MAVEN SWIA and STATIC during the first two years of MAVEN operations (between 12/02/2014 and 10/24/2016).

Figure 1 :

 1 Figure 1: Differential particle flux of the precipitating pick-up ion as measured by MAVEN between 200 and 350 km in altitude during the 12/2014-10/2016 period. Red line: SWIA cs, blue line: STATIC ca, green line: STATIC d0 15-17 amu mass range, black line: theoretical predicted flux (Wang et al. 2015).

Figure 2 :

 2 Figure 2: Integrated precipitating flux measured by MAVEN (SWIA cs) during the 12/2014-10/2016 period plotted vs MSO latitude and longitude. The subsolar point is at 0°,0°.

Acknowledgements

FL, JYC and RM acknowledge the support of the "Système Solaire" program of the French Space Agency CNES and the Programme National de Planétologie and Programme National Soleil-Terre. This work is also part of HELIOSARES Project supported by the ANR (ANR-09-BLAN-0223) and ANR MARMITE (ANR-13-BS05-0012-02). Authors also acknowledge the support of the IPSL data center CICLAD for providing us access to their computing resources and data. The results of the simulations presented in this paper can be requested to FL.


Alexander Bentkamp
email: a.bentkamp@vu.nl

Jasmin Christian Blanchette
email: j.c.blanchette@vu.nl

Dietrich Klakow
email: dietrich.klakow@lsv.uni-saarland.de

A Formal Proof of the Expressiveness of Deep Learning

Deep learning has had a profound impact on computer science in recent years, with applications to image recognition, language processing, bioinformatics, and more. Recently, Cohen et al. provided theoretical evidence for the superiority of deep learning over shallow learning. We formalized their mathematical proof using Isabelle/HOL. The Isabelle development simplifies and generalizes the original proof, while working around the limitations of the HOL type system. To support the formalization, we developed reusable libraries of formalized mathematics, including results about the matrix rank, the Borel measure, and multivariate polynomials as well as a library for tensor analysis.

Introduction

Deep learning algorithms enable computers to perform tasks that seem beyond what we can program them to do using traditional techniques. In recent years, we have seen the emergence of unbeatable computer go players, practical speech recognition systems, and self-driving cars. These algorithms also have applications to image recognition, bioinformatics, and many other domains. Yet, on the theoretical side, we are only starting to understand why deep learning works so well. Recently, Cohen et al. [START_REF] Cohen | On the expressive power of deep learning: A tensor analysis[END_REF] used tensor theory to explain the superiority of deep learning over shallow learning for one specific learning architecture called convolutional arithmetic circuits (CACs).

Machine learning algorithms attempt to model abstractions of their input data. A typical application is image recognition-i.e., classifying a given image in one of several categories, depending on what the image depicts. The algorithms usually learn from a set of data points, each specifying an input (the image) and a desired output (the category). This learning process is called training. The algorithms generalize the sample data, allowing them to imitate the learned output on previously unseen input data.

CACs are based on sum-product networks (SPNs), also called arithmetic circuits [START_REF] Poon | Sum-product networks: A new deep architecture[END_REF]. An SPN is a rooted directed acyclic graph with input variables as leaf nodes and two types of inner nodes: sums and products. The incoming edges of sum nodes are labeled with real-valued weights, which are learned by training.

CACs impose the structure of the popular convolutional neural networks (CNNs) onto SPNs, using alternating convolutional and pooling layers, which are realized as collections of sum nodes and product nodes, respectively. These networks can be shallower or deeper-i.e., consist of few or many layers-and each layer can be arbitrarily small or large, with low-or high-arity sum nodes. CACs are equivalent to similarity networks, which have been demonstrated to perform as well as CNNs, if not better [START_REF] Cohen | Deep SimNets[END_REF].

Cohen et al. prove two main theorems about CACs: the fundamental and the generalized theorem of network capacity (Section 3). The generalized theorem states that CAC networks enjoy complete depth efficiency: In general, to express a function captured by a deeper network using a shallower network, the shallower network must be exponentially larger than the deeper network. By "in general," we mean that the statement holds for all CACs except for a Lebesgue null set S in the weight space of the deeper network. The fundamental theorem is a special case of the generalized theorem, where the expressiveness of the deepest possible network is compared with the shallowest network. Cohen et al. present both theorems in a variant where weights are shared across the networks and a more flexible variant where they are not.

As an exercise in mechanizing modern research in machine learning, we developed a formal proof of the fundamental theorem for networks with nonshared weights using the Isabelle/HOL proof assistant [START_REF] Nipkow | Isabelle/HOL: A Proof Assistant for Higher-Order Logic[END_REF]. To simplify our work, we recast the original proof into a more modular version (Section 4), which generalizes the result as follows: S is not only a Lebesgue null set, but also a subset of the zero set of a nonzero multivariate polynomial. This stronger theorem gives a clearer picture of the expressiveness of deep CACs.

The formal proof builds on general libraries that we either developed or enriched (Section 5). We created a library for tensors and their operations, including product, CP-rank, and matricization. We added the matrix rank and its properties to Thiemann and Yamada's matrix library [START_REF] Thiemann | Matrices, Jordan normal forms, and spectral radius theory[END_REF], generalized the definition of the Borel measure by Hölzl and Himmelmann [START_REF] Hölzl | Three chapters of measure theory in Isabelle/HOL[END_REF], and extended Lochbihler and Haftmann's polynomial library [START_REF] Haftmann | Towards abstract and executable multivariate polynomials in Isabelle[END_REF] with various lemmas, including the theorem stating that zero sets of nonzero multivariate polynomials are Lebesgue null sets. For matrices and the Lebesgue measure, an issue we faced was that the definitions in the standard Isabelle libraries have types that are too restrictive: The dimensionality of the matrices and of the measure space is parameterized by types that encode numbers, whereas we needed them to be terms.

Building on these libraries, we formalized the fundamental theorem for networks with nonshared weights (Section 6). CACs are represented using a datatype that is flexible enough to capture networks with and without concrete weights. We defined tensors and polynomials to describe these networks, and used the datatype's induction principle to show their properties and deduce the fundamental theorem.

Our formalization is part of the Archive of Formal Proofs [START_REF] Bentkamp | Expressiveness of deep learning[END_REF] and is described in more detail in Bentkamp's M.Sc. thesis [START_REF] Bentkamp | An Isabelle Formalization of the Expressiveness of Deep Learning[END_REF]. It comprises about 7000 lines of Isabelle proofs, mostly in the declarative Isar style [START_REF] Wenzel | Isar-A generic interpretative approach to readable formal proof documents[END_REF], and relies only on the standard axioms of higher-order logic, including the axiom of choice.

Mathematical Preliminaries

Tensors Tensors can be understood as multidimensional arrays, with vectors and matrices as the one-and two-dimensional cases. Each index corresponds to a mode of the tensor. For matrices, the modes are called "row" and "column." The number of modes is the order of the tensor. The number of values an index can take in a particular mode is the dimension in that mode. Thus, a real-valued tensor

A ∈ R M 1 ו••×M N of order N and dimension M i in mode i contains values A d 1 ,...,d N ∈ R for d i ∈ {1, . . . , M i }.
Like for vectors and matrices, addition + is defined as componentwise addition for tensors of identical dimensions. The product ⊗ is a binary operation on two arbitrary tensors that generalizes the outer vector product. The canonical polyadic rank, or CPrank, associates a natural number with a tensor, generalizing the matrix rank. The matricization [A ] of a tensor A is a matrix obtained by rearranging A 's entries using a bijection between the tensor and matrix entries. It has the following property:

Lemma 1 Given a tensor A , we have rank [A ] ≤ CP-rank A .
Lebesgue Measure The Lebesgue measure is a mathematical description of the intuitive concept of length, surface, or volume. It extends this concept from simple geometrical shapes to a large amount of subsets of R n , including all closed and open sets, although it is impossible to design a measure that caters for all subsets of R n while maintaining intuitive properties. The sets to which the Lebesgue measure can assign a volume are called measurable. The volume that is assigned to a measurable set can be a nonnegative real number or ∞. A set of Lebesgue measure 0 is called a null set. If a property holds for all points in R n except for a null set, the property is said to hold almost everywhere.

The following lemma [START_REF] Caron | The zero set of a polynomial[END_REF] about polynomials will be useful for the proof of the fundamental theorem of network capacity.

Lemma 2 If p ≡ 0 is a polynomial in d variables, the set of points x ∈ R d with p(x) = 0 is a Lebesgue null set.

The Theorems of Network Capacity

Figure 1 gives the formulas for evaluating a CAC and relates them to the network's hierarchical structure. The * operator denotes componentwise multiplication. The inputs x 1 , . . . , x N of a CAC are N real vectors of length M, where N must be a power of 2. The output y is a vector of length Y. The network's depth d can be any number between 1 and log 2 N. The first d -1 pooling layers consist of binary nodes. The last pooling layer consists of a single node with an arity of N /2 d-1 ≥ 2.

The calculations depend on the learned weights, which are organized as entries of a collection of real matrices W l, j , where l is the index of the layer and j is the position in that layer where the matrix is used. Matrix W l, j has dimensions r l × r l-1 for natural numbers r -1 , . . . , r d with r -1 = M and r d = Y. The weight space of a CAC is the space of all possible weight configurations. For a given weight configuration, the network expresses the function (x 1 , . . . , x N ) → y.

The above definitions are all we need to state the main result proved by Cohen et Let S be the set of configurations in the weight space of the deeper network that express functions also expressible by the shallower network. Then S is a Lebesgue null set. Intuitively, to express the same functions as the deeper network, almost everywhere in the weight space of the deeper network, r 2,d 2 -1 must be at least r N/2 d 2 , which means the shallower network needs exponentially larger weight matrices than the deeper network.

u 0, j = x j v 0, j = W 0, j • u 0, j u 1, j = v 0,2 j-1 * v 0,2 j v 1, j = W 1, j • u 1, j . . . u d-1, j = v d-2,2 j-1 * v d-2,2 j v d-1, j = W d-1, j • u d-1, j u d,1 = v d-1,1 * • • • * v d-1, N /2 d-1 y = v d,1 = W d,1 • u d,1 y = v d,1 u d,1 v d-1, N /2 d-1 u d-1, N /2 d-1 v d-1,1 u d-1,1 v 1,2 u 1,2 v 0,4 u 0,4 v 0,3 u 0,3 v 1,1 u 1,1 v 0,2 u 0,2 v 0,1 u 0,1 v 1, N /2 u 1, N /2 v 0,N u 0,N v 0,N-1 u 0,N-1 v 1, N /2-1 u 1, N /2-1 v 0,N-2 u 0,N-2 v 0,N-3
The special case of this theorem where d 1 = log 2 N and d 2 = 1 is called the fundamental theorem of network capacity. This is the theorem we formalized. Cohen et al. extended the result to CACs with an initial representational layer that applies a collection of nonlinearities to the inputs before the rest of the network is evaluated. Independently, they also showed that the fundamental and generalized theorems hold when the same weight matrix is applied within each layer l-i.e., W l,1 = • • • = W l,N/2 l .

Restructured Proof of the Theorems

The proof of either theorem of network capacity depends on a connection between CACs and measure theory, using tensors, matrices, and polynomials along the way. Briefly, the CACs and the functions they express can be described using tensors. Via matricization, these tensors can be analyzed as matrices. Polynomials bridge the gap between matrices and measure theory, since the matrix determinant is a polynomial, and zero sets of polynomials are Lebesgue null sets (Lemma 2).

The proof by Cohen et al. is structured as a monolithic induction over the deep network structure. It combines tensors, matrices, and polynomials in each induction step. Before launching Isabelle, we restructured the proof into a more modular version that cleanly separates the mathematical theories involved, resulting in the following sketch: I. We describe the function expressed by a CAC for a fixed weight configuration using tensors. We focus on an arbitrary entry y i of the output vector y. If the shallower network cannot express the output component y i , it cannot represent the entire output either. Let A i (w) be the tensor that represents the function (x 1 , . . . , x N ) → y i expressed by the deeper network with a weight configuration w.

II. We define a function ϕ that reduces the order of a tensor. The CP-rank of ϕ(A ) indicates how large the shallower network must be to express a function represented by a tensor A : If the function expressed by the shallower network is represented by A , then r 2,d 2 -1 ≥ CP-rank (ϕ(A )). III. We construct a multivariate polynomial p, mapping the weights configurations w of the deeper network to a real number p(w). It has the following properties:

(a) If p(w) = 0, then rank [ϕ(A i (w))] ≥ r N/2 d 2 . Hence CP-rank (ϕ(A i (w))) ≥ r N/2 d 2 by Lemma 1. (b)
The polynomial p is not the zero polynomial. Hence its zero set is a Lebesgue null set by Lemma 2.

By properties IIIa and IIIb, the inequation CP-rank (ϕ(A i (w))) ≥ r N/2 d 2 holds almost everywhere. By step II, we need r 2,d 2 -1 ≥ r N/2 d 2 almost everywhere for the shallower network to express functions the deeper network expresses.

The restructuring helps us keep the induction simple, and we can avoid formalizing some lemmas of the original proof. Furthermore, the restructured proof allows us to state a stronger property than in the original proof, which Cohen et al. independently discovered later [START_REF] Cohen | Inductive bias of deep convolutional networks through pooling geometry[END_REF]: The set S from Theorem 3 is not only a Lebesgue null set, but also a subset of the zero set of the polynomial p. This fact can be used to derive further properties of S. Zero sets of polynomials are well studied in algebraic geometry, where they are known as algebraic varieties. This generalization partially addresses an issue that arises when applying the theorem to actual implementations of CACs: Cohen et al. assume that the weight space of the deeper network is a Euclidean space, but in practice it will always be discrete. They also show that S is a closed null set, but since these can be arbitrarily dense, this gives no information about the discrete counterpart of S.

We can estimate the size of this discrete counterpart of S using our generalization in conjunction with a result from algebraic geometry [START_REF] Bürgisser | The probability that a slightly perturbed numerical analysis problem is difficult[END_REF][START_REF] Lotz | On the volume of tubular neighborhoods of real algebraic varieties[END_REF] that allows us to estimate the size of the ε-neighborhood of the zero set of a polynomial. The ε-neighborhood of S is a good approximation of the discrete counterpart of S if ε corresponds to the precision of computer arithmetic. Unfortunately, the estimate is trivial, unless we assume ε < 2 -170 000 , which largely exceeds the precision of modern computers. Thus, shallow CACs are perhaps more expressive than Theorem 3 suggests. On the other hand, our analysis is built upon inequalities, which only provide an upper bound. A mathematical result estimating the size of S with a lower bound would call for an entirely different approach.

Formal Libraries

Matrices We had several options for the choice of a matrix library, of which the most relevant were Isabelle's analysis library and Thiemann and Yamada's matrix library [START_REF] Thiemann | Matrices, Jordan normal forms, and spectral radius theory[END_REF]. The analysis library fixes the matrix dimensions using type parameters, a technique introduced by Harrison [START_REF] Harrison | A HOL theory of Euclidean space[END_REF]. The advantage of this approach is that the dimensions are part of the type and need not be stated as conditions. Moreover, it makes it possible to instantiate type classes depending on the type arguments. However, this approach is not practical when the dimensions are specified by terms. Therefore, we chose Thiemann and Yamada's library, which uses a single type for matrices of all dimensions and includes a rich collection of lemmas.

We extended the library in a few ways. We contributed a definition of the matrix rank, as the dimension of the space spanned by the matrix columns: definition (in vec_space) rank :: α mat ⇒ nat where rank A = vectorspace.dim F (span_vs (set (cols A)))

Moreover, we defined submatrices and proved that the rank of a matrix is larger than any submatrix with nonzero determinant, and that the rank is the maximum amount of linearly independent columns of the matrix.

Tensors The Tensor entry [START_REF] Prathamesh | Tensor product of matrices[END_REF] of the Archive of Formal Proofs might seem to be a good starting point for a formalization of tensors. However, despite its name, this library does not contain a type for tensors. It introduces the Kronecker product, which is equivalent to the tensor product but operates on the matricizations of tensors. The Groups, Rings and Modules entry [START_REF] Kobayashi | Groups, rings and modules[END_REF] of the Archive of Formal Proofs could have been another potential basis for our work. Unfortunately, it introduces the tensor product in a very abstract fashion and does not integrate well with other Isabelle libraries.

Instead, we introduced our own type for tensors, based on a list that specifies the dimension in each mode and a list containing all of its entries: typedef α tensor = {(ds :: nat list, as :: α list). length as = ∏ ds} We formalized addition, multiplication by scalars, product, matricization, and the CP-rank. We instantiated addition as a semigroup (semigroup_add) and product as a monoid (monoid_mult). Stronger type classes cannot be instantiated: Their axioms do not hold collectively for tensors of all sizes, even though they hold for fixed tensor sizes. For example, it is impossible to define addition for tensors of different sizes while satisfying the cancellation property a

+ c = b + c = ⇒ a = b.
For proving properties of addition, scalar multiplication, and product, we devised a powerful induction principle on tensors that uses tensor slices. The induction step amounts to showing a property for a tensor

A ∈ R M 1 ו••×M N assuming it holds for all slices A i ∈ R M 2 ו••×M N ,
which are obtained by fixing the first index i ∈ {1, . . . , M 1 }.

Matricization rearranges the entries of a tensor

A ∈ R M 1 ו••×M N into a matrix [A ] ∈ R I×J
. This rearrangement can be described as a bijection between {0, . . . , M 1 -1}ו • •× {0, . . . , M N -1} and {0, . . . , I -1} × {0, . . . , J -1}, assuming that indices start at 0. The operation is parameterized by a partition of the set of tensor indices into two sets

{r 1 < • • • < r K } {c 1 < • • • < c L } = {1, . . . , N}.
The proof of Theorem 3 uses only standard matricization, which partitions the indices into odd and even numbers, but we formalized the more general formulation [START_REF] Bader | Algorithm 862: MATLAB tensor classes for fast algorithm prototyping[END_REF]. The matrix [A ] has I = ∏ K i=1 r i rows and J = ∏ L j=1 c j columns. The rearrangement function is

(i 1 , . . . , i N ) → ∑ K k=1 i r k • ∏ k-1 k =1 M r k , ∑ L l=1 i c l • ∏ l-1 l =1 M c l
The indices i r 1 , . . . , i r K and i c 1 , . . . , i c L serve as digits in a mixed-base numeral system to specify the row and the column in the matricization, respectively. This is perhaps more obvious if we expand the sum and product operators and factor out the bases M i :

(i 1 , . . . , i N ) → i r 1 + M r 1 • (i r 2 + M r 2 • . . . • (i r K-1 + M r K-1 • i r K ) . . .)), i c 1 + M c 1 • (i c 2 + M c 2 • . . . • (i c L-1 + M c L-1 • i c L ) . . .))
To formalize the matricization operation, we defined a function calculating the digits of a number n in a given mixed-based numeral system:

fun encode :: nat list ⇒ nat ⇒ nat list where encode [] n = [] | encode (b # bs) n = (n mod b) # encode bs (n div b)
We then defined matricization as

definition matricize :: nat set ⇒ α tensor ⇒ α mat where matricize R A = mat (∏ sublist (dims A ) R) (∏ sublist (dims A ) (-R)) (λ(r, c). lookup A (weave R (encode (sublist (dims A ) R) r) (encode (sublist (dims A ) (-R)) c)))
The matrix constructor mat takes as arguments the matrix dimensions and a function that returns each matrix entry given the indices r and c. Defining this function amounts to finding the corresponding indices of the tensor, which are essentially the mixed-base encoding of r and c, but the digits of these two encoded numbers must be interleaved in an order specified by the set R = {r 1 , . . . , r K }.

To merge two lists of digits in the right way, we defined a function weave. This function is the counterpart of sublist from the standard library, which reduces a list to those entries whose indices belong to a set I: Other properties, such as the weave_sublists lemma above, are justified using an induction over the length of a list, with a case distinction in the induction step on whether the new list element is taken from xs or ys.

Another difficulty arises with the rule rank

[A ⊗ B] = rank [A ] • rank [B]
for standard matricization and tensors of even order, which seemed tedious to formalize. Restructuring the proof eliminates one of its two occurrences (Section 4). The remaining occurrence is used to show that rank [a 1 ⊗ • • • ⊗ a N ] = 1, where a 1 , . . . , a N are vectors and N is even. A simpler proof relies on the observation that the entries of

[a 1 ⊗ • • • ⊗ a N ] can be written as f (i) • g( j)
, where f depends only on the row index i, and g depends only on the column index j. Using this argument, rank To resolve this mismatch, we considered three options: (1) Prove that S is a Borel null set, which we believe is the case, although it does not follow trivially from S's being a subset of a Borel null set; (2) define the Lebesgue measure, using the already formalized Borel measure and measure completion; (3) formulate the theorem using the almost-everywhere quantifier (∀ ae ) instead of the null set predicate.

[a 1 ⊗ • • • ⊗ a N ] = 1 can
We chose the third approach, because it seemed simpler. Theorem 3, as expressed in Section 3, defines the set S as set of configurations in the weight space of the deeper network that express functions also expressible by the shallower network, and then states that S is a null set. In the formalization, we state it as follows: Almost everywhere in the weight space of the deeper network, the deeper network expresses functions not expressible by the shallower network. This formulation is equivalent to asserting that S is a subset of a null set, which we can easily prove for the Borel measure as well.

There is, however, another issue with the definition of the Borel measure from Isabelle's analysis library:

definition lborel :: (α :: euclidean_space) measure where lborel = distr (∏ M b ∈ Basis. interval_measure (λx. x)) borel (λf . ∑ b ∈ Basis. f b * R b)
The type α specifies the number of dimensions of the measure space. In our proof, the measure space is the weight space of the deeper network, and its dimension depends on the number N of inputs and the size r l of the weight matrices. The number of dimensions is a term in our proof. We described a similar issue with Isabelle's matrix library already. The solution is to provide a new definition of the Borel measure whose type does not fix the number of dimensions. The multidimensional Borel measure is the product measure (∏ M ) of the one-dimensional Borel measure (lborel :: real measure) with itself:

definition lborel f :: nat ⇒ (nat ⇒ real) measure where lborel f n = (∏ M b ∈ {. .< n}. lborel)
The argument n specifies the dimension of the measure space. Unlike with lborel, the measure space of lborel f n is not the entire universe of the type: Only functions that map to a default value for numbers ≥ n are contained in the measure space, which is available as space (lborel f n). With the above definition, we could prove the main lemmas about lborel f from the corresponding lemmas about lborel with little effort.

Multivariate Polynomials Multivariate polynomial libraries have been developed to support other formalization projects in Isabelle. Sternagel and Thiemann [START_REF] Sternagel | Executable multivariate polynomials[END_REF] formalized multivariate polynomials designed for execution, but the equality of polynomials is a custom predicate, which means that we cannot use Isabelle's simplifier to rewrite polynomial expressions. Immler and Maletzky [START_REF] Immler | Gröbner bases theory[END_REF] formalized an axiomatic approach to multivariate polynomials using type classes, but their focus is not on the evaluation homomorphism, which we need. Instead, we chose to extend a previously unpublished multivariate polynomial library by Lochbihler and Haftmann [START_REF] Haftmann | Towards abstract and executable multivariate polynomials in Isabelle[END_REF]. We derived induction principles and properties of the evaluation homomorphism and of nested multivariate polynomials. These were useful to formalize Lemma 2:

lemma lebesgue_mpoly_zero_set: fixes p :: real mpoly assumes p = 0 and vars p ⊆ {. .< n} shows {x ∈ space (lborel f n). insertion x p = 0} ∈ null_sets (lborel f n)

Formalization of the Fundamental Theorem

With the necessary libraries in place, we undertook the formal proof of the fundamental theorem of network capacity, starting with the CACs. A recursive datatype is appropriate to capture the hierarchical structure of these networks:

datatype α cac = Input nat | Conv α (α cac) | Pool (α cac) (α cac)
To simplify the proofs, Pool nodes are always binary. Pooling layers that merge more than two branches are represented by nesting Pool nodes to the right. The type variable α can be used to store weights. For networks without weights, it is set to nat × nat, which associates only the matrix dimension with each Conv node. For networks with weights, α is real mat, an actual matrix. These two network types are connected by insert_weights :: (nat × nat) cac ⇒ (nat ⇒ real) ⇒ real mat cac, which inserts weights into a weightless network. The weights are specified by the second argument f , of which only the first values f 0, f 1, . . . , f (k -1) are used, until the necessary number of weights, k, is reached. Sets over nat ⇒ real can be measured using lborel f .

The following function describes how the networks are evaluated, where ⊗ mv multiplies a matrix with a vector and component_mult multiplies vectors componentwise:

fun evaluate_net :: real mat cac ⇒ real vec list ⇒ real vec where evaluate_net (Input M) is = hd is | evaluate_net (Conv A m) is = A ⊗ mv evaluate_net m is | evaluate_net (Pool m 1 m 2 ) is = component_mult (evaluate_net m 1 (take (length (input_sizes m 1 )) is)) (evaluate_net m 2 (drop (length (input_sizes m 1 )) is))
The cac type can represent networks with arbitrary nesting of Conv and Pool nodes, going beyond the definition of CACs. Moreover, since we focus on the fundamental theorem of network capacities, it suffices to consider a deep model with d 1 = log 2 N and a shallow model with d 2 = 1. These are specified by generating functions:

fun deep_model 0 :: nat ⇒ nat list ⇒ (nat × nat) cac and deep_model :: nat ⇒ nat ⇒ nat list ⇒ (nat × nat) cac where Conv (Y,r 1 ) Pool Conv (r 1 ,r 0 ) Pool Conv (r 0 ,M) Input M Conv (r 0 ,M) Input M Conv (r 1 ,r 0 ) Pool Conv (r 0 ,M) Input M Conv (r 0 ,M) Input M (a) deep_model Y r 1 [r 0 , M] Conv (Y,Z) Pool Pool Pool Conv (Z,M) Input M Conv (Z,M) Input M Conv (Z,M) Input M Conv (Z,M) Input M (b) shallow_model Y Z M 3
Fig. 2: A deep and a shallow network represented using the cac datatype

deep_model 0 Y [] = Input Y | deep_model 0 Y (r # rs) = Pool (deep_model Y r rs) (deep_model Y r rs) | deep_model Y r rs = Conv (Y, r) (deep_model 0 r rs) fun shallow_model 0 :: nat ⇒ nat ⇒ nat ⇒ (nat × nat) cac where shallow_model 0 Z M 0 = Conv (Z, M) (Input M) | shallow_model 0 Z M (Suc N) = Pool (shallow_model 0 Z M 0) (shallow_model 0 Z M N) definition shallow_model :: nat ⇒ nat ⇒ nat ⇒ nat ⇒ (nat × nat) cac where shallow_model Y Z M N = Conv (Y, Z) (shallow_model 0 Z M N)
Two examples are given in Figure 2. The rest of the formalization follows the proof sketch presented in Section 4.

Step I The following operation computes a list, or vector, of tensors representing a network's function, each tensor standing for one component of the output vector:

fun tensors_from_net :: real mat cac ⇒ real tensor vec where tensors_from_net

(Input M) = Matrix.vec M (λi. unit_vec M i) | tensors_from_net (Conv A m) = mat_tensorlist_mult A (tensors_from_net m) (input_sizes m) | tensors_from_net (Pool m 1 m 2 ) = component_mult (tensors_from_net m 1 ) (tensors_from_net m 2 )
For an Input node, we return the list of unit vectors of length M. For a Conv node, we multiply the weight matrix A with the tensor list computed for the subnetwork m, using matrix-vector multiplication. For a Pool node, we compute, elementwise, the tensor products of the two tensor lists associated with the subnetworks m 1 and m 2 . If two networks express the same function, the representing tensors are the same: lemma tensors_from_net_eqI: assumes valid_net m 1 and valid_net m 2 and input_sizes m 1 = input_sizes m 2 and ∀is.

input_correct is -→ evaluate_net m 1 is = evaluate_net m 2 is shows tensors_from_net m 1 = tensors_from_net m 2
The fundamental theorem fixes an arbitrary deep network. It is useful to fix the deep network parameters in a locale-a sectioning mechanism that fixes variables and assumptions on them across definitions and lemmas: locale deep_model_correct_params = fixes rs :: nat list assumes deep: length rs ≥ 3 and no_zeros: r. r ∈ set rs = ⇒ r > 0

The list rs completely specifies one specific deep network model:

abbreviation deep_net = deep_model (rs ! 0) (rs ! 1) (tl (tl rs))
The other parameters of the deep network can be defined based on rs:

definition r = min (last rs) (last (butlast rs)) definition N_half = 2 length rs -3 definition weight_space_dim = count_weights deep_net
The shallow must have the same input and output sizes as the deep network, if it is to express the same function as the deep network. This leaves only the parameter Z = r 2,0 , which specifies the weight matrix sizes in the Conv nodes and the size of the vectors multiplied in the Pool nodes of the shallow network:

abbreviation shallow_net Z = shallow_model (rs ! 0) Z (last rs) (2 * N_half -1)
Following the proof sketch, we consider a single output component y i . We do so using a second locale that introduces a constant i for i. locale deep_model_correct_params_output_index = deep_model_correct_params + fixes i :: nat assumes output_index_valid: i < rs ! 0

Then we can define the tensor A i , which describes the behavior of the function expressed by the deep network at the output component y i , depending on the weight configuration w of the deep network:

definition A i w = tensors_from_net (insert_weights deep_net w) ! i
We want to analyze for which w the shallow network can express the same function, and is hence represented by the same tensor.

Step II We must show that if a tensor A represents the function expressed by the shallow network, then r 2,d 2 -1 ≥ CP-rank (ϕ(A )). For the fundamental theorem of network capacity, ϕ is the identity and d 2 = 1. Hence, it suffices to prove that Z = r 2,0 ≥ CP-rank (A ):

lemma cprank_shallow_model: cprank (tensors_from_net (insert_weights w (shallow_net Z)) ! i) ≤ Z
This lemma can be proved easily from the definition of the CP-rank.

Step III We define the polynomial p and prove that it has properties IIIa and IIIb. Defining p as a function is simple:

definition p func w = det (submatrix [A i w] rows_with_1 rows_with_1)
where [A i w] abbreviates the standard matricization matricize {n. even n} (A i w), and rows_with_1 is the set of row indices with 1s in the main diagonal for a specific weight configuration w that will be defined in Step IIIb. We try to make the submatrix as large as possible while maintaining the property that p is not the zero polynomial. The bound on Z in the statement of the final theorem is derived from the size of this submatrix. The function p func must be shown to be a polynomial function. We introduce a predicate polyfun, which is true if a function is a polynomial function:

definition polyfun N f = (∃p. vars p ⊆ N ∧ (∀x. insertion x p = f x))
This predicate is preserved from constant and linear functions through the tensor representation of the CAC, matricization, choice of submatrix, and determinant:

lemma polyfun_p: polyfun {. .< weight_space_dim} p func
Step IIIa We must show that if p(w) = 0, then CP-rank (A i (w)) ≥ r N/2 . The Isar proof is sketched below:

lemma if_polynomial_0_rank: assumes p func w = 0 shows r N_half ≤ cprank (A i w) proof - have r N_half = dim r (submatrix [A i w] rows_with_1 rows_with_1)
by calculating the size of the submatrix also have

• • • ≤ mrank [A i w]
using the assumption and the fact that the rank is larger than submatrices with nonzero determinant also have

• • • ≤ cprank (A i w)
using Lemma 1 finally show ?thesis . qed

Step IIIb To prove that p is not the zero polynomial, we must exhibit a witness weight configuration where p is nonzero. Since weights are arranged in matrices, we define concrete matrix types: matrices with 1s on their main diagonal and 0s elsewhere (eye_matrix), matrices with 1s everywhere (all1_matrix), and matrices with 1s in the first column and 0s elsewhere (copy_first_matrix). For example, the last matrix type is defined as follows: definition copy_first_matrix :: nat ⇒ nat ⇒ real mat where copy_first_matrix nr nc = mat nr nc (λ(r, c). if c = 0 then 1 else 0)

For each matrix type, we show how it behaves under multiplication with a vector:

lemma mult_copy_first_matrix: assumes i < nr and dim v v > 0 shows (copy_first_matrix nr (dim v v) ⊗ mv v) ! i = v ! 0
Using these matrices, we can define the deep network containing the witness weights: The network's structure is identical to deep_model. For each Conv node, we carefully choose one of the three matrix types we defined, such that the representing tensor of this network has as many 1s as possible on the main diagonal and 0s elsewhere. This in turn ensures that its matricization has as many 1s as possible on its main diagonal and 0s elsewhere. The rows_with_1 constant specifies the row indices that contain the 1s.

The witness weights can be extracted from the witness network as follows:

definition witness_weights :: nat ⇒ real where witness_weights = (εw. witness (rs ! 0) (rs ! 1) (tl (tl rs)) = insert_weights deep_net w)

This could also be achieved without using Hilbert's choice operator, by defining a recursive function that extracts the weights from weighted networks. We prove that the representing tensor of the witness network, which is equal to A i witness_weights, has the desired form. This step is rather involved: We show how the defined matrices act in the network and perform a tedious induction over the witness network. Then we can show that the submatrix characterized by rows_with_1 of the matricization of this tensor is the identity matrix of size r N_half :

lemma witness_submatrix: submatrix [A i witness_weights] rows_with_1 rows_with_1 = eye_matrix r N_half r N_half
As a consequence of this lemma, the determinant of this submatrix, which is the definition of p func , is nonzero. Therefore, p is not the zero polynomial: lemma polynomial_not_zero:

p func witness_weights = 0

Fundamental Theorem The results of Steps II and III can be used to establish the fundamental theorem of network capacity:

theorem fundamental_theorem_of_network_capacity: ∀ ae w d w.r.t. lborel f weight_space_dim. w s Z. Z < r N_half ∧ ∀is. input_correct is -→ evaluate_net (insert_weights deep_net w d ) is = evaluate_net (insert_weights (shallow_net Z) w s ) is
The r N_half bound corresponds to the size of the identity matrix in witness_submatrix.

The theorem statement is independent of the tensor library, and is therefore correct regardless of whether the library faithfully captures tensor-related notions.

Discussion and Related Work

Extension with Shared Weights and the Generalized Theorem We formalized the fundamental theorem for nonshared weights. The case of shared weights is so similar that Cohen et al. discharge it with a one-sentence proof by analogy. Using copy and paste, we could easily extend the formalization to cover this case, but to reduce code duplication we would need more abstract definitions of the involved networks.

The generalized theorem of network capacity is mostly a straightforward generalization. To formalize it, we would need to define CACs for arbitrary depths, which our datatype allows. Moreover, we would need to define the function ϕ and prove some of its properties. Then, we would generalize the existing lemmas. We focused on the fundamental theorem because it contains all the essential ideas.

Sledgehammer and SMT To discharge proof obligations, we used Sledgehammer [START_REF] Paulson | Three years of experience with Sledgehammer, a practical link between automatic and interactive theorem provers[END_REF] extensively. This Isabelle tool heuristically selects a few hundred lemmas from the thousands available (using machine learning [START_REF] Blanchette | A learning-based fact selector for Isabelle/HOL[END_REF]); translates the proof obligation and the selected lemmas to first-order logic; invokes external automatic theorem provers on the translated problem; and, in case of success, translates the derivations found by the external provers to Isar proof texts that can be inserted in the formalization. In the best-case scenario, Sledgehammer quickly produces a one-line proof text consisting of an invocation of the metis proof method [START_REF] Paulson | Source-level proof reconstruction for interactive theorem proving[END_REF], Isabelle's internal superposition prover. Unfortunately, Sledgehammer sometimes returns only cryptic structured Isar proofs [START_REF] Blanchette | Semi-intelligible Isar proofs from machine-generated proofs[END_REF] or, if all else fails, proofs that depend on the smt method [START_REF] Böhme | Fast LCF-style proof reconstruction for Z3[END_REF].

The smt method relies on the SMT solver Z3 [START_REF] De Moura | Z3: An efficient SMT solver[END_REF] to find a proof, which it then replays using Isabelle's inference kernel. Relying on a highly heuristic third-party prover is fragile; some proofs that are fast with a given version of the prover might time out with a different version, or be unreplayable due to some incompleteness in smt. As a result, entries in the Archive of Formal Proofs cannot use it. Sledgehammer often generates smt proofs, especially in proof obligations about sums and products of reals, existential quantifiers, and λ-expressions. We ended up with over 60 invocations of smt, which we later replaced one by one with structured Isar proofs, a tedious process. The following equation on reals is an example that can only be proved by smt, with suitable lemmas:

∑ i∈I ∑ j∈J a • b • f (i) • g( j) = ∑ i∈I a • f (i) • ∑ j∈J b • g( j)
We could not solve it with other proof methods without engaging in a detailed proof involving multiple steps. This particular example relies on smt's partial support for λ-expressions through λ-lifting, an instance of what we would call "easy higher-order."

Similar Theoretical Results about Other Deep Learning Architectures CACs are relatively easy to analyze but little used in practice. In a follow-up paper [START_REF] Cohen | Convolutional rectifier networks as generalized tensor decompositions[END_REF], Cohen et al. connected their tensor analysis of CACs to the frequently used CNNs with rectified linear unit (ReLU) activation. Unlike CACs, ReLU CNNs with average pooling are not universal-that is, even shallow networks of arbitrary size cannot express all functions a deeper network can express. Moreover, ReLU CNNs do not enjoy complete depth efficiency; the analogue of the set S for those networks has a Lebesgue measure greater than zero. This leads Cohen et al. to conjecture that CACs could become a leading approach for deep learning, once suitable training algorithms have been developed.

Related Formal Proofs

We are aware of a few other formalizations of machine learning algorithms, including hidden Markov models [START_REF] Liu | On the formal analysis of HMM using theorem proving[END_REF], perceptrons [START_REF] Murphy | Certified convergent perceptron learning[END_REF], expectation maximization, and support vector machines [START_REF] Bhat | Syntactic foundations for machine learning[END_REF]. To our knowledge, our work is the first formalization about deep learning. Some of the mathematical libraries underlying our formalizations have counterparts in other systems, notably Coq. For example, the Mathematical Components include comprehensive matrix theories [START_REF] Bertot | Canonical big operators[END_REF], which are naturally expressed using dependent types. The tensor formalization by Boender [START_REF] Boender | Formalization of quantum protocols using Coq[END_REF] restricts itself to the Kronecker product on matrices. Bernard et al. [START_REF] Bernard | Formal proofs of transcendence for e and π as an application of multivariate and symmetric polynomials[END_REF] formalized multivariate polynomials and used them to show the transcendence of e and π. Kam formalized the Lebesgue measure as part of a formalization of the Lebesgue integral, which in turn was used to state and prove Markov's inequality [START_REF] Kam | Case Studies in Proof Checking[END_REF].

Conclusion

We applied a proof assistant to formalize a recent result in a field where they have been little used before, namely machine learning. We found that the functionality and libraries of a modern proof assistant such as Isabelle/HOL were mostly up to the task. Beyond the formal proof of the fundamental theorem of network capacity, our main contribution is a general library of tensors.

Admittedly, even the formalization of fairly short pen-and-paper proofs can require a lot of work, partly because of the need to develop and extend libraries. On the other hand, not only does the process lead to a computer verification of the result, but it can also reveal new ideas and results. The generalization and simplifications we discovered illustrate how formal proof development can be beneficial to research outside the small world of interactive theorem proving.

Fig. 1 :

 1 Fig. 1: Definition and hierarchical structure of a CAC with d layers

  lemma weave_sublists: weave I (sublist as I) (sublist as (-I)) = as The main concern when defining such a function is to determine how it should behave in corner cases-in our scenario, when I = {} and the first list argument is nonempty. We settled on a definition such that the property length (weave I xs ys) = length xs + length ys holds unconditionally: definition weave :: nat set ⇒ α list ⇒ α list ⇒ α list where weave I xs ys = map (λi. if i∈I then xs ! |{a ∈ I. a < i}| else ys ! |{a ∈ -I. a < i}|) [0 . .< length xs + length ys] (The ! operator returns the list element at a given index.) This definition allows us to prove lemmas about weave I xs ys ! a and length (weave I xs ys) very easily.

  For the deep model, the arguments Y # r # rs correspond to the weight matrix sizes [r 1,d (= Y), r 1,d-1 , . . . , r 1,0 , r 1,-1 (= M)]. For the shallow model, the arguments Y, Z, M correspond to the parameters r 2,1 (= Y), r 2,0 , r 2,-1 (= M), and N gives the number of inputs minus 1.

fun witness 0 :

 0 : nat ⇒ nat list ⇒ real mat cac and witness :: nat ⇒ nat ⇒ nat list ⇒ real mat cac where witness 0 Y [] = Input Y | witness 0 Y (r # rs) = Pool (witness Y r rs) (witness Y r rs) | witness Y r rs = Conv ((if length rs = 0 then eye_matrix else if length rs = 1 then all1_matrix else copy_first_matrix) Y r) (witness 0 r rs)

  be shown for generalized matricization and an arbitrary N, which we used to prove Lemma 1:Lebesgue Measure Isabelle's analysis library defines the Borel measure on R n but not the closely related Lebesgue measure. The Lebesgue measure is the completion of the Borel measure. The two measures are identical on all sets that are Borel measurable, but the Lebesgue measure has more measurable sets. The proof by Cohen et al. allows us to show that the set S defined in Theorem 3 is a subset of a Borel null set. It follows that S is a Lebesgue null set, but not necessarily a Borel null set.

	lemma matrix_rank_le_cp_rank:
	fixes A :: (α :: field) tensor
	shows mrank (matricize R A) ≤ cprank A

Acknowledgment We thank Lukas Bentkamp, Robert Lewis, Anders Schlichtkrull, Mark Summerfield, and the anonymous reviewers for suggesting many textual improvements. The work has received funding from the European Research Council under the European Union's Horizon 2020 research and innovation program (grant agreement No. 713999, Matryoshka).