4 research outputs found
Dandelion: Certified Approximations of Elementary Functions
Elementary function operations such as sin and exp cannot in general be computed exactly on today's digital computers, and thus have to be approximated. The standard approximations in library functions typically provide only a limited set of precisions, and are too inefficient for many applications. Polynomial approximations that are customized to a limited input domain and output accuracy can provide superior performance. In fact, the Remez algorithm computes the best possible approximation for a given polynomial degree, but has so far not been formally verified. This paper presents Dandelion, an automated certificate checker for polynomial approximations of elementary functions computed with Remez-like algorithms that is fully verified in the HOL4 theorem prover. Dandelion checks whether the difference between a polynomial approximation and its target reference elementary function remains below a given error bound for all inputs in a given constraint. By extracting a verified binary with the CakeML compiler, Dandelion can validate certificates within a reasonable time, fully automating previous manually verified approximations
Implementation and Synthesis of Math Library Functions
Achieving speed and accuracy for math library functions like exp, sin, and
log is difficult. This is because low-level implementation languages like C do
not help math library developers catch mathematical errors, build
implementations incrementally, or separate high-level and low-level decision
making. This ultimately puts development of such functions out of reach for all
but the most experienced experts. To address this, we introduce MegaLibm, a
domain-specific language for implementing, testing, and tuning math library
implementations. MegaLibm is safe, modular, and tunable. Implementations in
MegaLibm can automatically detect mathematical mistakes like sign flips via
semantic wellformedness checks, and components like range reductions can be
implemented in a modular, composable way, simplifying implementations. Once the
high-level algorithm is done, tuning parameters like working precisions and
evaluation schemes can be adjusted through orthogonal tuning parameters to
achieve the desired speed and accuracy. MegaLibm also enables math library
developers to work interactively, compiling, testing, and tuning their
implementations and invoking tools like Sollya and type-directed synthesis to
complete components and synthesize entire implementations. MegaLibm can express
8 state-of-the-art math library implementations with comparable speed and
accuracy to the original C code, and can synthesize 5 variations and 3
from-scratch implementations with minimal guidance.Comment: 25 pages, 12 figure
Verified compilation and optimization of floating-point kernels
When verifying safety-critical code on the level of source code, we trust the compiler to produce machine code that preserves the behavior of the source code. Trusting a verified compiler is easy. A rigorous machine-checked proof shows that the compiler correctly translates source code into machine code. Modern verified compilers (e.g. CompCert and CakeML) have rich input languages, but only rudimentary support for floating-point arithmetic. In fact, state-of-the-art verified compilers only implement and verify an inflexible one-to-one translation from floating-point source code to machine code. This translation completely ignores that floating-point arithmetic is actually a discrete representation of the continuous real numbers. This thesis presents two extensions improving floating-point arithmetic in CakeML. First, the thesis demonstrates verified compilation of elementary functions to floating-point code in: Dandelion, an automatic verifier for polynomial approximations of elementary functions; and libmGen, a proof-producing compiler relating floating-point machine code to the implemented real-numbered elementary function. Second, the thesis demonstrates verified optimization of floating-point code in: Icing, a floating-point language extending standard floating-point arithmetic with optimizations similar to those used by unverified compilers, like GCC and LLVM; and RealCake, an extension of CakeML with Icing into the first fully verified optimizing compiler for floating-point arithmetic.Bei der Verifizierung von sicherheitsrelevantem Quellcode vertrauen wir dem Compiler, dass er Maschinencode ausgibt, der sich wie der Quellcode verhĂ€lt. Man kann ohne weiteres einem verifizierten Compiler vertrauen. Ein rigoroser maschinen-ĂŒ}berprĂŒfter Beweis zeigt, dass der Compiler Quellcode in korrekten Maschinencode ĂŒbersetzt. Moderne verifizierte Compiler (z.B. CompCert und CakeML) haben komplizierte Eingabesprachen, aber unterstĂŒtzen Gleitkommaarithmetik nur rudimentĂ€r. De facto implementieren und verifizieren hochmoderne verifizierte Compiler fĂŒr Gleitkommaarithmetik nur eine starre eins-zu-eins Ăbersetzung von Quell- zu Maschinencode. Diese Ăbersetzung ignoriert vollstĂ€ndig, dass Gleitkommaarithmetik eigentlich eine diskrete ReprĂ€sentation der kontinuierlichen reellen Zahlen ist. Diese Dissertation prĂ€sentiert zwei Erweiterungen die Gleitkommaarithmetik in CakeML verbessern. Zuerst demonstriert die Dissertation verifizierte Ăbersetzung von elementaren Funktionen in Gleitkommacode mit: Dandelion, einem automatischen Verifizierer fĂŒr Polynomapproximierungen von elementaren Funktionen; und libmGen, einen Beweis-erzeugenden Compiler der Gleitkommacode in Relation mit der implementierten elementaren Funktion setzt. Dann demonstriert die Dissertation verifizierte Optimierung von Gleitkommacode mit: Icing, einer Gleitkommasprache die Gleitkommaarithmetik mit Optimierungen erweitert die Ă€hnlich zu denen in unverifizierten Compilern, wie GCC und LLVM, sind; und RealCake, eine Erweiterung von CakeML mit Icing als der erste vollverifizierte Compiler fĂŒr Gleitkommaarithmetik
Exact Real Search: Formalised Optimisation and Regression in Constructive Univalent Mathematics
The real numbers are important in both mathematics and computation theory.
Computationally, real numbers can be represented in several ways; most commonly
using inexact floating-point data-types, but also using exact
arbitrary-precision data-types which satisfy the expected mathematical
properties of the reals. This thesis is concerned with formalising properties
of certain types for exact real arithmetic, as well as utilising them
computationally for the purposes of search, optimisation and regression.
We develop, in a constructive and univalent type-theoretic foundation of
mathematics, a formalised framework for performing search, optimisation and
regression on a wide class of types. This framework utilises Mart\'in
Escard\'o's prior work on searchable types, along with a convenient version of
ultrametric spaces -- which we call closeness spaces -- in order to
consistently search certain infinite types using the functional programming
language and proof assistant Agda.
We formally define and prove the convergence properties of type-theoretic
variants of global optimisation and parametric regression, problems related to
search from the literature of analysis. As we work in a constructive setting,
these convergence theorems yield computational algorithms for correct
optimisation and regression on the types of our framework.
Importantly, we can instantiate our framework on data-types from the
literature of exact real arithmetic, allowing us to perform our variants of
search, optimisation and regression on ternary signed-digit encodings of the
real numbers, as well as a simplified version of Hans-J. Boehm's functional
encodings of real numbers. Furthermore, we contribute to the extensive work on
ternary signed-digits by formally verifying the definition of certain exact
real arithmetic operations using the Escard\'o-Simpson interval object
specification of compact intervals.Comment: A thesis submitted to the University of Birmingham for the degree of
Doctor of Philosophy. 198 pages. Supervised by Dan Ghica and Mart\'in
Escard\'