Formalization and Execution of Linear Algebra: From Theorems to Algorithms

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8901)


In this work we present a formalization of the Rank Nullity theorem of Linear Algebra in Isabelle/HOL. The formalization is of interest because of various reasons. First, it has been carried out based on the representation of mathematical structures proposed in the HOL Multivariate Analysis library of Isabelle/HOL (which is part of the standard distribution of the proof assistant). Hence, our proof shows the adequacy of such an infrastructure for the formalization of Linear Algebra. Moreover, we enrich the proof with an additional formalization of its computational meaning; to this purpose, we choose to implement the Gauss-Jordan elimination algorithm for matrices over fields, prove it correct, and then apply the Isabelle code generation facility that permits to execute the formalized algorithm. For the algorithm to be code generated, we use again the implementation of matrices available in the HOL Multivariate Analysis library, and enrich it with some necessary features. We report on the precise modifications that we introduce to get code execution from the original representation, and on the performance of the code obtained. We present an alternative verified type refinement of vectors that outperforms the original version. This refinement performs well enough as to be applied to the computation of the rank of some biomedical digital images. Our work proves itself as a suitable basis for the formalization of numerical Linear Algebra in HOL provers that can be successfully applied for computations of real case studies.


Linear Algebra Verification Code generation 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aransay, J. Divasón, J.: Rank Nullity Theorem in Linear Algebra, Archive of Formal Proofs (2013).
  2. 2.
    Aransay, J., Divasón, J.: Gauss-Jordan elimination in Isabelle/HOL (2013).
  3. 3.
    Aransay, J., Divasón, J.: Performance Analysis of a Verified Linear Algebra program in SML, Taller de Programación Funcional (TPF 2013), pp. 28–35. Lars-Åke Fredlund and Laura M. Castro (eds.) (2013)Google Scholar
  4. 4.
    Dénès, M., Mörtberg, A., Siles, V.: A Refinement-Based Approach to Computational Algebra in Coq. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 83–98. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  5. 5.
    Esparza, J., Lammich, P., Neumann, R., Nipkow, T., Schimpf, A., Smaus, J.-G.: A Fully Verified Executable LTL Model Checker. In: Sharygina, N., Veith, H. (eds.) CAV 2013. LNCS, vol. 8044, pp. 463–478. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  6. 6.
    Formath Project: Formalisation of Mathematics.
  7. 7.
    Haftmann, F., Nipkow, T.: Code Generation via Higher-Order Rewrite Systems. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) FLOPS 2010. LNCS, vol. 6009, pp. 103–117. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  8. 8.
    Haftmann, F., Krauss, A., Kunčar, O., Nipkow, T.: Data Refinement in Isabelle/HOL. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 100–115. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  9. 9.
    Harrison, J.: A HOL Theory of Euclidean Space. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 114–129. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  10. 10.
    Harrison, J.: The HOL Light Theory of Euclidean Space. J. Autom. Reasoning 50(2), 173–190 (2013)CrossRefMATHGoogle Scholar
  11. 11.
    Hales, T.C., Harrison, J., McLaughlin, S., Nipkow, T., Obua, S., Zumkeller, R.: A revision of the Proof of the Kepler Conjecture. Discrete & Computational Geometry 44(1), 1–34 (2010)CrossRefMathSciNetMATHGoogle Scholar
  12. 12.
    Heras, J., Coquand, T., Mörtberg, A., Siles, V.: Computing Persistent Homology within Coq/SSReflect. ACM Transactions on Computational Logic, 14(4). Article n. 26Google Scholar
  13. 13.
    Heras, J., Dénès, M., Mata, G., Mörtberg, A., Poza, M., Siles, V.: Towards a Certified Computation of Homology Groups for Digital Images. In: Ferri, M., Frosini, P., Landi, C., Cerri, A., Di Fabio, B. (eds.) CTIC 2012. LNCS, vol. 7309, pp. 49–57. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  14. 14.
    Heras, J., Poza, M., Dénès, M., Rideau, L.: Incidence Simplicial Matrices Formalized in Coq/SSReflect. In: Davenport, J.H., Farmer, W.M., Urban, J., Rabe, F. (eds.) MKM 2011 and Calculemus 2011. LNCS, vol. 6824, pp. 30–44. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  15. 15.
    Hölzl, J., et al.: HOL Multivariate Analysis (2013).
  16. 16.
    Hölzl, J., Immler, F., Huffman, B.: Type Classes and Filters for Mathematical Analysis in Isabelle/HOL. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 279–294. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  17. 17.
    Lammich, P., Tuerk, T.: Applying Data Refinement for Monadic Programs to Hopcroft’s Algorithm. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 166–182. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  18. 18.
    Lammich, P.: Automatic Data Refinement. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 84–99. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  19. 19.
    Lochbihler, A.: Light-Weight Containers for Isabelle: Efficient, Extensible, Nestable. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 116–132. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  20. 20.
    Nipkow, T.: Gauss-Jordan Elimination for Matrices Represented as Functions. Archive of Formal Proofs (2011).
  21. 21.
    Nipkow, T., Paulson, L., Wenzel, M.: Isabelle/HOL: A proof assistant for Higher-Order Logic. Springer (2002)Google Scholar
  22. 22.
    Roman, S.: Advanced Linear Algebra (Third Edition). Springer (2008)Google Scholar
  23. 23.
    Gasner, E., Reppy, J.H. (eds.): The Standard ML Basis Library.
  24. 24.
    Wiedijk, F.: Formalizing 100 Theorems.

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  1. 1.Departamento de Matemáticas y ComputaciónUniversidad de La RiojaLa RiojaSpain

Personalised recommendations