skip to main content
research-article
Free Access

Term transformers: A new approach to state

Authors Info & Claims
Published:26 May 2009Publication History
Skip Abstract Section

Abstract

We present a new approach to adding state and state-changing commands to a term language. As a formal semantics it can be seen as a generalization of predicate transformer semantics, but beyond that it brings additional opportunities for specifying and verifying programs. It is based on a construct called a phrase, which is a term of the form Ct, where C stands for a command and t stands for a term of any type. If R is boolean, CR is closely related to the weakest precondition wp(C,R). The new theory draws together functional and imperative programming in a simple way. In particular, imperative procedures and functions are seen to be governed by the same laws as classical functions. We get new techniques for reasoning about programs, including the ability to dispense with logical variables and their attendant complexities. The theory covers both programming and specification languages, and supports unbounded demonic and angelic nondeterminacy in both commands and terms.

References

  1. Back, R.-J. and von Wright, J. 1998. Refinement Calculus: a Systematic Introduction. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Back, R.-J. R. 1980. Correctness preserving program refinements: Proof theory and applications. Tract 131, Mathematisch Centrum, Amsterdam.Google ScholarGoogle Scholar
  3. Back, R.-J. R. and von Wright, J. 1990. Duality in specification languages: A lattice-theoretical approach. Acta Inf. 27, 7, 583--625. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Backhouse, R. C. 2003. Program Construction: Calculating Implementations from Specifications. Wiley, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Bijlsma, L. and Nederpelt, R. 1998. Dijkstra-Scholten predicate calculus: Concepts and misconceptions. Acta Inf. 35, 1007--1036.Google ScholarGoogle ScholarCross RefCross Ref
  6. Böhme, S., Leino, K. R. M., and Wolff, B. 2008. HOL-Boogie—An interactive prover for the Boogie program-verifier. In Proceedings of the 21st International Conference on Theorem Proving in Higher Order Logics, O. A. Mohamed, et al., Eds. Lecture Notes in Computer Science, vol. 5170. Springer-Verlag, New York, 150--166. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Boom, H. J. 1982. A weaker precondition for loops. ACM Trans. Program. Lang. Syst. 4, 4, 668--677. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Boute, R. T. 2005. Functional declarative language design and predicate calculus: A practical approach. ACM Trans. Program. Lang. Syst. 27, 5, 988--1047. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Bunkenburg, A. 1997. Expression refinement. Ph.D. thesis, Computing Science Department, University of Glasgow.Google ScholarGoogle Scholar
  10. Cohen, E. 1990. Programming in the 1990s: An Introduction to the Calculation of Programs. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Detlefs, D., Nelson, G., and Saxe, J. B. 2005. Simplify: A theorem prover for program checking. J. ACM 52, 3, 365--473. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Dijkstra, E. W. 1976. A Discipline of Programming. Prentice Hall, Englewood Cliffs, NJ. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Dijkstra, E. W. 1982. The equivalence of bounded nondeterminacy and continuity. In Selected Writings on Computing: A Personal Perspective. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Dijkstra, E. W. and Scholten, C. S. 1990. Predicate Calculus and Program Semantics. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Dijkstra, E. W. and van Gasteren, A. J. M. 1986. A simple fixpoint argument without the restriction to continuity. Acta Inf. 23, 1, 1--7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Floyd, R. W. 1967. Nondeterministic algorithms. J. ACM 14, 4, 636--644. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Gardiner, P. H. B. and Morgan, C. C. 1991. Data refinement of predicate transformers. Theor. Comput. Sci. 87, 143--162. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Gries, D. 1981. The Science of Programming. Texts and Monographs in Computer Science. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Gries, D. and Schneider, F. B. 1993. A Logical Approach to Discrete Math. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Hehner, E. C. R. 1984. The Logic of Programming. Prentice Hall, Englewood Cliffs, NJ. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Hehner, E. C. R. 1993. A Practical Theory of Programming. Springer-Verlag, New York. 2nd ed. 2004 at http://www.cs.toronto.edu/~hehner/aPToP/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Hitchcock, P. and Park, D. 1972. Induction rules and termination proofs. In IRIA Conference on Automata, Languages, and Programming Theory. North-Holland, Amsterdam, 225--251.Google ScholarGoogle Scholar
  23. Hoare, C. A. R. 1969. An axiomatic basis for computer programming. Commun. ACM 12, 10, 576--580. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Kaldewaij, A. 1990. Programming: the Derivation of Algorithms. Prentice-Hall, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Kleymann, T. 1999. Hoare logic and auxiliary variables. Formal Aspects Comput. 11, 5, 541--566.Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Launchbury, J. and Peyton Jones, S. 1994. Lazy functional state threads. In Proceedings of the ACM SIGPLAN Conference on Programming Languages Design and Implementation. ACM, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Moggi, E. 1989. Computational lambda-calculus and monads. In Proceedings of the 4th Annual Symposium on Logic in Computer Science. IEEE Press, Piscataway, NJ., 14--23. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Morgan, C. 1988. Auxiliary variables in data refinement. Inf. Process. Lett. 29, 6, 293--296. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Morgan, C. 1994. Programming from Specifications, 2nd ed. Prentice Hall, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Morris, J. M. 1987. A theoretical basis for stepwise refinement and the programming calculus. Sci. Comput. Program. 9, 287--306. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Morris, J. M. and Tyrrell, M. 2007. Dual unbounded nondeterminacy, recursion, and fixpoints. Acta Inf. 44, 5, 323--344. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Morris, J. M. and Tyrrell, M. 2008. Dually nondeterministic functions. ACM Trans. Program. Lang. Syst. 30, 6, 1--34. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Naumann, D. A. 2001a. Calculating sharp adaptation rules. Inf. Process. Lett. 77, 2-4, 201--208. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Naumann, D. A. 2001b. Ideal models for pointwise relational and state-free imperative programming. In Proceedings of the 3rd ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming. ACM, New York, 4--15. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Naumann, D. A. 2001c. Predicate transformer semantics of a higher-order imperative language with record subtyping. Sci. Comput. Program. 41, 1, 1--51. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Nelson, G. 1989. A generalization of Dijkstra's calculus. ACM Trans. Program. Lang. Syst. 11, 4, 517--561. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Nelson, G. 1992. Some generalizations and applications of Dijkstra's guarded commands. In Programming and Mathematical Methods, M. Broy, Ed. NATO ASI Series F: Computer and Systems Sciences, vol. 88. Springer-Verlag, New York.Google ScholarGoogle Scholar
  38. Partsch, H. A. 1990. Specification and Transformation of Programs. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Pierik, C. and de Boer, F. S. 2004. Modularity and the rule of adaptation. In Algebraic Methodology and Software Technology, 10th International Conference, C. Rattray, et al., Eds. Lecture Notes in Computer Science, vol. 3116. Springer-Verlag, New York, 394--408.Google ScholarGoogle Scholar
  40. Spivey, J. 1988. Understanding Z: A Specification Language and its Formal Semantics. Cambridge University Press, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Tarski, A. 1955. A lattice-theoretical fixpoint theorem and its applications. Pacific J. Math. 5, 285--309.Google ScholarGoogle ScholarCross RefCross Ref
  42. Tunnicliffe, W. R. 1985. The free completely distributive lattice over a poset. Algebra Universalis 21, 133--135.Google ScholarGoogle ScholarCross RefCross Ref
  43. von Wright, J. 1994. The lattice of data refinement. Acta Inf. 31, 105--135. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Wadler, P. 1992. The essence of functional programming. In Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM, New York, 1--14. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Woodcock, J. and Loomes, M. 1988. Software Engineering Mathematics. Addison-Wesley Longman, Boston, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Term transformers: A new approach to state

                  Recommendations

                  Reviews

                  Richard John Botting

                  I hope the ideas in this paper will lead to clearer languages and documentation. All language reference manuals use some kind of Backus-Naur form (BNF) grammar to define syntax. Hardly any provide formal semantics. People have proposed operational, axiomatic, and denotational methods. None has become popular. This paper extends Dijkstra's work on predicate transformers. These are a form of axiomatic semantics. They help programmers construct correct programs. This paper extends predicate transformers to work on general expressions or terms. For example, an assignment such as x := x +1; has a term transformer that maps the expression x × y into ( x +1) y . This paper presents a logic of phrases that includes term transformers. It attempts to explain the theory. The confusing initial examples do not help. Delayed definitions make it even worse. For example, defining T as including the maps T__?__T allows paradoxes. But this possibility is excluded in an appendix where the maps must be monotonic. The middle of the paper proves results. The appendices state the axioms. Readers need to understand Dijkstra's work, the lambda calculus, and formal logic. Perhaps they should start with the appendices. Farmer and von Mohrenschildt [1] define a different kind of term transformer using von Neumann-Bernays-Gödel set theory. They aim to improve theorem provers. They do not develop them in the direction of semantics. Somebody should introduce these two teams of researchers. Term transformers are worthy of study and application. These papers are a good start. Morris et al. promise a sequel, applying them to define a real language. 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!