Skip to main content

Automated Algebraic Reasoning for Collections and Local Variables with Lenses

  • Conference paper
  • First Online:
Relational and Algebraic Methods in Computer Science (RAMiCS 2020)

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

Abstract

Lenses are a useful algebraic structure for giving a unifying semantics to program variables in a variety of store models. They support efficient automated proof in the Isabelle/UTP verification framework. In this paper, we expand our lens library with (1) dynamic lenses, that support mutable indexed collections, such as arrays, and (2) symmetric lenses, which allow partitioning of a state space into disjoint local and global regions to support variable scopes. From this basis, we provide an enriched program model in Isabelle/UTP for collection variables and variable blocks. For the latter, we adopt an approach first used by Back and von Wright, and derive weakest precondition and Hoare calculi. We demonstrate several examples, including verification of insertion sort.

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.

    The seL4 microkernel verification project: http://sel4.systems.

  2. 2.

    The similarly named quotient lens of Foster et al. [9] is a rather different concept.

References

  1. Armstrong, A., Gomes, V.B.F., Struth, G.: Building program construction and verification tools from algebraic principles. Formal Aspects Comput. 28(2), 265–293 (2015). https://doi.org/10.1007/s00165-015-0343-1

    Article  MathSciNet  MATH  Google Scholar 

  2. Dongol, B., Gomes, V.B.F., Struth, G.: A program construction and verification tool for separation logic. In: Hinze, R., Voigtländer, J. (eds.) MPC 2015. LNCS, vol. 9129, pp. 137–158. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-19797-5_7

    Chapter  MATH  Google Scholar 

  3. Gomes, V.B.F., Struth, G.: Modal Kleene algebra applied to program correctness. In: Fitzgerald, J., Heitmeyer, C., Gnesi, S., Philippou, A. (eds.) FM 2016. LNCS, vol. 9995, pp. 310–325. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-48989-6_19

    Chapter  Google Scholar 

  4. Huerta y Munive, J.J., Struth, G.: Verifying hybrid systems with modal Kleene algebra. In: Desharnais, J., Guttmann, W., Joosten, S. (eds.) RAMiCS 2018. LNCS, vol. 11194, pp. 225–243. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-02149-8_14

    Chapter  Google Scholar 

  5. Barnett, M., Chang, B.-Y.E., DeLine, R., Jacobs, B., Leino, K.R.M.: Boogie: a modular reusable verifier for object-oriented programs. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2005. LNCS, vol. 4111, pp. 364–387. Springer, Heidelberg (2006). https://doi.org/10.1007/11804192_17

    Chapter  Google Scholar 

  6. Filliâtre, J.-C., Paskevich, A.: Why3—where programs meet provers. In: Felleisen, M., Gardner, P. (eds.) ESOP 2013. LNCS, vol. 7792, pp. 125–128. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-37036-6_8

    Chapter  Google Scholar 

  7. Kozen, D.: Kleene algebra with tests. ACM TOPLAS 19(3), 427–443 (1992)

    Article  Google Scholar 

  8. Foster, J., Greenwald, M., Moore, J., Pierce, B., Schmitt, A.: Combinators for bidirectional tree transformations: a linguistic approach to the view-update problem. ACM Trans. Program. Lang. Syst. 29(3), 17-es (2007)

    Article  Google Scholar 

  9. Foster, J., Pilkiewicz, A., Pierce, B.: Quotient lenses. In: Proceedings of the 13th International Conference on Functional Programming (ICFP). ACM (2008)

    Google Scholar 

  10. Foster, S., Zeyda, F., Woodcock, J.: Unifying heterogeneous state-spaces with lenses. In: Sampaio, A., Wang, F. (eds.) ICTAC 2016. LNCS, vol. 9965, pp. 295–314. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-46750-4_17

    Chapter  Google Scholar 

  11. Foster, S., Cavalcanti, A., Canham, S., Woodcock, J., Zeyda, F.: Unifying theories of reactive design contracts. Theor. Comput. Sci. 802, 105–140 (2020)

    Article  MathSciNet  Google Scholar 

  12. Bockenek, J., Lammich, P., Nemouchi, Y., Wolff, B.: Using Isabelle/UTP for the verification of sorting algorithms. In: Proceedings of the Isabelle Workshop (FLoC) (2018)

    Google Scholar 

  13. Back, R.J., von Wright, J.: Refinement Calculus: A Systematic Introduction. Springer, New York (1998). https://doi.org/10.1007/978-1-4612-1674-2

    Book  MATH  Google Scholar 

  14. Foster, S., Zeyda, F., Woodcock, J.: Isabelle/UTP: a mechanised theory engineering framework. In: Naumann, D. (ed.) UTP 2014. LNCS, vol. 8963, pp. 21–41. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-14806-9_2

    Chapter  Google Scholar 

  15. Foster, S., Zeyda, F., Nemouchi, Y., Ribeiro, P., Wolff, B.: Isabelle/UTP: mechanised theory engineering for unifying theories of programming. Arch. Formal Proofs (2019). https://www.isa-afp.org/entries/UTP.html

  16. Hofmann, M., Pierce, B., Wagner, D.: Symmetric lenses. In: Proceedings of the 38th International Symposium on Principles of Programming Languages (POPL), pp. 371–384. IEEE (2011)

    Google Scholar 

  17. Alkassar, E., Hillebrand, M.A., Leinenbach, D., Schirmer, N.W., Starostin, A.: The Verisoft approach to systems verification. In: Shankar, N., Woodcock, J. (eds.) VSTTE 2008. LNCS, vol. 5295, pp. 209–224. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-87873-5_18

    Chapter  Google Scholar 

  18. Back, R.J., Preoteasa, V.: An algebraic treatment of procedure refinement to support mechanical verification. Formal Aspects Comput. 17(1), 69–90 (2005). https://doi.org/10.1007/s00165-004-0060-7

    Article  MATH  Google Scholar 

  19. Foster, S.: Hybrid relations in Isabelle/UTP. In: Ribeiro, P., Sampaio, A. (eds.) UTP 2019. LNCS, vol. 11885, pp. 130–153. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-31038-7_7

    Chapter  Google Scholar 

  20. Feliachi, A., Gaudel, M.-C., Wolff, B.: Unifying theories in Isabelle/HOL. In: Qin, S. (ed.) UTP 2010. LNCS, vol. 6445, pp. 188–206. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-16690-7_9

    Chapter  MATH  Google Scholar 

  21. Hoare, C.A.R., He, J.: Unifying Theories of Programming. Prentice-Hall, Upper Saddle River (1998)

    MATH  Google Scholar 

  22. Schirmer, N., Wenzel, M.: State spaces - the locale way. ENTCS 254, 161–179 (2009). (SSV 2009)

    Google Scholar 

  23. Greenaway, G., Lim, J., Andronick, J., Klein, G.: Don’t sweat the small stuff: formal verification of C code without the pain. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). ACM, June 2014

    Google Scholar 

  24. Dongol, B., Hayes, I., Meinicke, L., Struth, G.: Cylindric Kleene lattices for program construction. In: Hutton, G. (ed.) MPC 2019. LNCS, vol. 11825, pp. 197–225. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-33636-3_8

    Chapter  MATH  Google Scholar 

  25. Tarski, A.: On the calculus of relations. J. Symb. Log. 6(3), 73–89 (1941)

    Article  MathSciNet  Google Scholar 

  26. Hoare, C.A.R., et al.: The laws of programming. Commun. ACM 30(8), 672–686 (1987)

    Article  MathSciNet  Google Scholar 

  27. Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM 12(10), 576–580 (1969)

    Article  Google Scholar 

  28. Dijkstra, E.W.: Guarded commands, nondeterminacy and formal derivation of programs. Commun. ACM 18(8), 453–457 (1975)

    Article  MathSciNet  Google Scholar 

Download references

Acknowledgements

This work is funded by the EPSRC projects CyPhyAssure (CyPhyAssure Project: https://www.cs.york.ac.uk/circus/CyPhyAssure/.) (Grant EP/S001190/1) and RoboTest (Grant EP/R025479/1).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Simon Foster .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Foster, S., Baxter, J. (2020). Automated Algebraic Reasoning for Collections and Local Variables with Lenses. In: Fahrenberg, U., Jipsen, P., Winter, M. (eds) Relational and Algebraic Methods in Computer Science. RAMiCS 2020. Lecture Notes in Computer Science(), vol 12062. Springer, Cham. https://doi.org/10.1007/978-3-030-43520-2_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-43520-2_7

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-43519-6

  • Online ISBN: 978-3-030-43520-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics