skip to main content
article
Free Access

Calculational semantics: Deriving programming theories from equations by functional predicate calculus

Published:01 July 2006Publication History
Skip Abstract Section

Abstract

The objects of programming semantics, namely, programs and languages, are inherently formal, but the derivation of semantic theories is all too often informal, deprived of the benefits of formal calculation “guided by the shape of the formulas.” Therefore, the main goal of this article is to provide for the study of semantics an approach with the same convenience and power of discovery that calculus has given for many years to applied mathematics, physics, and engineering. The approach uses functional predicate calculus and concrete generic functionals; in fact, a small part suffices. Application to a semantic theory proceeds by describing program behavior in the simplest possible way, namely by program equations, and discovering the axioms of the theory as theorems by calculation. This is shown in outline for a few theories, and in detail for axiomatic semantics, fulfilling a second goal of this article. Indeed, a chafing problem with classical axiomatic semantics is that some axioms are unintuitive at first, and that justifications via denotational semantics are too elaborate to be satisfactory. Derivation provides more transparency. Calculation of formulas for ante- and postconditions is shown in general, and for the major language constructs in particular. A basic problem reported in the literature, whereby relations are inadequate for handling nondeterminacy and termination, is solved here through appropriately defined program equations. Several variants and an example in mathematical analysis are also presented. One conclusion is that formal calculation with quantifiers is one of the most important elements for unifying continuous and discrete mathematics in general, and traditional engineering with computing science, in particular.

