Mechanizing Programming Logics in Higher Order Logic
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 verifier 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 constructs of Hoare logic with other application-specific notations. This is briefly illustrated for various logical constructs, including termination statements, VDM-style ‘relational’ correctness specifications, weakest 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.
KeywordsPredicate Logic Program Variable Dynamic Logic Verification Condition High Order Logic
Unable to display preview. Download preview PDF.
- 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
- 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
- A. Church, ’A Formulation of the Simple Theory of Types’, Journal of Symbolic Logic 5, 1940.Google Scholar
- 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
- 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
- Goldblatt, R.,Logics of Time and Computation, CSLI Lecture Notes 7, CSLI/Stanford, Ventura Hall, Stanford, CA 94305, USA, 1987.Google Scholar
- 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
- 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
- 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
- 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
- Gordon, M.J.C.,Programming Language Theory and its Implementation, Prentice-Hall, 1988.Google Scholar
- INMOS Limited, ’Occam Programming Language’, Prentice-Hall.Google Scholar
- Jones, C.B., ’Systematic Program Development’ in Gehani, N. & McGettrick, A.D. (eds),Software Specification Techniques, Addison-Wesley, 1986.Google Scholar
- Joyce, J. J., Forthcoming Ph.D. thesis, University of Cambridge Computer Laboratory, expected 1989.Google Scholar
- 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
- Loeckx, J. and Sieber, K.,The Foundations of Program Verification, John Wiley & Sons Ltd. and B.G. Teubner, Stuttgart, 1984.Google Scholar
- London, R.L., et al. ’Proof rules for the programming language Euclid’, ActaInformatica 10, No. 1, 1978.Google Scholar
- Fourman, M.P., ’The Logic of Topoi’, in Barwise, J. (ed.),Handbook of Mathematical Logic, North-Holland, 1977.Google Scholar
- Melham. T.F., ’Automating Recursive Type Definitions in Higher Order Logic’, Proceedings of the1988 Banff Conference on Hardware Verification this volume.Google Scholar
- Mosses, P.D., ’Compiler Generation using Denotational Semantics’, inMathematical Foundations of Computer Science, Lecture Notes in Computer Science 45, Springer-Verlag, 1976.Google Scholar
- Milner, A.R.J.G., ’A Theory of Type Polymorphism in Programming’,Journal of Computer and System Sciences17, 1978.Google Scholar
- Paulson, L.C.,Logic and Computation: Interactive Proof with Cambridge LCF, Cambridge University Press, 1987.Google Scholar
- 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
- Pratt, V.R., ’Semantical Considerations on Floyd-Hoare Logic’,Proceedings of the 17th IEEE Symposium on Foundations of Computer Science, 1976.Google Scholar
- Hayes, I. (ed.),Specification Case Studies, Prentice-Hall.Google Scholar