Advertisement

Calculating Certified Compilers for Non-deterministic Languages

  • Patrick Bahr
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9129)

Abstract

Reasoning about programming languages with non-deterministic semantics entails many difficulties. For instance, to prove correctness of a compiler for such a language, one typically has to split the correctness property into a soundness and a completeness part, and then prove these two parts separately. In this paper, we present a set of proof rules to prove compiler correctness by a single proof in calculational style. The key observation that led to our proof rules is the fact that the soundness and completeness proof follow a similar pattern with only small differences. We condensed these differences into a single side condition for one of our proof rules. This side condition, however, is easily discharged automatically by a very simple form of proof search. We implemented this calculation framework in the Coq proof assistant. Apart from verifying a given compiler, our proof technique can also be used to formally derive – from the semantics of the source language – a compiler that is correct by construction. For such a derivation to succeed it is crucial that the underlying correctness argument proceeds as a single calculation, as opposed to separate calculations of the two directions of the correctness property. We demonstrate our technique by deriving a compiler for a simple language with interrupts.

Keywords

Virtual Machine Induction Hypothesis Target Language Side Condition Proof Obligation 
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.

References

  1. 1.
    Ager, M.S., Biernacki, D., Danvy, O., Midtgaard., J.: From interpreter to compiler and virtual machine: a functional derivation. Technical report RS-03-14, Department of Computer Science, University of Aarhus (2003)Google Scholar
  2. 2.
    Ager, M.S., Biernacki, D., Danvy, O., Midtgaard, J.: A functional correspondence between evaluators and abstract machines. In: Proceedings of the 5th ACM SIGPLAN International Conference on Principles and Practice of Declaritive Programming, pp. 8–19 (2003)Google Scholar
  3. 3.
    Backhouse, R.: Program Construction: Calculating Implementations from Specifications. Wiley, UK (2003)Google Scholar
  4. 4.
    Bahr, P., Hutton, G.: Calculating correct compilers, July 2014. submitted to J. Funct. ProgramGoogle Scholar
  5. 5.
    Danvy, O., Millikin, K.: On the equivalence between small-step and big-step abstract machines: a simple application of lightweight fusion. Inf. Process. Lett. 106(3), 100–109 (2008)MATHMathSciNetCrossRefGoogle Scholar
  6. 6.
    Hutton, G.: Programming in Haskell, vol. 2. Cambridge University Press, Cambridge (2007)Google Scholar
  7. 7.
    Hutton, G., Wright, J.: What is the meaning of these constant interruptions? J. Funct. Program. 17(06), 777–792 (2007)MATHMathSciNetCrossRefGoogle Scholar
  8. 8.
    Kahn, G.: Natural semantics. In: Proceedings of the 4th Annual Symposium on Theoretical Aspects of Computer Science, pp. 22–39 (1987)Google Scholar
  9. 9.
    Leroy, X.: Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In: Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 42–54 (2006)Google Scholar
  10. 10.
    Meijer, E.: Calculating compilers. Ph.D. thesis, Katholieke Universiteit Nijmegen (1992)Google Scholar
  11. 11.
    Mu, S.C., Ko, H.S., Jansson, P.: Algebra of programming in Agda: dependent types for relational program derivation. J. Funct. Program. 19, 545–579 (2009)MATHMathSciNetCrossRefGoogle Scholar
  12. 12.
    Tesson, J., Hashimoto, H., Hu, Z., Loulergue, F., Takeichi, M.: Program calculation in Coq. In: Johnson, M., Pavlovic, D. (eds.) AMAST 2010. LNCS, vol. 6486, pp. 163–179. Springer, Heidelberg (2011) CrossRefGoogle Scholar
  13. 13.
    Troelstra, A.S., van Dalen, D.: Constructivism in Mathematics: An Introduction, vol. 1. Elsevier, USA (1988) Google Scholar
  14. 14.
    Wand, M.: Deriving target code as a representation of continuation semantics. ACM Trans. Program. Lang. Syst. 4(3), 496–517 (1982)MATHCrossRefGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  1. 1.Department of Computer ScienceUniversity of CopenhagenCopenhagenDenmark

Personalised recommendations