Abstract
We demonstrate how methods in Functional Programming can be used to implement a computer algebra system. As a proof-of-concept, we present the computational-algebra package. It is a computer algebra system implemented as an embedded domain-specific language in Haskell, a purely functional programming language. Utilising methods in functional programming and prominent features of Haskell, this library achieves safety, composability, and correctness at the same time. To demonstrate the advantages of our approach, we have implemented advanced Gröbner basis algorithms, such as Faugère’s \(F_4\) and \(F_5\), in a composable way.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Indeed, one can use dependent types, described in the next subsection, to require such proofs. However, this is too heavy for the small outcome, and does not currently work for primitive types.
- 2.
This can be achieved in object-oriented language with subtyping and Generics.
- 3.
More specifically, we used the implementation in commit 70e6e7b.
References
Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. In: Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, ICFP 2000, pp. 268–279. ACM, New York (2000). https://doi.org/10.1145/351240.351266
Coquand, T., Persson, H.: Gröbner bases in type theory. In: Altenkirch, T., Reus, B., Naraschewski, W. (eds.) TYPES 1998. LNCS, vol. 1657, pp. 33–46. Springer, Heidelberg (1999). https://doi.org/10.1007/3-540-48167-2_3
Coutts, D., Leshchinskiy, R., Stewart, D.: Stream fusion. from lists to streams to nothing at all. In: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, ICFP 2007 (2007)
Eisenberg, R.A., Weirich, S.: Dependently typed programming with singletons. ACM SIGPLAN Not. 47(12), 117–130 (2012). Haskell 2012
Faugére, J.-C.: A new efficient algorithm for computing Gröbner bases (\({F}_4\)). J. Pure Appl. Algebra 139(1), 61–88 (1999)
Faugére, J.-C.: A new efficient algorithm for computing Gröbner bases without reduction to zero (\({F}_5\)). In: Proceedings of the 2002 International Symposium on Symbolic and Algebraic Computation, pp. 75–83. ACM, Lille (2002)
GHC Team: The Glasgow Haskell Compiler (2018). https://www.haskell.org/ghc/. Accessed 2018
Giovini, A., Mora, T., Niesi, G., Robbiano, L., Traverso, C.: “One sugar cube, please” or selection strategies in the Buchberger algorithm. In: Proceedings of the 1991 International Symposium on Symbolic and Algebraic Computation, ISSAC 1991, pp. 5–4. ACM (1991)
Greuel, G.-M., Pfister, G.: A Singular Introduction to Commutative Algebra, 2nd edn. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-662-04963-1
Haskell Committee: The Haskell Programming Language. http://haskell.org/
Hypothesis: Most testing is ine ective - Hypothesis (2018). https://hypothesis.works. Accessed 06 May 2018
Ishii, H.: The computational-algebra package (2018). https://konn.github.io/computational-algebra
Ishii, H.: The ghc-typelits-presburger package (2017). http://hackage.haskell.org/package/ghc-typelits-presburger
Ishii, H.: The type-natural package (2013). http://hackage.haskell.org/package/type-natural
Jolly, R.: Categories as type classes in the scala algebra system. In: Gerdt, V.P., Koepf, W., Mayr, E.W., Vorozhtsov, E.V. (eds.) CASC 2013. LNCS, vol. 8136, pp. 209–218. Springer, Cham (2013). https://doi.org/10.1007/978-3-319-02297-0_18
Keller, G., Chakravarty, M.M., Leshchinskiy, R., Peyton Jones, S., Lippmeier, B.: Regular, shape-polymorphic, parallel arrays in Haskell. In: Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP 2010, pp. 261–272. ACM, Baltimore (2010)
Kmett, E.A.: The algebra package (2011). http://hackage.haskell.org/package/algebra. Accessed 2018
Kredel, H., Jolly, R.: Generic, type-safe and object oriented computer algebra software. In: Gerdt, V.P., Koepf, W., Mayr, E.W., Vorozhtsov, E.V. (eds.) CASC 2010. LNCS, vol. 6244, pp. 162–177. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-15274-0_14
Launchbury, J., Peyton Jones, S.L.: Lazy functional state threads. In: Proceedings of the ACM SIGPLAN 1994 Conference on Programming Language Design and Implementation, PLDI 1994, pp. 24–35. ACM, Orlando (1994)
Lobachev, O., Loogen, R.: Implementing data parallel rational multiple-residue arithmetic in Eden. In: Gerdt, V.P., Koepf, W., Mayr, E.W., Vorozhtsov, E.V. (eds.) CASC 2010. LNCS, vol. 6244, pp. 178–193. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-15274-0_15
Marlow, S.: Parallel and Concurrent Programming in Haskell: Techniques for Multicore and Multithreaded Programming. O’Reilly Media, Sebastopol (2013)
Marlow, S., Maier, P., Loidl, H.-W., Aswad, M.K., Trinder, P.: Seq no more: better strategies for parallel Haskell. In: Proceedings of the Third ACM Haskell Symposium on Haskell, Haskell 2010, pp. 91–102. ACM, Baltimore (2010). https://doi.org/10.1145/1863523.1863535
Mechveliani, S.D.: Computer algebra with Haskell: applying functional-categorial-“lazy” programming. In: Proceedings of International Workshop CAAP, pp. 203–211 (2001)
Mechveliani, S.D.: DoCon-A a Provable Algebraic Domain Constructor (2018). http://www.botik.ru/pub/local/Mechveliani/docon-A/2.02/manual.pdf. Accessed 06 May 2018
Pan, S., Hu, Y., Wang, B.: The termination of the F5 algorithm revisited. In: Proceedings of the 38th International Symposium on Symbolic and Algebraic Computation, ISSAC 2013, pp. 291–298. ACM, Boston (2013)
Runciman, C., Naylor, M., Lindblad, F.: SmallCheck and Lazy SmallCheck: automatic exhaustive testing for small values. In: Proceedings of the First ACM SIGPLAN Symposium on Haskell, Haskell 2008, pp. 37–48. ACM, Victoria (2008). https://doi.org/10.1145/1411286.1411292
Yorgey, B.A., Weirich, S., Cretin, J., Peyton Jones, S., Vytiniotis, D., Magalhães, J.P.: Giving Haskell a promotion. In: Proceedings of the 8th ACM SIGPLAN Workshop on Types in Language Design and Implementation, TLDI 2012, pp. 53–66. ACM, Philadelphia (2012)
Acknowledgments
The author would like to thank my supervisor, Prof. Akira Terui, for discussions, and to anonymous reviewers for helpful comments. This research is supported by Grant-in-Aid for JSPS Research Fellow Number 17J00479, and partially by Grants-in-Aid for Scientific Research 16K05035.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this paper
Cite this paper
Ishii, H. (2018). A Purely Functional Computer Algebra System Embedded in Haskell. In: Gerdt, V., Koepf, W., Seiler, W., Vorozhtsov, E. (eds) Computer Algebra in Scientific Computing. CASC 2018. Lecture Notes in Computer Science(), vol 11077. Springer, Cham. https://doi.org/10.1007/978-3-319-99639-4_20
Download citation
DOI: https://doi.org/10.1007/978-3-319-99639-4_20
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-99638-7
Online ISBN: 978-3-319-99639-4
eBook Packages: Computer ScienceComputer Science (R0)