Mechanizing Programming Logics in Higher Order Logic

  • Michael J. C. Gordon

Abstract

Formal reasoning about computer programs can be based directly on the semantics of the programming language, or done in a special purpose logic like Hoare logic. The advantage of the first approach is that it guarantees that the formal reasoning applies to the language being used (it is well known, for example, that Hoare’s assignment axiom fails to hold for most programming languages). The advantage of the second approach is that the proofs can be more direct and natural.

In this paper, an attempt to get the advantages of both approaches is described. The rules of Hoare logic are mechanically derived from the semantics of a simple imperative programming language (using the HOL system). These rules form the basis for a simple program veri­fier in which verification conditions are generated by LCF-style tactics whose validations use the derived Hoare rules. Because Hoare logic is derived, rather than postulated, it is straightforward to mix semantic and axiomatic reasoning. It is also straightforward to combine the con­structs of Hoare logic with other application-specific notations. This is briefly illustrated for various logical constructs, including termina­tion statements, VDM-style ‘relational’ correctness specifications, weak­est precondition statements and dynamic logic formulae.

The theory underlying the work presented here is well known. Our contribution is to propose a way of mechanizing this theory in a way that makes certain practical details work out smoothly.

Keywords

Predicate Logic Program Variable Dynamic Logic Verification Condition High Order Logic 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Andrews, P.B.,An Introduction to Mathematical Logic and Type Theory, Academic Press, 1986.MATHGoogle Scholar
  2. Boyer, R.S. and Moore, J S., AComputational Logic, Academic Press, 1979.MATHGoogle Scholar
  3. Boyer, R.S., and Moore, J S., ’Metafunctions: proving them correct and using them efficiently as new proof procedures’ in Boyer, R.S. and Moore, J S. (eds),The Correctness Problem in ComputerScience, Academic Press, New York, 1981.Google Scholar
  4. Clarke, E.M. Jr., ’The characterization problem for Hoare logics’, in Hoare, C.A.R. and Shepherdson, J.C. (eds),Mathematical Logic and Programming Languages, Prentice Hall, 1985.Google Scholar
  5. A. Church, ’A Formulation of the Simple Theory of Types’, Journal of Symbolic Logic 5, 1940.Google Scholar
  6. Dijkstra, E.W., ADiscipline of Programming, Prentice-Hall, 1976.MATHGoogle Scholar
  7. Floyd, R.W., ’Assigning meanings to programs’, in Schwartz, J.T. (ed.),Mathematical Aspects of Computer Science, Proceedings of Symposia in Applied Mathematics 19(American Mathematical Society), Providence, pp. 19 - 32, 1967.Google Scholar
  8. Good, D.I., ’Mechanical proofs about computer programs’, in Hoare, C.A.R. and Shepherdson, J.C. (eds),Mathematical Logic and Programming Languages, Prentice Hall, 1985.Google Scholar
  9. Goldblatt, R.,Logics of Time and Computation, CSLI Lecture Notes 7, CSLI/Stanford, Ventura Hall, Stanford, CA 94305, USA, 1987.Google Scholar
  10. Gordon, M.J.C., ’Representing a logic in the LCF metalanguage’, in Neel, D. (ed.),Tools and Notions for Program Construction, Cambridge University Press, 1982.Google Scholar
  11. Gordon, M.J.C., Milner, A.J.R.G. and Wadsworth, C.P.,Edinburgh LCF: a mechanized logic of computation, Springer Lecture Notes in Computer Science78, Springer-Verlag, 1979.Google Scholar
  12. M. Gordon, ’Why Higher-order Logic is a Good Formalism for Specifying and Verifying Hardware’, in G. Milne and P. A. Subrahmanyam (eds),Formal Aspects of VLSI Design, North-Holland, 1986.Google Scholar
  13. Gordon, M.J.C., ’HOL: A Proof Generating System for Higher-Order Logic’, University of Cambridge, Computer Laboratory, Tech. Report No. 103, 1987; Revised version in G. Birtwistle and P.A. Subrahmanyam (eds),VLSI Specification, Verification and Synthesis, Kluwer, 1987.Google Scholar
  14. Gordon, M.J.C.,Programming Language Theory and its Implementation, Prentice-Hall, 1988.Google Scholar
  15. Gries, D.,The Science of Programming, Springer-Verlag, 1981.MATHGoogle Scholar
  16. Hoare, C.A.R., ’An axiomatic basis for computer programming’,Communications of the ACM 12, pp. 576 - 583, October 1969.MATHCrossRefGoogle Scholar
  17. Igarashi, S., London, R.L., Luckham, D.C., ’Automatic program verification I: logical basis and its implementation’, Acta Informatica 4, 1975, pp. 145 - 182.MathSciNetCrossRefGoogle Scholar
  18. INMOS Limited, ’Occam Programming Language’, Prentice-Hall.Google Scholar
  19. Jones, C.B., ’Systematic Program Development’ in Gehani, N. & McGettrick, A.D. (eds),Software Specification Techniques, Addison-Wesley, 1986.Google Scholar
  20. Joyce, J. J., Forthcoming Ph.D. thesis, University of Cambridge Computer Laboratory, expected 1989.Google Scholar
  21. Ligler, G.T., ’A mathematical approach to language design’, inProceedings of the Second ACM Symposium on Principles of Programming Languages pp. 41-53.Google Scholar
  22. Loeckx, J. and Sieber, K.,The Foundations of Program Verification, John Wiley & Sons Ltd. and B.G. Teubner, Stuttgart, 1984.Google Scholar
  23. London, R.L., et al. ’Proof rules for the programming language Euclid’, ActaInformatica 10, No. 1, 1978.Google Scholar
  24. Fourman, M.P., ’The Logic of Topoi’, in Barwise, J. (ed.),Handbook of Mathematical Logic, North-Holland, 1977.Google Scholar
  25. Melham. T.F., ’Automating Recursive Type Definitions in Higher Order Logic’, Proceedings of the1988 Banff Conference on Hardware Verification this volume.Google Scholar
  26. Mosses, P.D., ’Compiler Generation using Denotational Semantics’, inMathematical Foundations of Computer Science, Lecture Notes in Computer Science 45, Springer-Verlag, 1976.Google Scholar
  27. Milner, A.R.J.G., ’A Theory of Type Polymorphism in Programming’,Journal of Computer and System Sciences17, 1978.Google Scholar
  28. Paulson, L.C., ’A higher-order implementation of rewriting’,Science of Computer Programming3, pp 143 - 170, 1985.MathSciNetCrossRefGoogle Scholar
  29. Paulson, L.C., ’Natural deduction as higher-order resolution’,Journal of Logic Programming3, pp 237 - 258, 1986.MathSciNetMATHCrossRefGoogle Scholar
  30. Paulson, L.C.,Logic and Computation: Interactive Proof with Cambridge LCF, Cambridge University Press, 1987.Google Scholar
  31. Plotkin, G.D., ’Dijkstra’s Predicate Transformers and Smyth’s Powerdomains’, in Bj0rner, D. (ed.),Abstract Software Specifications, Lecture Notes in Computer Science86, Springer-Verlag, 1986.Google Scholar
  32. Pratt, V.R., ’Semantical Considerations on Floyd-Hoare Logic’,Proceedings of the 17th IEEE Symposium on Foundations of Computer Science, 1976.Google Scholar
  33. Hayes, I. (ed.),Specification Case Studies, Prentice-Hall.Google Scholar

Copyright information

© Springer-Verlag New York Inc. 1989

Authors and Affiliations

  • Michael J. C. Gordon
    • 1
    • 2
  1. 1.Computer LaboratoryCambridgeUSA
  2. 2.SRI InternationalCambridgeUSA

Personalised recommendations