Archive of Formal Proofs https://www.isa-afp.org The Archive of Formal Proofs is a collection of proof libraries, examples, and larger scientific developments, mechanically checked in the theorem prover Isabelle. 13 Mar 2018 00:00:00 +0000 Weight-Balanced Trees https://www.isa-afp.org/entries/Weight_Balanced_Trees.html https://www.isa-afp.org/entries/Weight_Balanced_Trees.html Tobias Nipkow, Stefan Dirix 13 Mar 2018 00:00:00 +0000 This theory provides a verified implementation of weight-balanced trees following the work of <a href="https://doi.org/10.1017/S0956796811000104">Hirai and Yamamoto</a> who proved that all parameters in a certain range are valid, i.e. guarantee that insertion and deletion preserve weight-balance. Instead of a general theorem we provide parameterized proofs of preservation of the invariant that work for many (all?) valid parameters. CakeML https://www.isa-afp.org/entries/CakeML.html https://www.isa-afp.org/entries/CakeML.html Lars Hupel 12 Mar 2018 00:00:00 +0000 CakeML is a functional programming language with a proven-correct compiler and runtime system. This entry contains an unofficial version of the CakeML semantics that has been exported from the Lem specifications to Isabelle. Additionally, there are some hand-written theory files that adapt the exported code to Isabelle and port proofs from the HOL4 formalization, e.g. termination and equivalence proofs. A Theory of Architectural Design Patterns https://www.isa-afp.org/entries/Architectural_Design_Patterns.html https://www.isa-afp.org/entries/Architectural_Design_Patterns.html Diego Marmsoler 01 Mar 2018 00:00:00 +0000 The following document formalizes and verifies several architectural design patterns. Each pattern specification is formalized in terms of a locale where the locale assumptions correspond to the assumptions which a pattern poses on an architecture. Thus, pattern specifications may build on top of each other by interpreting the corresponding locale. A pattern is verified using the framework provided by the AFP entry Dynamic Architectures. Currently, the document consists of formalizations of 4 different patterns: the singleton, the publisher subscriber, the blackboard pattern, and the blockchain pattern. Thereby, the publisher component of the publisher subscriber pattern is modeled as an instance of the singleton pattern and the blackboard pattern is modeled as an instance of the publisher subscriber pattern. In general, this entry provides the first steps towards an overall theory of architectural design patterns. Hoare Logics for Time Bounds https://www.isa-afp.org/entries/Hoare_Time.html https://www.isa-afp.org/entries/Hoare_Time.html Maximilian P. L. Haslbeck, Tobias Nipkow 26 Feb 2018 00:00:00 +0000 We study three different Hoare logics for reasoning about time bounds of imperative programs and formalize them in Isabelle/HOL: a classical Hoare like logic due to Nielson, a logic with potentials due to Carbonneaux <i>et al.</i> and a <i>separation logic</i> following work by Atkey, Chaguérand and Pottier. These logics are formally shown to be sound and complete. Verification condition generators are developed and are shown sound and complete too. We also consider variants of the systems where we abstract from multiplicative constants in the running time bounds, thus supporting a big-O style of reasoning. Finally we compare the expressive power of the three systems. Treaps https://www.isa-afp.org/entries/Treaps.html https://www.isa-afp.org/entries/Treaps.html Maximilian Haslbeck, Manuel Eberl, Tobias Nipkow 06 Feb 2018 00:00:00 +0000 <p> A Treap is a binary tree whose nodes contain pairs consisting of some payload and an associated priority. It must have the search-tree property w.r.t. the payloads and the heap property w.r.t. the priorities. Treaps are an interesting data structure that is related to binary search trees (BSTs) in the following way: if one forgets all the priorities of a treap, the resulting BST is exactly the same as if one had inserted the elements into an empty BST in order of ascending priority. This means that a treap behaves like a BST where we can pretend the elements were inserted in a different order from the one in which they were actually inserted. </p> <p> In particular, by choosing these priorities at random upon insertion of an element, we can pretend that we inserted the elements in <em>random order</em>, so that the shape of the resulting tree is that of a random BST no matter in what order we insert the elements. This is the main result of this formalisation.</p> A verified factorization algorithm for integer polynomials with polynomial complexity https://www.isa-afp.org/entries/LLL_Factorization.html https://www.isa-afp.org/entries/LLL_Factorization.html Jose Divasón, Sebastiaan Joosten, René Thiemann, Akihisa Yamada 06 Feb 2018 00:00:00 +0000 Short vectors in lattices and factors of integer polynomials are related. Each factor of an integer polynomial belongs to a certain lattice. When factoring polynomials, the condition that we are looking for an irreducible polynomial means that we must look for a small element in a lattice, which can be done by a basis reduction algorithm. In this development we formalize this connection and thereby one main application of the LLL basis reduction algorithm: an algorithm to factor square-free integer polynomials which runs in polynomial time. The work is based on our previous Berlekamp–Zassenhaus development, where the exponential reconstruction phase has been replaced by the polynomial-time basis reduction algorithm. Thanks to this formalization we found a serious flaw in a textbook. First-Order Terms https://www.isa-afp.org/entries/First_Order_Terms.html https://www.isa-afp.org/entries/First_Order_Terms.html Christian Sternagel, René Thiemann 06 Feb 2018 00:00:00 +0000 We formalize basic results on first-order terms, including a first-order unification algorithm, as well as well-foundedness of the subsumption order. This entry is part of the <i>Isabelle Formalization of Rewriting</i> <a href="http://cl-informatik.uibk.ac.at/isafor">IsaFoR</a>, where first-order terms are omni-present: the unification algorithm is used to certify several confluence and termination techniques, like critical-pair computation and dependency graph approximations; and the subsumption order is a crucial ingredient for completion. The Error Function https://www.isa-afp.org/entries/Error_Function.html https://www.isa-afp.org/entries/Error_Function.html Manuel Eberl 06 Feb 2018 00:00:00 +0000 <p> This entry provides the definitions and basic properties of the complex and real error function erf and the complementary error function erfc. Additionally, it gives their full asymptotic expansions. </p> A verified LLL algorithm https://www.isa-afp.org/entries/LLL_Basis_Reduction.html https://www.isa-afp.org/entries/LLL_Basis_Reduction.html Jose Divasón, Sebastiaan Joosten, René Thiemann, Akihisa Yamada 02 Feb 2018 00:00:00 +0000 The Lenstra-Lenstra-Lovász basis reduction algorithm, also known as LLL algorithm, is an algorithm to find a basis with short, nearly orthogonal vectors of an integer lattice. Thereby, it can also be seen as an approximation to solve the shortest vector problem (SVP), which is an NP-hard problem, where the approximation quality solely depends on the dimension of the lattice, but not the lattice itself. The algorithm also possesses many applications in diverse fields of computer science, from cryptanalysis to number theory, but it is specially well-known since it was used to implement the first polynomial-time algorithm to factor polynomials. In this work we present the first mechanized soundness proof of the LLL algorithm to compute short vectors in lattices. The formalization follows a textbook by von zur Gathen and Gerhard. Formalization of Bachmair and Ganzinger's Ordered Resolution Prover https://www.isa-afp.org/entries/Ordered_Resolution_Prover.html https://www.isa-afp.org/entries/Ordered_Resolution_Prover.html Anders Schlichtkrull, Jasmin Christian Blanchette, Dmitriy Traytel, Uwe Waldmann 18 Jan 2018 00:00:00 +0000 This Isabelle/HOL formalization covers Sections 2 to 4 of Bachmair and Ganzinger's "Resolution Theorem Proving" chapter in the <em>Handbook of Automated Reasoning</em>. This includes soundness and completeness of unordered and ordered variants of ground resolution with and without literal selection, the standard redundancy criterion, a general framework for refutational theorem proving, and soundness and completeness of an abstract first-order prover. Gromov Hyperbolicity https://www.isa-afp.org/entries/Gromov_Hyperbolicity.html https://www.isa-afp.org/entries/Gromov_Hyperbolicity.html Sebastien Gouezel 16 Jan 2018 00:00:00 +0000 A geodesic metric space is Gromov hyperbolic if all its geodesic triangles are thin, i.e., every side is contained in a fixed thickening of the two other sides. While this definition looks innocuous, it has proved extremely important and versatile in modern geometry since its introduction by Gromov. We formalize the basic classical properties of Gromov hyperbolic spaces, notably the Morse lemma asserting that quasigeodesics are close to geodesics, the invariance of hyperbolicity under quasi-isometries, we define and study the Gromov boundary and its associated distance, and prove that a quasi-isometry between Gromov hyperbolic spaces extends to a homeomorphism of the boundaries. We also prove a less classical theorem, by Bonk and Schramm, asserting that a Gromov hyperbolic space embeds isometrically in a geodesic Gromov-hyperbolic space. As the original proof uses a transfinite sequence of Cauchy completions, this is an interesting formalization exercise. Along the way, we introduce basic material on isometries, quasi-isometries, Lipschitz maps, geodesic spaces, the Hausdorff distance, the Cauchy completion of a metric space, and the exponential on extended real numbers. An Isabelle/HOL formalisation of Green's Theorem https://www.isa-afp.org/entries/Green.html https://www.isa-afp.org/entries/Green.html Mohammad Abdulaziz, Lawrence C. Paulson 11 Jan 2018 00:00:00 +0000 We formalise a statement of Green’s theorem—the first formalisation to our knowledge—in Isabelle/HOL. The theorem statement that we formalise is enough for most applications, especially in physics and engineering. Our formalisation is made possible by a novel proof that avoids the ubiquitous line integral cancellation argument. This eliminates the need to formalise orientations and region boundaries explicitly with respect to the outwards-pointing normal vector. Instead we appeal to a homological argument about equivalences between paths. Taylor Models https://www.isa-afp.org/entries/Taylor_Models.html https://www.isa-afp.org/entries/Taylor_Models.html Christoph Traut, Fabian Immler 08 Jan 2018 00:00:00 +0000 We present a formally verified implementation of multivariate Taylor models. Taylor models are a form of rigorous polynomial approximation, consisting of an approximation polynomial based on Taylor expansions, combined with a rigorous bound on the approximation error. Taylor models were introduced as a tool to mitigate the dependency problem of interval arithmetic. Our implementation automatically computes Taylor models for the class of elementary functions, expressed by composition of arithmetic operations and basic functions like exp, sin, or square root. The Falling Factorial of a Sum https://www.isa-afp.org/entries/Falling_Factorial_Sum.html https://www.isa-afp.org/entries/Falling_Factorial_Sum.html Lukas Bulwahn 22 Dec 2017 00:00:00 +0000 This entry shows that the falling factorial of a sum can be computed with an expression using binomial coefficients and the falling factorial of its summands. The entry provides three different proofs: a combinatorial proof, an induction proof and an algebraic proof using the Vandermonde identity. The three formalizations try to follow their informal presentations from a Mathematics Stack Exchange page as close as possible. The induction and algebraic formalization end up to be very close to their informal presentation, whereas the combinatorial proof first requires the introduction of list interleavings, and significant more detail than its informal presentation. The Median-of-Medians Selection Algorithm https://www.isa-afp.org/entries/Median_Of_Medians_Selection.html https://www.isa-afp.org/entries/Median_Of_Medians_Selection.html Manuel Eberl 21 Dec 2017 00:00:00 +0000 <p>This entry provides an executable functional implementation of the Median-of-Medians algorithm for selecting the <em>k</em>-th smallest element of an unsorted list deterministically in linear time. The size bounds for the recursive call that lead to the linear upper bound on the run-time of the algorithm are also proven. </p> The Mason–Stothers Theorem https://www.isa-afp.org/entries/Mason_Stothers.html https://www.isa-afp.org/entries/Mason_Stothers.html Manuel Eberl 21 Dec 2017 00:00:00 +0000 <p>This article provides a formalisation of Snyder’s simple and elegant proof of the Mason&ndash;Stothers theorem, which is the polynomial analogue of the famous abc Conjecture for integers. Remarkably, Snyder found this very elegant proof when he was still a high-school student.</p> <p>In short, the statement of the theorem is that three non-zero coprime polynomials <em>A</em>, <em>B</em>, <em>C</em> over a field which sum to 0 and do not all have vanishing derivatives fulfil max{deg(<em>A</em>), deg(<em>B</em>), deg(<em>C</em>)} < deg(rad(<em>ABC</em>)) where the rad(<em>P</em>) denotes the <em>radical</em> of <em>P</em>, i.&thinsp;e. the product of all unique irreducible factors of <em>P</em>.</p> <p>This theorem also implies a kind of polynomial analogue of Fermat’s Last Theorem for polynomials: except for trivial cases, <em>A<sup>n</sup></em> + <em>B<sup>n</sup></em> + <em>C<sup>n</sup></em> = 0 implies n&nbsp;&le;&nbsp;2 for coprime polynomials <em>A</em>, <em>B</em>, <em>C</em> over a field.</em></p> Dirichlet L-Functions and Dirichlet's Theorem https://www.isa-afp.org/entries/Dirichlet_L.html https://www.isa-afp.org/entries/Dirichlet_L.html Manuel Eberl 21 Dec 2017 00:00:00 +0000 <p>This article provides a formalisation of Dirichlet characters and Dirichlet <em>L</em>-functions including proofs of their basic properties &ndash; most notably their analyticity, their areas of convergence, and their non-vanishing for &Re;(s) &ge; 1. All of this is built in a very high-level style using Dirichlet series. The proof of the non-vanishing follows a very short and elegant proof by Newman, which we attempt to reproduce faithfully in a similar level of abstraction in Isabelle.</p> <p>This also leads to a relatively short proof of Dirichlet’s Theorem, which states that, if <em>h</em> and <em>n</em> are coprime, there are infinitely many primes <em>p</em> with <em>p</em> &equiv; <em>h</em> (mod <em>n</em>).</p> Operations on Bounded Natural Functors https://www.isa-afp.org/entries/BNF_Operations.html https://www.isa-afp.org/entries/BNF_Operations.html Jasmin Christian Blanchette, Andrei Popescu, Dmitriy Traytel 19 Dec 2017 00:00:00 +0000 This entry formalizes the closure property of bounded natural functors (BNFs) under seven operations. These operations and the corresponding proofs constitute the core of Isabelle's (co)datatype package. To be close to the implemented tactics, the proofs are deliberately formulated as detailed apply scripts. The (co)datatypes together with (co)induction principles and (co)recursors are byproducts of the fixpoint operations LFP and GFP. Composition of BNFs is subdivided into four simpler operations: Compose, Kill, Lift, and Permute. The N2M operation provides mutual (co)induction principles and (co)recursors for nested (co)datatypes. The string search algorithm by Knuth, Morris and Pratt https://www.isa-afp.org/entries/Knuth_Morris_Pratt.html https://www.isa-afp.org/entries/Knuth_Morris_Pratt.html Fabian Hellauer, Peter Lammich 18 Dec 2017 00:00:00 +0000 The Knuth-Morris-Pratt algorithm is often used to show that the problem of finding a string <i>s</i> in a text <i>t</i> can be solved deterministically in <i>O(|s| + |t|)</i> time. We use the Isabelle Refinement Framework to formulate and verify the algorithm. Via refinement, we apply some optimisations and finally use the <em>Sepref</em> tool to obtain executable code in <em>Imperative/HOL</em>. Stochastic Matrices and the Perron-Frobenius Theorem https://www.isa-afp.org/entries/Stochastic_Matrices.html https://www.isa-afp.org/entries/Stochastic_Matrices.html René Thiemann 22 Nov 2017 00:00:00 +0000 Stochastic matrices are a convenient way to model discrete-time and finite state Markov chains. The Perron&ndash;Frobenius theorem tells us something about the existence and uniqueness of non-negative eigenvectors of a stochastic matrix. In this entry, we formalize stochastic matrices, link the formalization to the existing AFP-entry on Markov chains, and apply the Perron&ndash;Frobenius theorem to prove that stationary distributions always exist, and they are unique if the stochastic matrix is irreducible. The IMAP CmRDT https://www.isa-afp.org/entries/IMAP-CRDT.html https://www.isa-afp.org/entries/IMAP-CRDT.html Tim Jungnickel, Lennart Oldenburg, Matthias Loibl 09 Nov 2017 00:00:00 +0000 We provide our Isabelle/HOL formalization of a Conflict-free Replicated Datatype for Internet Message Access Protocol commands. We show that Strong Eventual Consistency (SEC) is guaranteed by proving the commutativity of concurrent operations. We base our formalization on the recently proposed "framework for establishing Strong Eventual Consistency for Conflict-free Replicated Datatypes" (AFP.CRDT) from Gomes et al. Hence, we provide an additional example of how the recently proposed framework can be used to design and prove CRDTs. Hybrid Multi-Lane Spatial Logic https://www.isa-afp.org/entries/Hybrid_Multi_Lane_Spatial_Logic.html https://www.isa-afp.org/entries/Hybrid_Multi_Lane_Spatial_Logic.html Sven Linker 06 Nov 2017 00:00:00 +0000 We present a semantic embedding of a spatio-temporal multi-modal logic, specifically defined to reason about motorway traffic, into Isabelle/HOL. The semantic model is an abstraction of a motorway, emphasising local spatial properties, and parameterised by the types of sensors deployed in the vehicles. We use the logic to define controller constraints to ensure safety, i.e., the absence of collisions on the motorway. After proving safety with a restrictive definition of sensors, we relax these assumptions and show how to amend the controller constraints to still guarantee safety. The Kuratowski Closure-Complement Theorem https://www.isa-afp.org/entries/Kuratowski_Closure_Complement.html https://www.isa-afp.org/entries/Kuratowski_Closure_Complement.html Peter Gammie, Gianpaolo Gioiosa 26 Oct 2017 00:00:00 +0000 We discuss a topological curiosity discovered by Kuratowski (1922): the fact that the number of distinct operators on a topological space generated by compositions of closure and complement never exceeds 14, and is exactly 14 in the case of R. In addition, we prove a theorem due to Chagrov (1982) that classifies topological spaces according to the number of such operators they support. Transition Systems and Automata https://www.isa-afp.org/entries/Transition_Systems_and_Automata.html https://www.isa-afp.org/entries/Transition_Systems_and_Automata.html Julian Brunner 19 Oct 2017 00:00:00 +0000 This entry provides a very abstract theory of transition systems that can be instantiated to express various types of automata. A transition system is typically instantiated by providing a set of initial states, a predicate for enabled transitions, and a transition execution function. From this, it defines the concepts of finite and infinite paths as well as the set of reachable states, among other things. Many useful theorems, from basic path manipulation rules to coinduction and run construction rules, are proven in this abstract transition system context. The library comes with instantiations for DFAs, NFAs, and Büchi automata. Büchi Complementation https://www.isa-afp.org/entries/Buchi_Complementation.html https://www.isa-afp.org/entries/Buchi_Complementation.html Julian Brunner 19 Oct 2017 00:00:00 +0000 This entry provides a verified implementation of rank-based Büchi Complementation. The verification is done in three steps: <ol> <li>Definition of odd rankings and proof that an automaton rejects a word iff there exists an odd ranking for it.</li> <li>Definition of the complement automaton and proof that it accepts exactly those words for which there is an odd ranking.</li> <li>Verified implementation of the complement automaton using the Isabelle Collections Framework.</li> </ol> Evaluate winding numbers through Cauchy indices https://www.isa-afp.org/entries/Winding_Number_Eval.html https://www.isa-afp.org/entries/Winding_Number_Eval.html Wenda Li 17 Oct 2017 00:00:00 +0000 In complex analysis, the winding number measures the number of times a path (counterclockwise) winds around a point, while the Cauchy index can approximate how the path winds. This entry provides a formalisation of the Cauchy index, which is then shown to be related to the winding number. In addition, this entry also offers a tactic that enables users to evaluate the winding number by calculating Cauchy indices. Count the Number of Complex Roots https://www.isa-afp.org/entries/Count_Complex_Roots.html https://www.isa-afp.org/entries/Count_Complex_Roots.html Wenda Li 17 Oct 2017 00:00:00 +0000 Based on evaluating Cauchy indices through remainder sequences, this entry provides an effective procedure to count the number of complex roots (with multiplicity) of a polynomial within a rectangle box or a half-plane. Potential applications of this entry include certified complex root isolation (of a polynomial) and testing the Routh-Hurwitz stability criterion (i.e., to check whether all the roots of some characteristic polynomial have negative real parts). Homogeneous Linear Diophantine Equations https://www.isa-afp.org/entries/Diophantine_Eqns_Lin_Hom.html https://www.isa-afp.org/entries/Diophantine_Eqns_Lin_Hom.html Florian Messner, Julian Parsert, Jonas Schöpf, Christian Sternagel 14 Oct 2017 00:00:00 +0000 We formalize the theory of homogeneous linear diophantine equations, focusing on two main results: (1) an abstract characterization of minimal complete sets of solutions, and (2) an algorithm computing them. Both, the characterization and the algorithm are based on previous work by Huet. Our starting point is a simple but inefficient variant of Huet's lexicographic algorithm incorporating improved bounds due to Clausen and Fortenbacher. We proceed by proving its soundness and completeness. Finally, we employ code equations to obtain a reasonably efficient implementation. Thus, we provide a formally verified solver for homogeneous linear diophantine equations. The Hurwitz and Riemann ζ Functions https://www.isa-afp.org/entries/Zeta_Function.html https://www.isa-afp.org/entries/Zeta_Function.html Manuel Eberl 12 Oct 2017 00:00:00 +0000 <p> This entry builds upon the results about formal and analytic Dirichlet series to define the Hurwitz &zeta; function and, based on that, the Riemann &zeta; function. This is done by first defining them for &real;(<i>z</i>) > 1 and then successively extending the domain to the left using the Euler&ndash;MacLaurin formula. </p> <p> Some basic results about these functions are also shown, such as their analyticity on &#8450;&#8726;&#123;1&#125;, that they have a simple pole with residue 1 at 1, their relation to the &Gamma; function, and the special values at negative integers and positive even integers &ndash; including the famous &zeta;(-1) = -1/12 and &zeta;(2) = &pi;&sup2;/6. </p> <p> Lastly, the entry also contains Euler's analytic proof of the infinitude of primes, based on the fact that &zeta;(<i>s</i>) has a pole at <i>s</i> = 1. </p> Linear Recurrences https://www.isa-afp.org/entries/Linear_Recurrences.html https://www.isa-afp.org/entries/Linear_Recurrences.html Manuel Eberl 12 Oct 2017 00:00:00 +0000 <p> Linear recurrences with constant coefficients are an interesting class of recurrence equations that can be solved explicitly. The most famous example are certainly the Fibonacci numbers with the equation <i>f</i>(<i>n</i>) = <i>f</i>(<i>n</i>-1) + <i>f</i>(<i>n</i> - 2) and the quite non-obvious closed form (<i>&phi;</i><sup><i>n</i></sup> - (-<i>&phi;</i>)<sup>-<i>n</i></sup>) / &radic;<span style="text-decoration: overline">5</span> where &phi; is the golden ratio. </p> <p> In this work, I build on existing tools in Isabelle &ndash; such as formal power series and polynomial factorisation algorithms &ndash; to develop a theory of these recurrences and derive a fully executable solver for them that can be exported to programming languages like Haskell. </p>