Skip to main content

Refinement to Imperative/HOL

  • Conference paper
  • First Online:
Interactive Theorem Proving (ITP 2015)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9236))

Included in the following conference series:

Abstract

Many algorithms can be implemented most efficiently with imperative data structures that support destructive update. In this paper we present an approach to automatically generate verified imperative implementations from abstract specifications in Isabelle/HOL. It is based on the Isabelle Refinement Framework, for which a lot of abstract algorithms are already formalized.

Based on Imperative/HOL, which allows to generate verified imperative code, we develop a separation logic framework with automation to make it conveniently usable. On top of this, we develop an imperative collection framework, which provides standard implementations for sets and maps like hash tables and array lists. Finally, we define a refinement calculus to refine abstract (functional) algorithms to imperative ones.

Moreover, we have implemented a tool to automate the refinement process, replacing abstract data types by efficient imperative implementations from our collection framework. As a case study, we apply our tool to automatically generate verified imperative implementations of nested depth-first search and Dijkstra’s shortest paths algorithm, which are considerably faster than the corresponding functional implementations. The nested DFS implementation is almost as fast as a C++ implementation of the same algorithm.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    For technical reasons, we formalize a partial heap as a full heap with an address range. Assertions must not depend on heap content outside this address range.

  2. 2.

    The distinction between values and arrays is dictated by Imperative/HOL.

  3. 3.

    Again, for technical reasons, we additionally check that the program does not modify addresses outside the heap’s address range, and that it does not deallocate memory.

  4. 4.

    Specified in Isabelle’s long goal format, which is more readable for large propositions.

  5. 5.

    Inserting x twice is redundant, but gives a nice example for our transformations.

  6. 6.

    We applied \(\alpha \)-conversion to give the newly created variables meaningful names.

  7. 7.

    Again, we applied \(\alpha \)-conversion, to make the generated variable names more readable.

References

  1. Bornat, R., Calcagno, C., O’Hearn, P., Parkinson, M.: Permission accounting in separation logic. In: POPL, pp. 259–270. ACM (2005)

    Google Scholar 

  2. Bulwahn, L., Krauss, A., Haftmann, F., Erkök, L., Matthews, J.: Imperative functional programming with isabelle/HOL. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 134–149. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  3. Calcagno, C., Distefano, D., O’Hearn, P., Yang, H.: Compositional shape analysis by means of bi-abduction. In: POPL 2009, pp. 289–300 (2009)

    Google Scholar 

  4. Calcagno, C., O’Hearn, P., Yang, H.: Local action and abstract separation logic. LICS 2007, 366–378 (2007)

    Google Scholar 

  5. Charguéraud, A.: Characteristic formulae for the verification of imperative programs. In: ICFP, pp. 418–430. ACM (2011)

    Google Scholar 

  6. Esparza, J., Lammich, P., Neumann, R., Nipkow, T., Schimpf, A., Smaus, J.-G.: A fully verified executable LTL model checker. In: Sharygina, N., Veith, H. (eds.) CAV 2013. LNCS, vol. 8044, pp. 463–478. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  7. Hinze, R., Paterson, R.: Finger trees: A simple general-purpose data structure. J. Funct. Program. 16(2), 197–217 (2006)

    Article  MATH  MathSciNet  Google Scholar 

  8. Holzmann, G., Peled, D., Yannakakis, M.: On nested depth first search. In: SPIN. Discrete Mathematics and Theoretical Computer Science, vol. 32, pp. 23–32. American Mathematical Society (1996)

    Google Scholar 

  9. Klein, G., Kolanski, R., Boyton, A.: Mechanised separation algebra. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 332–337. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  10. Krauss, A.: Recursive definitions of monadic functions. In: Proceedings of PAR, vol. 43, pp. 1–13 (2010)

    Google Scholar 

  11. Lammich, P.: Collections framework. In: Archive of Formal Proofs, Dec 2009. http://afp.sf.net/entries/Collections.shtml. Formal proof development

  12. Lammich, P.: Refinement for monadic programs. In: Archive of Formal Proofs (2012). http://afp.sf.net/entries/Refine_Monadic.shtml. Formal proof development

  13. Lammich, P.: Automatic data refinement. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 84–99. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  14. Lammich, P.: Verified efficient implementation of gabow’s strongly connected component algorithm. In: Klein, G., Gamboa, R. (eds.) ITP 2014. LNCS, vol. 8558, pp. 325–340. Springer, Heidelberg (2014)

    Google Scholar 

  15. Lammich, P., Lochbihler, A.: The isabelle collections framework. In: Kaufmann, M., Paulson, L.C. (eds.) ITP 2010. LNCS, vol. 6172, pp. 339–354. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  16. Lammich, P., Meis, R.: A separation logic framework for imperative hol. In: Archive of Formal Proofs, Nov 2012. http://afp.sf.net/entries/Separation_Logic_Imperative_HOL.shtml. Formal proof development

  17. Lammich, P., Tuerk, T.: Applying data refinement for monadic programs to hopcroft’s algorithm. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 166–182. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  18. Marti, N., Affeldt, R.: A certified verifier for a fragment of separation logic. In: PPL-Workshop (2007)

    Google Scholar 

  19. Meis, R.: Integration von Separation Logic in das Imperative HOL-Framework. Master Thesis, WWU Münster (2011)

    Google Scholar 

  20. MLton Standard ML compiler. http://mlton.org/

  21. Nanevski, A., Morrisett, G., Shinnar, A., Govereau, P., Birkedal, L.: Ynot: Reasoning with the awkward squad. In: ICFP (2008)

    Google Scholar 

  22. Neumann, R.: A framework for verified depth-first algorithms. In: Workshop on Automated Theory Exploration (ATX 2012), pp. 36–45 (2012)

    Google Scholar 

  23. Nordhoff, B., Lammich, P.: Formalization of Dijkstra’s algorithm. In: Archive of Formal Proofs, Jan 2012. http://afp.sf.net/entries/Dijkstra_Shortest_Path.shtml. Formal proof development

  24. Pelánek, R.: BEEM: benchmarks for explicit model checkers. In: Bošnački, D., Edelkamp, S. (eds.) SPIN 2007. LNCS, vol. 4595, pp. 263–267. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  25. Reynolds, J.C.: Separation logic: A logic for shared mutable data structures. In: Proceedings of Logic in Computer Science (LICS), pp. 55–74. IEEE (2002)

    Google Scholar 

  26. Schwoon, S., Esparza, J.: A note on on-the-fly verification algorithms. In: Halbwachs, N., Zuck, L.D. (eds.) TACAS 2005. LNCS, vol. 3440, pp. 174–190. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  27. Sedgewick, R., Wayne, K.: Algorithms, 4th edn. Addison-Wesley, Boston (2011)

    Google Scholar 

  28. Tuerk, T.: A separation logic framework for HOL. Technical report UCAM-CL-TR-799, University of Cambridge, Computer Laboratory, June 2011

    Google Scholar 

Download references

Acknowledgements

We thank Rene Meis for formalizing the basics of separation logic for Imperative/HOL. Moreover we thank Thomas Tuerk for interesting discussions about automation of separation logic.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Peter Lammich .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Springer International Publishing Switzerland

About this paper

Cite this paper

Lammich, P. (2015). Refinement to Imperative/HOL. In: Urban, C., Zhang, X. (eds) Interactive Theorem Proving. ITP 2015. Lecture Notes in Computer Science(), vol 9236. Springer, Cham. https://doi.org/10.1007/978-3-319-22102-1_17

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-22102-1_17

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-22101-4

  • Online ISBN: 978-3-319-22102-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics