skip to main content
research-article

Fun with semirings: a functional pearl on the abuse of linear algebra

Published:25 September 2013Publication History
Skip Abstract Section

Abstract

Describing a problem using classical linear algebra is a very well-known problem-solving technique. If your question can be formulated as a question about real or complex matrices, then the answer can often be found by standard techniques.

It's less well-known that very similar techniques still apply where instead of real or complex numbers we have a closed semiring, which is a structure with some analogue of addition and multiplication that need not support subtraction or division.

We define a typeclass in Haskell for describing closed semirings, and implement a few functions for manipulating matrices and polynomials over them. We then show how these functions can be used to calculate transitive closures, find shortest or longest or widest paths in a graph, analyse the data flow of imperative programs, optimally pack knapsacks, and perform discrete event simulations, all by just providing an appropriate underlying closed semiring.

References

  1. S. Abdali and B. Saunders. Transitive closure and related semiring properties via eliminants. Theoretical Computer Science, 40: 257--274, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. V. Aho, J. E. Hopcroft, and J. D. Ullman. The Design and Analysis of Computer Algorithms. Addison-Wesley, 1974. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. R. Backhouse and B. Carré. Regular algebra applied to path-finding problems. IMA Journal of Applied Mathematics, 2 (15): 161--186, 1975.Google ScholarGoogle ScholarCross RefCross Ref
  4. G. Cohen and P. Moller. Linear system theory for discrete event systems. In 23rd IEEE Conference on Decision and Control, pages 539--544, 1984.Google ScholarGoogle ScholarCross RefCross Ref
  5. J. Conway. Regular algebra and finite machines. Chapman and Hall (London), 1971.Google ScholarGoogle Scholar
  6. R. Floyd. Algorithm 97: shortest path. Communications of the ACM, 5 (6): 345, 1962. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. S. Golan. Semirings and their applications. Springer, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  8. J. S. Golan. Semirings and affine equations over them. Kluwer Academic Publishers, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  9. M. Gondran and M. Minoux. Graphs, dioids and semirings. Springer, 2008.Google ScholarGoogle ScholarCross RefCross Ref
  10. J. Kam and J. Ullman. Global data flow analysis and iterative algorithms. Journal of the ACM (JACM), 23 (1): 158--171, 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. U. Khedker and D. Dhamdhere. A generalized theory of bit vector data flow analysis. ACM Transactions on Programming Languages and Systems (TOPLAS), 16 (5): 1472--1511, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. Lehmann. Algebraic structures for transitive closure. Theoretical Computer Science, 4 (1): 59--76, 1977.Google ScholarGoogle ScholarCross RefCross Ref
  13. V. P. Maslov. Idempotent analysis. American Mathematical Society, 1992.Google ScholarGoogle ScholarCross RefCross Ref
  14. M. D. Mcilroy. Power series, power serious. Journal of Functional Programming, 9 (3): 325--337, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. R. McNaughton and H. Yamada. Regular expressions and state graphs for automata. IRE Transactions on Electronic Computers, 9 (1): 39--47, 1960.Google ScholarGoogle ScholarCross RefCross Ref
  16. M. Mohri. Semiring frameworks and algorithms for shortest-distance problems. Journal of Automata, Languages and Combinatorics, 7 (3): 321--350, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. R. Tarjan. Solving path problems on directed graphs. Technical report, Stanford University, 1975. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Fun with semirings: a functional pearl on the abuse of linear algebra

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 48, Issue 9
        ICFP '13
        September 2013
        457 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2544174
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programming
          September 2013
          484 pages
          ISBN:9781450323260
          DOI:10.1145/2500365

        Copyright © 2013 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 25 September 2013

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!