Skip to main content

Formalisation in higher-order logic and code generation to functional languages of the Gauss-Jordan algorithm


In this paper, we present a formalisation in a proof assistant, Isabelle/HOL, of a naive version of the Gauss-Jordan algorithm, with explicit proofs of some of its applications; and, additionally, a process to obtain versions of this algorithm in two different functional languages (SML and Haskell) by means of code generation techniques from the verified algorithm. The aim of this research is not to compete with specialised numerical implementations of Gauss-like algorithms, but to show that formal proofs in this area can be used to generate usable functional programs. The obtained programs show compelling performance in comparison to some other verified and functional versions, and accomplish some challenging tasks, such as the computation of determinants of matrices of big integers and the computation of the homology of matrices representing digital images.

Hide All
Aransay, J. & Divasón, J. (2014a) Formalization and execution of Linear Algebra: From theorems to algorithms. In Post Proceedings of the International Symposium on Logic-Based Program Synthesis and Transformation: LOPSTR 2013, Gupta, G. & Peña, R. (eds), LNCS, vol. 8901. Madrid, Spain: Springer, pp. 01–19.
Aransay, J. & Divasón, J. (2014b) Gauss-Jordan algorithm and its applications. Arch. Formal Proofs. Available at:, Formal proof development.
Aransay, J. & Divasón, J. (2014c) Gauss-Jordan elimination in Isabelle/HOL. Available at:
Aransay, J. & Divasón, J. (2015) Generalizing a Mathematical Analysis Library in Isabelle/HOL. NASA Formal Methods, Havelund, K., Holzmann, G. & Joshi, R. (eds), LNCS, vol. 9058. Pasadena, CA, USA: Springer, pp. 415–421.
Avigad, J., & Harrison, J. (2014) Formally verified mathematics. Commun. ACM 57 (4), 6675.
Avigad, J., Hölzl, J. & Serafin, L. (2014) A Formally Verified Proof of the Central Limit Theorem. Available at:
Bulwahn, L., Krauss, A., Haftmann, F., Erkök, L. & Matthews, J. (2008) Imperative functional programming with Isabelle/HOL. In TPHOLs '08: Proceedings of the 21st International Conference on Theorem Proving in Higher Order Logics, Mohamed, O., Muñoz, C. & Tahar, S. (eds), LNCS, vol. 5170. Montreal, Canada: Springer, pp. 352–367.
Dénès, M. (2013) Étude Formelle d'algorithmes Efficaces En Algèbre Linéaire. PhD Thesis, INRIA Sophia Antipolis, France.
Dénès, M., Mörtberg, A. & Siles, V. (2012) A refinement-based approach to computational algebra in COQ. In ITP - 3rd International Conference on Interactive Theorem Proving - 2012, Beringer, L. & Felty, A. (eds), LNCS, vol. 7406. Princeton, NJ, USA: Springer, pp. 83–98.
Dénès, M., Mörtberg, A. & Siles, V. (2013) Refinements for free!. Certified Programs and Proofs, Gonthier, G. & Norrish, M. (eds), LNCS, vol. 8307. Melbourne, VIC, Australia: Springer, pp. 147162.
Durán, A. J., Pérez, M. & Varona, J. L. (2014) Misfortunes of a mathematicians' trio using computer algebra systems: Can we trust? Notices AMS 61 (10), 12491252.
Esparza, J., Lammich, P., Neumann, R., Nipkow, T., Schimpf, A. & Smaus, J. G. (2013) A fully verified executable LTL model checker, Computer Aided Verification: CAV 2013, Sharygina, N. & Veith, H. (eds), LNCS, vol. 8044. Saint Petersburg, Russia: Springer, pp. 463–478.
Gockenbach, M. S. (2010) Finite-Dimensional Linear Algebra. CRC Press.
Haftmann, F. (2013) Code generation from Isabelle/HOL theories. Available at:
Haftmann, F., Krauss, A., Kuncar, O. & Nipkow, T. (2013) Data refinement in Isabelle/HOL. In Interactive Theorem Proving: ITP 2013, Blazy, S., Paulin-Mohring, C., & Pichardie, D. (eds), LNCS, vol. 7998. Rennes, France: Springer, pp. 100–115.
Haftmann, F. & Nipkow, T. (2010) Code generation via higher-order rewrite systems. In Functional and Logic Programming: 10th International Symposium: FLOPS 2010, Blume, M., Kobayashi, N. & Vidal, G. (eds), LNCS, vol. 6009. Sendai, Japan: Springer, pp. 103–117.
Hales, T. C. & Ferguson, S. P. (2011) The Kepler Conjecture. The Hales-Ferguson Proof. New York: Springer.
Harrison, J. (2005) A HOL theory of Euclidean space. In Theorem Proving in Higher Order Logics, Hurd, J. & Melham, T. (eds), LNCS, vol. 3603. Oxford, UK: Springer, pp. 114–129.
Harrison, J. (2013) The HOL Light theory of Euclidean space. J. Autom. Reason. 50 (2), 173190.
Haskell. (2014) The Haskell Programming Language. Available at:
Heras, J., Dénès, M., Mata, G., Mörtberg, A., Poza, M. & Siles, V. (2012) Towards a certified computation of homology groups for digital images. In Computational Topology in Image Context: CTIC 2012, Ferri, M., Frosini, P., Landi, C., Cerri, A. & Fabio, B. D. (eds), LNCS, vol. 7309. Bertinoro, Italy: Springer, pp. 49–57.
HMA. (2014) HOL Multivariate Analysis Library. Available at:
Milner, R., Harper, R., MacQueen, D. & Tofte, M. (1997) The Definition of Standard ML, revised edition. MIT Press.
MLton. (2014) The MLton website. Available at:
Nipkow, T. (2011) Gauss-Jordan elimination for matrices represented as functions. Arch. Formal Proofs. Available at:, Formal proof development.
Nipkow, T., Paulson, L. C. & Wenzel, M. (2002) Isabelle/HOL: A Proof Assistant for Higher-Order Logic. LNCS, vol. 2283. Springer.
Paulson, L. C. (1990) Logic and Computer Science. Academic Press. Chap. Isabelle: The next 700 theorem provers, pp. 361388.
Poly, M. L. (2014) The Poly/ML website. Available at:
Roman, S. (2008) Advanced Linear Algebra. 3rd edn.Springer.
Sternagel, C. (2013) Proof pearl - a mechanized proof of GHC's mergesort. J. Autom. Reasoning 51 (4), 357370.
Strang, G. (2009) Introduction to Linear Algebra. 4th edn.Wellesley-Cambridge Press.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *


Full text views

Total number of HTML views: 0
Total number of PDF views: 24 *
Loading metrics...

Abstract views

Total abstract views: 166 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 20th March 2018. This data will be updated every 24 hours.