Skip to main content

The Scallina Grammar

Towards a Scala Extraction for Coq

  • Conference paper
  • First Online:
Formal Methods: Foundations and Applications (SBMF 2018)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 11254))

Included in the following conference series:

Abstract

In response to the challenges associated with a Coq-based extraction of readable and traceable Scala code, the Scallina project defines a grammar delimiting a common subset of Gallina and Scala along with an optimized translation strategy for programs conforming to the aforementioned grammar. The Scallina translator shows how these contributions can be transferred into a working prototype. A typical application features a user implementing a functional program in Gallina, the core language of Coq, proving this program’s correctness with regards to its specification and making use of Scallina to synthesize readable Scala components.

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 49.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 64.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.

    An implementation extracted from a program which is proven-correct in a proof assistant can be considered correct when one assumes that the proof assistant itself and its corresponding extraction mechanism are correct.

  2. 2.

    Unless these programs are rewritten from scratch and manually proven using the proof assistant.

  3. 3.

    http://logika.sireum.org.

  4. 4.

    Scheme will not be considered in this paper since it is not statically typed.

  5. 5.

    https://github.com/JBakouny/Scallina/tree/v0.5.0.

  6. 6.

    Except that types cannot start by an abstraction or a constructor.

  7. 7.

    More information about Leon’s Pure Scala is available in paragraph 3 of [3] and in the documentation section of http://leon.epfl.ch.

  8. 8.

    https://github.com/JBakouny/Scallina/blob/master/src/main/resources/scala/of/coq/lang/PeanoNat.scala.

  9. 9.

    Note that values can, in turn, easily be converted to Java values.

  10. 10.

    https://github.com/JBakouny/Scallina/tree/v0.5.0/packaged-examples/v0.5.0/list-queue.

  11. 11.

    http://www.cnrs.edu.lb/.

  12. 12.

    http://proofcafe.org/wiki/en/Coq2Scala.

  13. 13.

    https://www.murex.com/.

References

  1. Amin, N., Grütter, S., Odersky, M., Rompf, T., Stucki, S.: The essence of dependent object types. In: Lindley, S., McBride, C., Trinder, P., Sannella, D. (eds.) A List of Successes That Can Change the World. LNCS, vol. 9600, pp. 249–272. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-30936-1_14

    Chapter  MATH  Google Scholar 

  2. Barthe, G., Forest, J., Pichardie, D., Rusu, V.: Defining and reasoning about recursive functions: a practical tool for the coq proof assistant. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 114–129. Springer, Heidelberg (2006). https://doi.org/10.1007/11737414_9

    Chapter  MATH  Google Scholar 

  3. Blanc, R., Kuncak, V., Kneuss, E., Suter, P.: An overview of the leon verification system: verification by translation to recursive functions. In: Proceedings of the 4th Workshop on Scala, SCALA 2013, pp. 1:1–1:10. ACM, New York (2013). https://doi.org/10.1145/2489837.2489838

  4. 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 

  5. Guallart, N.: An overview of type theories. Axiomathes 25(1), 61–77 (2015). https://doi.org/10.1007/s10516-014-9260-9

  6. Haftmann, F., Bulwahn, L.: Code generation from Isabelle/HOL theories, October 2017. https://isabelle.in.tum.de/dist/Isabelle2017/doc/codegen.pdf

  7. Haftmann, F., Nipkow, T.: Code generation via higher-order rewrite systems. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) FLOPS 2010. LNCS, vol. 6009, pp. 103–117. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-12251-4_9

    Chapter  Google Scholar 

  8. Hindley, R.: The principle type-scheme of an object in combinatory logic. Trans. Am. Math. Soc. 146, 29–60 (1969)

    MathSciNet  MATH  Google Scholar 

  9. Hupel, L., Kuncak, V.: Translating Scala programs to Isabelle/HOL. In: Olivetti, N., Tiwari, A. (eds.) IJCAR 2016. LNCS (LNAI), vol. 9706, pp. 568–577. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-40229-1_38

    Chapter  Google Scholar 

  10. Klein, G., et al.: sel4: formal verification of an OS kernel. In: Matthews, J.N., Anderson, T.E. (eds.) Proceedings of the 22nd ACM Symposium on Operating Systems Principles 2009, SOSP 2009, Big Sky, Montana, USA, 11–14 October 2009, pp. 207–220. ACM (2009). https://doi.org/10.1145/1629575.1629596

  11. Kuncak, V.: Developing verified software using Leon. In: Havelund, K., Holzmann, G., Joshi, R. (eds.) NFM 2015. LNCS, vol. 9058, pp. 12–15. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-17524-9_2

    Chapter  Google Scholar 

  12. Leroy, X.: Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In: Morrisett, J.G., Jones, S.L.P. (eds.) Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2006, Charleston, South Carolina, USA, 11–13 January 2006, pp. 42–54. ACM (2006). https://doi.org/10.1145/1111037.1111042

  13. Letouzey, P.: A new extraction for Coq. In: Geuvers, H., Wiedijk, F. (eds.) TYPES 2002. LNCS, vol. 2646, pp. 200–219. Springer, Heidelberg (2003). https://doi.org/10.1007/3-540-39185-1_12

    Chapter  MATH  Google Scholar 

  14. Letouzey, P.: Programmation fonctionnelle certifiée : L’extraction de programmes dans l’assistant Coq. (Certified functional programming : Program extraction within Coq proof assistant). Ph.D. thesis, University of Paris-Sud, Orsay, France (2004). https://tel.archives-ouvertes.fr/tel-00150912

  15. Letouzey, P.: Extraction in Coq: an overview. In: Beckmann, A., Dimitracopoulos, C., Löwe, B. (eds.) CiE 2008. LNCS, vol. 5028, pp. 359–369. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-69407-6_39

    Chapter  Google Scholar 

  16. The Coq development team: The Coq proof assistant reference manual. LogiCal Project (2004). http://coq.inria.fr, version 8.0

  17. Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978). https://doi.org/10.1016/0022-0000(78)90014-4

    Article  MathSciNet  Google Scholar 

  18. Nipkow, T., Wenzel, M., Paulson, L.C. (eds.): Isabelle/HOL. LNCS, vol. 2283. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45949-9

    Book  MATH  Google Scholar 

  19. Odersky, M.: The scala language specification. Technical report, Programming Methods Laboratory, EPFL, Lausanne, Switzerland, June 2014

    Google Scholar 

  20. Odersky, M., Rompf, T.: Unifying functional and object-oriented programming with Scala. Commun. ACM 57(4), 76–86 (2014). https://doi.org/10.1145/2591013

    Article  Google Scholar 

  21. Odersky, M., Spoon, L., Venners, B.: Programming in Scala: A Comprehensive Step-by-Step Guide, 2nd edn. Artima Incorporation, USA (2011)

    Google Scholar 

Download references

Acknowledgement

The authors would like to thank the National Council for Scientific Research in Lebanon (CNRS-L) for their funding, as well as Murex S.A.S for providing financial support.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Youssef El Bakouny .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

El Bakouny, Y., Mezher, D. (2018). The Scallina Grammar. In: Massoni, T., Mousavi, M. (eds) Formal Methods: Foundations and Applications. SBMF 2018. Lecture Notes in Computer Science(), vol 11254. Springer, Cham. https://doi.org/10.1007/978-3-030-03044-5_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-03044-5_7

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-03043-8

  • Online ISBN: 978-3-030-03044-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics