Advertisement

Program Extraction for Mutable Arrays

  • Kazuhiko Sakaguchi
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10818)

Abstract

We present a mutable array programming library for the Coq proof assistant which enables simple reasoning method based on Ssreflect/Mathematical Components, and extractions of the efficient OCaml programs using in-place updates. To refine the performance of extracted programs, we improved the extraction plugin of Coq. The improvements are based on trivial transformations for purely functional programs and reduce the construction and destruction costs of (co)inductive objects, and function call costs effectively. As a concrete application for our library and the improved extraction plugin, we provide efficient implementations, proofs, and benchmarks of two algorithms: the union–find data structure and the quicksort algorithm.

Notes

Acknowledgments

We thank Yukiyoshi Kameyama and anonymous referees for valuable comments on an earlier version of this paper. This work was supported by JSPS KAKENHI Grant Number 17J01683.

References

  1. 1.
    Brady, E.: Programming and reasoning with algebraic effects and dependent types. In: ICFP 2013, pp. 133–144. ACM (2013)Google Scholar
  2. 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).  https://doi.org/10.1007/978-3-540-71067-7_14CrossRefGoogle Scholar
  3. 3.
    Chlipala, A., Malecha, G., Morrisett, G., Shinnar, A., Wisnesky, R.: Effective interactive proofs for higher-order imperative programs. In: ICFP 2009, pp. 79–90. ACM (2009)Google Scholar
  4. 4.
    Garillot, F., Gonthier, G., Mahboubi, A., Rideau, L.: Packaging mathematical structures. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 327–342. Springer, Heidelberg (2009).  https://doi.org/10.1007/978-3-642-03359-9_23CrossRefGoogle Scholar
  5. 5.
    Launchbury, J., Peyton Jones, S.L.: Lazy functional state threads. In: PLDI 1994, pp. 24–35. ACM (1994)Google Scholar
  6. 6.
    Leroy, X.: A formally verified compiler back-end. J. Autom. Reason. 43(4), 363–446 (2009)MathSciNetCrossRefGoogle Scholar
  7. 7.
    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_12CrossRefMATHGoogle Scholar
  8. 8.
    Letouzey, P.: Programmation fonctionnelle certifiée - L’extraction de programmes dans l’assistant Coq. Ph.D. thesis, Université Paris-Sud (2004)Google Scholar
  9. 9.
    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_39CrossRefGoogle Scholar
  10. 10.
    Mahboubi, A., Tassi, E.: Canonical structures for the working Coq user. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 19–34. Springer, Heidelberg (2013).  https://doi.org/10.1007/978-3-642-39634-2_5CrossRefGoogle Scholar
  11. 11.
    Mahboubi, A., Tassi, E.: Mathematical components (2016). https://math-comp.github.io/mcb/book.pdf
  12. 12.
    Nanevski, A., Morrisett, G., Birkedal, L.: Hoare type theory, polymorphism and separation. J. Funct. Prog 18(5–6), 865–911 (2008)MathSciNetCrossRefGoogle Scholar
  13. 13.
    Nanevski, A., Morrisett, G., Shinnar, A., Govereau, P., Birkedal, L.: Ynot: dependent types for imperative programs. In: ICFP 2008, pp. 229–240. ACM (2008)CrossRefGoogle Scholar
  14. 14.
    O’Hearn, P., Reynolds, J., Yang, H.: Local reasoning about programs that alter data structures. In: Fribourg, L. (ed.) CSL 2001. LNCS, vol. 2142, pp. 1–19. Springer, Heidelberg (2001).  https://doi.org/10.1007/3-540-44802-0_1CrossRefGoogle Scholar
  15. 15.
    Paulin-Mohring, C.: Extracting \({F}_{\omega }\)’s programs from proofs in the Calculus of Constructions. In: POPL 1989, pp. 89–104. ACM (1989)Google Scholar
  16. 16.
    Sakaguchi, K., Kameyama, Y.: Efficient finite-domain function library for the Coq proof assistant. IPSJ Trans. Prog. 10(1), 14–28 (2017)Google Scholar
  17. 17.
    Swamy, N., Hriţcu, C., Keller, C., Rastogi, A., Delignat-Lavaud, A., Forest, S., Bhargavan, K., Fournet, C., Strub, P.Y., Kohlweiss, M., Zinzindohoue, J.K., Zanella-Béguelin, S.: Dependent types and multi-monadic effects in F\(^\star \). In: POPL 2016, pp. 256–270. ACM (2016)Google Scholar
  18. 18.
    Tarjan, R.E.: Efficiency of a good but not linear set union algorithm. J. ACM 22(2), 215–225 (1975)MathSciNetCrossRefGoogle Scholar
  19. 19.
    Tarjan, R.E., van Leeuwen, J.: Worst-case analysis of set union algorithms. J. ACM 31(2), 245–281 (1984)MathSciNetCrossRefGoogle Scholar
  20. 20.
    The Coq Development Team: The Coq Proof Assistant Reference Manual (2017). https://coq.inria.fr/distrib/V8.7.0/refman/
  21. 21.
    The Mathematical Components Project: The mathematical components repository. https://github.com/math-comp/math-comp
  22. 22.
    Wadler, P.: Monads for functional programming. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 24–52. Springer, Heidelberg (1995).  https://doi.org/10.1007/3-540-59451-5_2CrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  1. 1.University of TsukubaTsukubaJapan

Personalised recommendations