Skip to main content
Log in

Towards a linear algebra of programming

  • Original Article
  • Published:
Formal Aspects of Computing

Abstract

The algebra of programming (AoP) is a discipline for programming from specifications using relation algebra. Specification vagueness and nondeterminism are captured by relations. (Final) implementations are functions. Probabilistic functions are half way between relations and functions: they express the propensity, or likelihood of ambiguous, multiple outputs. This paper puts forward a basis for a linear algebra of programming (LAoP) extending standard AoP towards probabilistic functions. Because of the quantitative essence of these functions, the allegory of binary relations which supports the AoP has to be extended. We show that, if one restricts to discrete probability spaces, categories of matrices provide adequate support for the extension, while preserving the pointfree reasoning style typical of the AoP.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Abadir KM, Magnus JR (2005) Matrix algebra. In: Econometric exercises, vol 1. Cambridge University Press, Cambridge

    Google Scholar 

  2. Andova S, McIver A, D’Argenio PR, Cuijpers PJL, Markovski J, Morgan C, Núñez M (eds) (2009) Proceedings first workshop on quantitative formal methods: theory and applications. In: EPTCS, vol 13

  3. Backhouse RC (2004) Mathematics of program construction. University of Nottingham. Draft of book in preparation, 608 p

  4. Bird R, de Moor O (1997) Algebra of programming. Series in Computer Science. Prentice-Hall International, Englewood Cliffs

    Google Scholar 

  5. Bloom SL, Sabadini N, Walters RFC (1996) Matrices, machines and behaviors. Appl Categ Struct 4(4): 343–360

    Article  MathSciNet  MATH  Google Scholar 

  6. Baroni M, Zamparelli R (2010) Nouns are vectors, adjectives are matrices: representing adjective-noun constructions in semantic space. In: Association for Computational Linguistics Proceedings, EMNLP ’10, Morristown, NJ, USA, pp 1183–1193

  7. Conway JH (1971) Regular algebra and finite machines. Chapman and Hall, London

    MATH  Google Scholar 

  8. Coecke B, Sadrzadeh M, Clark S (2010) Mathematical foundations for a compositional distributed model of meaning. Linguist Anal 36(1–4): 345–384

    Google Scholar 

  9. Distefano S, Longo F, Scarpa M (2010) Availability assessment of HA standby redundant clusters. In: 29th IEEE international symposium on reliable distributed systems

  10. Erwig M, Kollmansberger S (2006) Functional pearls: probabilistic functional programming in Haskell. J Funct Program 16: 21–34

    Article  MATH  Google Scholar 

  11. Frias MF (2002) Fork algebras in algebra, logic and computer science. Logic and computer science. World Scientific Publishing Co, Singapore

    Book  Google Scholar 

  12. Freyd PJ, Scedrov A (1990) Categories, allegories. In: Mathematical library, vol 39. North-Holland, Amsterdam

    Google Scholar 

  13. Gibbons J, Hinze R (2011) Just do it: simple monadic equational reasoning. In: Proceedings of the 16th ACM SIGPLAN international conference on Functional programming, ICFP’11, New York, NY, USA, 2011. ACM, New York, pp 2–14

  14. Gibbons J, Hutton G, Altenkirch T (2001) When is a function a fold or an unfold? Electron Notes Theor Comput Sci 44(1)

  15. Gibbons J (1997) Conditionals in distributive categories. Technical Report CMS-TR-97-01, School of Computing and Mathematical Sciences, Oxford Brookes University

  16. Hehner E (2011) A probability perspective. Form Asp Comput 23: 391–419

    Article  MathSciNet  MATH  Google Scholar 

  17. Hoogendijk P (1997) A generic theory of data types. PhD thesis, University of Eindhoven, The Netherlands

  18. Kawahara Y, Furusawa H, Mori M (1999) Categorical representation theorems of fuzzy relations. Inf Sci 119(3–4): 235–251

    Article  MathSciNet  MATH  Google Scholar 

  19. Kemeny JG, Snell JL (1960) Finite Markov chains. Springer, Berlin (1976, originally printed by Van Nostrand, Princeton)

  20. Latouche G, Ramaswami V (1999) Introduction to matrix analytic methods in stochastic modeling. ASA-SIAM

  21. Larsen KG, Skou A (1991) Bisimulation through probabilistic testing. Inf Comput 94(1): 1–28

    Article  MathSciNet  MATH  Google Scholar 

  22. Lawvere B, Schanuel S (1997) Conceptual mathematics: a first introduction to categories. Cambridge University Press, Cambridge

    MATH  Google Scholar 

  23. MacLane S (1998) Categories for the working mathematician. In: Graduate texts in mathematics, vol 5. Springer, Berlin

    Google Scholar 

  24. Macedo H (2012) Matrices as arrows—why categories of matrices matter. PhD thesis, University of Minho (submitted)

  25. Maddux RD (1991) The origin of relation algebras in the development and axiomatization of the calculus of relations. Studia Logica 50: 421–455

    Article  MathSciNet  MATH  Google Scholar 

  26. MacLane S, Birkhoff G (1999) Algebra. AMS Chelsea

  27. Mu SC, Bird R (2001) Quantum functional programming, 2001. 2nd Asian workshop on programming languages and systems, KAIST, Dajeaon, Korea, December 17–18

  28. McIver A, Cohen E, Morgan C (2006) Using probabilistic Kleene algebra for protocol verification. In: Schmidt R (ed) Relations and Kleene algebra in computer science. LNCS, vol 4136. Springer, Berlin, pp 296–310

  29. McIver A, Morgan C (2005) Abstraction, refinement and proof for probabilistic systems. In: Monographs in computer science. Springer, Berlin

    Google Scholar 

  30. Macedo HD, Oliveira JN (2010) Matrices as Arrows! A biproduct approach to typed linear algebra. In: MPC’10. LNCS, vol 6120. Springer, Berlin, pp 271–287

  31. Macedo HD, Oliveira JN (2011) Do the middle letters of “OLAP” stand for linear algebra (“LA”)? Technical Report TR- HASLab:04:2011, INESC TEC and University of Minho, Gualtar Campus, Braga

  32. Macedo HD, Oliveira JN (2011) Towards linear algebras of components. In: FACS 2010. LNCS, vol 6921. Springer, Berlin, pp 300–303

  33. Morgan C (1990) Programming from specification. In: Hoare CAR (ed) Series in computer science. Prentice-Hall International, Englewood Cliffs

    Google Scholar 

  34. Oliveira JN (2011) A look at the (linear) algebra of probabilistic functions, 2011. Contribution to the QAIS Start-up Workshop celebrating IBM-Portugal Scientific Prize 2010, Braga, 17th October

  35. Pratt V (1992) Origins of the calculus of binary relations. In: Proceedings of the 7th annual IEEE symposium on logic in computer science, Santa Cruz, CA, IEEE Comp. Soc, pp 248–254

  36. Rosenhouse J (2009) The Monty Hall problem: the remarkable story of math’s most contentious brain teaser. Oxford University Press, New York

    MATH  Google Scholar 

  37. Rao CR, Rao MB (1998) Matrix algebra and its applications to statistics and econometrics. World Scientific Publishing, Singapore

    Book  MATH  Google Scholar 

  38. Silva A, Bonchi F, Bonsangue MM, Rutten JJMM (2011) Quantitative Kleene coalgebras. Inf Comput 209(5): 822–849

    Article  MathSciNet  MATH  Google Scholar 

  39. Schmidt G (2010) Relational mathematics. Number 132 in Encyclopedia of Mathematics and its Applications. Cambridge University Press, Cambridge

    Google Scholar 

  40. SQIG-Group (2011) LAP: linear algebra of bounded resources programs. IT & Tech. Univ. Lisbon

  41. Sokolova A (2005) Coalgebraic analysis of probabilistic systems. Ph.D. dissertation, Tech. Univ. Eindhoven, Eindhoven, The Netherlands

  42. Sernadas A, Ramos J, Mateus P (2008) Linear algebra techniques for deciding the correctness of probabilistic programs with bounded resources. Technical report, SQIG-IT and IST-TU Lisbon, 1049-001 Lisboa, Portugal, 2008. Short paper presented at LPAR 2008, Doha, Qatar. November 22–27

  43. Takai T, Furusawa H (2006) Monodic tree Kleene algebra. In: Schmidt R (ed) Relations and Kleene algebra in computer science. Lecture notes in computer science, vol 4136. Springer, Berlin, pp 402–416

  44. Trcka N (2009) Strong, weak and branching bisimulation for transition systems and Markov reward chains: a unifying matrix approach. In: Proc. first workshop on quantitative formal methods: theory and applications, EPTCS, vol 13. pp 55–65

  45. Voas J, McGraw G (1997) Software fault injection: innoculating programs against errors. Wiley, New York, 416 p

  46. Winter M (2009) Arrow categories. Fuzzy Sets Syst 160(20): 2893–2909

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to José N. Oliveira.

Additional information

by Peter Höfner, Robert van Glabbeek and Ian Hayes

Rights and permissions

Reprints and permissions

About this article

Cite this article

Oliveira, J.N. Towards a linear algebra of programming. Form Asp Comp 24, 433–458 (2012). https://doi.org/10.1007/s00165-012-0240-9

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00165-012-0240-9

Keywords

Navigation