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.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
In OCaml programs, arguments of constructors are parenthesized and comma separated. If a constructor is replaced with some function by the command, arguments of the constructor are interpreted as tuples.
- 2.
The specification language of Coq.
- 3.
is the canonical instance of nat.
- 4.
expressions are syntax sugar for match expressions in Coq.
- 5.
Implementing it as a part of the simplification of MiniML terms is difficult, because MiniML is a type-free language.
- 6.
It is extracted by disabling new optimization mechanisms described in Sect. 4, but compiled with same OCaml compiler and optimization flags.
- 7.
Here we assume that is a total order and means “less than or equal to” in some sense.
References
Brady, E.: Programming and reasoning with algebraic effects and dependent types. In: ICFP 2013, pp. 133–144. ACM (2013)
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_14
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)
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_23
Launchbury, J., Peyton Jones, S.L.: Lazy functional state threads. In: PLDI 1994, pp. 24–35. ACM (1994)
Leroy, X.: A formally verified compiler back-end. J. Autom. Reason. 43(4), 363–446 (2009)
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
Letouzey, P.: Programmation fonctionnelle certifiée - L’extraction de programmes dans l’assistant Coq. Ph.D. thesis, Université Paris-Sud (2004)
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
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_5
Mahboubi, A., Tassi, E.: Mathematical components (2016). https://math-comp.github.io/mcb/book.pdf
Nanevski, A., Morrisett, G., Birkedal, L.: Hoare type theory, polymorphism and separation. J. Funct. Prog 18(5–6), 865–911 (2008)
Nanevski, A., Morrisett, G., Shinnar, A., Govereau, P., Birkedal, L.: Ynot: dependent types for imperative programs. In: ICFP 2008, pp. 229–240. ACM (2008)
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_1
Paulin-Mohring, C.: Extracting \({F}_{\omega }\)’s programs from proofs in the Calculus of Constructions. In: POPL 1989, pp. 89–104. ACM (1989)
Sakaguchi, K., Kameyama, Y.: Efficient finite-domain function library for the Coq proof assistant. IPSJ Trans. Prog. 10(1), 14–28 (2017)
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)
Tarjan, R.E.: Efficiency of a good but not linear set union algorithm. J. ACM 22(2), 215–225 (1975)
Tarjan, R.E., van Leeuwen, J.: Worst-case analysis of set union algorithms. J. ACM 31(2), 245–281 (1984)
The Coq Development Team: The Coq Proof Assistant Reference Manual (2017). https://coq.inria.fr/distrib/V8.7.0/refman/
The Mathematical Components Project: The mathematical components repository. https://github.com/math-comp/math-comp
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_2
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.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer International Publishing AG, part of Springer Nature
About this paper
Cite this paper
Sakaguchi, K. (2018). Program Extraction for Mutable Arrays. In: Gallagher, J., Sulzmann, M. (eds) Functional and Logic Programming. FLOPS 2018. Lecture Notes in Computer Science(), vol 10818. Springer, Cham. https://doi.org/10.1007/978-3-319-90686-7_4
Download citation
DOI: https://doi.org/10.1007/978-3-319-90686-7_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-90685-0
Online ISBN: 978-3-319-90686-7
eBook Packages: Computer ScienceComputer Science (R0)