Automatic Certified Differentiation in Lean
Ramy Shahin
Abstract
Automatic differentiation (the automatic computation of numerical function derivatives) has many applications, especially in scientific computing and machine learning. Several approaches to automate the calculation of derivatives have been presented. Common challenges facing those approaches include (1) having to define derivative rules for different classes of functions, (2) having to manipulate program symbols to understand the semantics of the function being differentiated, and construct the derivative function, and (3), more importantly, ensuring that the calculated derivative is correct. In this paper, we present an approach for automatic certified differentiation using the Lean proof assistant. By certified, we mean a correctness certificate is computed together with the derivative function and a domain on which the derivative is guaranteed to be valid. Our approach leverages existing derivative theorems included in the Mathlib Lean library instead of having to define our own rules. We also utilize Lean metaprogramming to manipulate the symbolic structure of the input function, and to construct the derivative function. The correctness certificate is computed step-wise as we apply Mathlib theorems. To make the search efficient, we index the derivative theorems by the function they differentiate. We evaluate our approach on 500 randomly generated functions: with the index, all of them are differentiated, with a median time of 0.18\,s per function, 8.6 times faster than without the index.
Create a lesson
Related papers
Construction and formal verification of a special topology on Zn: characterization of connected subsets
Ignacio Vega-Páez
On the Complexity of Computing with p-adic Lattices
Pierre Fromonot, Mercedes Haiech, Tristan Vaccon
Barik transform and Barik eliminant: a novel algebraic method to solve polynomial equations in the sine and cosine of one variable
Sandipan Bandyopadhyay
One Loss Resolves Signed Rank-One Gradient Fibers: Exact Decoding on Cycle and Theta Blocks
Junwen Lou, Shuo Tian, Penghui Liu
Deterministic Root-Finding over Finite Fields with Elliptic Curves
Pierre-Jean Spaenlehauer
An algorithmic construction of Nullstellensatz certificates for graph automorphism groups
Ivan Drecun