References

  1. Back, R.-J. 1983. A continuous semantics for unbounded nondeterminism. Theor. Comput. Sci. 23, 2, 187--210.Google ScholarGoogle ScholarCross RefCross Ref
  2. Back, R.-J. and von Wright, J. 1992. Combining angels, demons and miracles in program specifications. Theor. Comput. Sci. 100, 2, 365--383. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Back, R.-J. and von Wright, J. 1998. Refinement Calculus: A Systematic Introduction. Springer, New York. Google ScholarGoogle ScholarCross RefCross Ref
  4. Backhouse, R. 2002. Galois Connections. Number 7 in Programming Algebra. Univ. of Nottingham. http://www.cs.nott.ac.uk/~rcb/G53PAL/G53PAL.html.Google ScholarGoogle Scholar
  5. Bass, H. 2003. The Carnegie initiative on the doctorate: The case of mathematics. Notices of the AMS 50, 7 (Aug.), 767--776.Google ScholarGoogle Scholar
  6. Boiten, E. and Möller, B. 2002. 6th international conference on mathematics of program construction. Conference announcement: http://www.cs.kent.ac.uk/events/conf/2002/mpc2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Boute, R. 1988. Systems semantics: Principles, applications and implementation. ACM Trans. Program. Languages Syst. 10, 1 (Jan.), 118--155. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Boute, R. 1993. Funmath illustrated: A declarative formalism and application examples. Declarative Systems Series 1, Computing Science Institute, University of Nijmegen.Google ScholarGoogle Scholar
  9. Boute, R. 2002. Functional mathematics: A unifying declarative and calculational approach to systems, circuits and programs---Part I. Ghent University. Course notes.Google ScholarGoogle Scholar
  10. Boute, R. 2003. Concrete generic functionals: Principles, design and applications. In Generic Programming, J. Gibbons and J. Jeuring, eds. Kluwer Academic, Hingham, Mass, 89--119. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Boute, R. 2005. Functional declarative language design and predicate calculus: A practical approach. ACM Trans. Program. Languages Syst. 27, 5 (Sept.) 988--1047. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Cohen, E. 1990. Programming in the 1990's: An Introduction to the Calculation of Programs. Springer, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. De Bakker, J. W. 1980. Mathematical Theory of Program Correctness. Prentice-Hall, Upper Saddle River, N. J. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Dean, C. N. and Hinchey, M. G. 1996. Teaching and Learning Formal Methods. Academic Press, London.Google ScholarGoogle Scholar
  15. Dijkstra, E. W. 1976. A Discipline of Programming. Prentice-Hall, Upper Saddle River, N. J. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Dijkstra, E. W. 2000. Under the spell of Lcibniz's dream. Technical Note EWD1298. http://www.cs.utexas.edu/users/EWD/ewd12xx/EWD1298.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Dijkstra, E. W. and Scholten, C. S. 1990. Predicate Calculus and Program Semantics. Springer, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Dijkstra, R. M. 1994. Relational calculus and relational program semantics. Computing Science Reports CS-R9408, Dept. of Computer Science, University of Groningen.Google ScholarGoogle Scholar
  19. Dijkstra, R. M. 1998. Computation calculus: Bridging a formalization gap. In Proceedings of the Conference Mathematics of Program Construction. LNCS, vol. 1422. Springer, New York, 151--174. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Gordon, M. 2003. Specification and Verification I. University of Cambridge. http://www.cl.cam.ac.uk/Teaching/mjcg/Lectures/SpecVer1/Notes03/Notes.pdf.Google ScholarGoogle Scholar
  21. Gries, D. 1996. The need for education in useful formal logic. IEEE Computer 29, 4 (Apr.), 29--30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Gries, D. and Schneider, F. B. 1993. A Logical Approach to Discrete Math. Springer, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Hancock, P. 2004. Refinement calculus: Some references and pointers. Technical note. http://homepages.inf.ed.ac.uk/v1phanc1/RC-bib.pdf.Google ScholarGoogle Scholar
  24. Hehner, E. 1999. Specifications, programs and total correctness. Sci. Comput. Program. 34, 3 (July), 191--205. Original version (1998) also on the web: http://www.cs.toronto.edu/~hehner/SPTC.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Hehner, E. 2004. A Practical Theory of Programming, 2nd ed. Springer, New York. http://www.cs.toronto.edu/~hehner/aPToP/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Hesselink, W. H. 1992. Programs, Recursion, and Unbounded Choice. Cambridge, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Hoare, C. A. R. 1969. An axiomatic basis for computer programming. Comm. ACM 12, 10 (Oct.), 576--580, 583. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Hoare, C. A. R. and Jifeng, H. 1998. Unifying Theories of Programming. Prentice-Hall, Upper Saddle River, N. J.Google ScholarGoogle Scholar
  29. Lamport, L. 2002. Specifying Systems. Addison-Wesley, Reading, Mass.Google ScholarGoogle Scholar
  30. Lamport, L. 2004. All I really need to know I learned in high school. Proceedings of the 2004 CoLogNET/FME Symposium on Teaching Formal Methods. http://www.intec.UGent.be/groupsites/formal/Sympos2004/Sympos2004.htm.Google ScholarGoogle Scholar
  31. Lang, S. 1983. Undergraduate Analysis. Springer, Berlin.Google ScholarGoogle Scholar
  32. Leavens, G. 1995. Weakest preconditions. Course notes Semantics Program. Languages (Com S 641). http://www.cs.iastate.edu/~leavens/ComS641-Hesselink.html.Google ScholarGoogle Scholar
  33. Lee, E. A. and Messerschmitt, D. G. 1998. Engineering---An education for the future. IEEE Computer 31, 1 (Jan.), 77--85. http://www.gigascale.org/pubs/5/computermag.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Lee, E. A. and Varaiya, P. 2003. Structure and Interpretation of Signals and Systems. Addison-Wesley, Reading, Mass.Google ScholarGoogle Scholar
  35. Leino, K. R. M. and Manohar, R. 1999. Joining specification statements. Theor. Comput. Sci. 216, 1--2 (Mar.), 375--394. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Loeckx, J. and Sieber, K. 1984. The Foundations of Program Verification. Wiley-Teubner. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. McCluskey, E. J. 1965. Introduction to the Theory of Switching Circuits. McGraw Hill, New York.Google ScholarGoogle Scholar
  38. Meyer, B. 1991. Introduction to the Theory of Programming Languages. Prentice Hall, Upper Saddle River, N. J. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Morgan, C. 1994. Programming from Specifications, 2nd ed. Prentice Hall, Upper Saddle River, N. J. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Morris, J. M. 1987. A theoretical basis for stepwise refinement and the programming calculus. Sci. Comput. Program. 9, 3 (Dec.), 287--306. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Nelson, G. 1989. A generalization of Dijkstra's calculus. ACM Trans. Prog. Lang. Syst. 11, 4 (Oct.), 517--561. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Plotkin, G. D. 1980. Dijkstra's predicate transformers and Smyth's powerdomains. In Abstract Software Specifications, D. Björner, ed. LNCS, vol. 86. Springer, New York, 527--583. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Ravaglia, R., Alper, T., Rozenfeld, M., and Suppes, P. 1999. Successful pedagogical applications of symbolic computation. In Computer-Human Interaction in Symbolic Computation, N. Kajler, ed. Springer, New York. http://www-epgy.stanford.edu/research/chapter4.pdf.Google ScholarGoogle Scholar
  44. Recorde, R. 1557. The Whetstone of Witte. http://www-gap.dcs.st-and.ac.uk/~history/Mathematicians/Recorde.html.Google ScholarGoogle Scholar
  45. Taylor, P. 2000. Practical Foundations of Mathematics, 2nd printing. Cambridge Studies in Advanced Mathematics, no. 59. Cambridge University Press, New York. Comment about chapter 1 of this book on http://www.dcs.qmul.ac.uk/~pt/Practical_Foundations/html/s10.html.Google ScholarGoogle Scholar
  46. Wigner, E. 1960. The unreasonable effectiveness of mathematics in the natural sciences. Comm. Pure Appl. Math. 13, I (Feb.), 1--14. http://nedwww.ipac.caltech.edu/level5/March02/Wigner/Wigner.html.Google ScholarGoogle ScholarCross RefCross Ref
  47. Winskel, G. 1993. The Formal Semantics of Programming Languages: An Introduction. MIT Press, Cambridge, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Calculational semantics: Deriving programming theories from equations by functional predicate calculus

                            Recommendations

                            Reviews

                            Wolfgang Schreiner

                            Scholars in many disciplines envy physics and its mathematical formalism, where natural processes can be described by precise equations and equational reasoning can derive consequences and yield insights that would be hard to obtain by intuition alone. This is also true for computer scientists who aim to elaborate formal calculi for describing the behavior of programs in order to get a better understanding of their properties. In pursuit of this goal, the paper presents a set of calculational semantics that allow equational reasoning on programs. The core problem is that programs process discrete objects (computer stores) in a way that can only be adequately described by a logic with quantifiers. To support equational reasoning on such formulas, the author introduces a functional predicate calculus, where logical formulas are represented by Boolean functions and logical equivalence becomes function equality. It is shown how program behavior can be described by equations and how the laws of various other approaches to program semantics can be derived by formal calculations. This approach has various elder relatives. For instance, the late Dijkstra, a pioneer in the field of programming theory, together with Scholten, propagated an equational style of program reasoning, and Hoare and Jifeng introduced an algebra of programming based on a view of programs as relations between states. While the calculational semantics presented in this paper does not enter new territory, it nevertheless provides a succinct working language and a framework for linking other theories. Online Computing Reviews Service

                            Access critical reviews of Computing literature here

                            Become a reviewer for Computing Reviews.

                            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

                            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!