Abstract
We explore the theory of regular language representations in the constructive type theory of Coq. We cover various forms of automata (deterministic, nondeterministic, one-way, two-way), regular expressions, and the logic WS1S. We give translations between all representations, show decidability results, and provide operations for various closure properties. Our results include a constructive decidability proof for the logic WS1S, a constructive refinement of the Myhill-Nerode characterization of regularity, and translations from two-way automata to one-way automata with verified upper bounds for the increase in size. All results are verified with an accompanying Coq development of about 3000 lines.
Similar content being viewed by others
Notes
Here, abstract means that no witness can be extracted from the existence proof. The function \(\mathsf {xchoose}_X\) computes a witness by enumerating elements of X. The proof argument is only used to guarantee termination.
The language \(L := \{\,a^nb^m\,\big |\,\text {The} n-\text {th Turing machine holds within m steps on input} \varepsilon \,\}\) is decidable, but the image of L under the homomorphism mapping a to a and b to \(\varepsilon \) is undecidable.
In [24], \({\hat{\delta }}\,\) is defined recursively starting from the right end of the word. In Coq, structural recursion is more natural and the impact on the proofs appears to be minimal.
Wu et al. [42] derive the closure of regular expressions under complement by proving the Myhill–Nerode theorem using regular expressions. The proof is significantly more complex than the automata constructions.
That the transitive closure of a decidable relation is decidable is established in the Ssreflect libraries using depth-first search.
References
Abadi, M., Cardelli, L., Curien, P., Lévy, J.: Explicit substitutions. J. Funct. Program. 1(4), 375–416 (1991)
Berghofer, S., Reiter, M.: Formalizing the logic-automaton connection. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) Theorem Proving in Higher Order Logics (TPHOLs 2009). LNCS, vol. 5674, pp. 147–163. Springer (2009)
Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.): Interactive Theorem Proving—4th International Conference, ITP 2013, Rennes, France, July 22–26, 2013. Proceedings, LNCS, vol. 7998. Springer (2013)
Braibant, T., Pous, D.: Deciding kleene algebras in Coq. Log. Methods. Comput. Sci. 8(1:16), 1–42 (2012)
Brzozowski, J.A.: Derivatives of regular expressions. J. ACM 11(4), 481–494 (1964)
Büchi, J.R.: Weak second-order arithmetic and finite automata. Zeitschr. f. math. Logic und Grundladen d. Math. 6, 66–92 (1960)
Cohen, C.: Pragmatic quotient types in Coq. In: Blazy et al. [3], pp. 213–228
Constable, R.L., Jackson, P.B., Naumov, P., Uribe, J.C.: Constructively formalizing automata theory. In: Plotkin, G.D., Stirling, C., Tofte, M. (eds.) Proof, Language, and Interaction, pp. 213–238. The MIT Press, Cambridge (2000)
Coquand, T., Siles, V.: A decision procedure for regular expression equivalence in type theory. In: Jouannaud, J.P., Shao, Z. (eds.) Certified Programs and Proofs (CPP 2011). LNCS, vol. 7086, pp. 119–134. Springer (2011)
Doczkal, C., Kaiser, J.O., Smolka, G.: Coq development accompanying this paper (Online Resource 1), https://github.com/chdoc/coq-reglang
Doczkal, C., Kaiser, J., Smolka, G.: A constructive theory of regular languages in Coq. In: Gonthier, G., Norrish, M. (eds.) Certified Programs and Proofs (CPP 2013). LNCS, vol. 8307, pp. 82–97. Springer (2013)
Doczkal, C., Smolka, G.: Two-way automata in Coq. In: Blanchette, J.C., Merz, S. (eds.) Interactive Theorem Proving (ITP 2016). LNCS, vol. 9807, pp. 151–166. Springer (2016)
Elgot, C.C.: Decision problems of finite automata design and related arithmetics. Trans. Am. Math. Soc. 98, 21–51 (1961)
Filliâtre, J.C.: Finite automata theory in Coq: A constructive proof of kleene’s theorem. Tech. Rep. 97-04, LIP - ENS Lyon (1997)
Gelade, W., Neven, F.: Succinctness of the complement and intersection of regular expressions. ACM Trans. Comput. Logic 13(1), 4:1–4:19 (2012)
Gonthier, G., Mahboubi, A., Rideau, L., Tassi, E., Théry, L.: A modular formalisation of finite group theory. In: Schneider, K., Brandt, J. (eds.) Theorem Proving in Higher Order Logics (TPHOLs 2007). LNCS, vol. 4732, pp. 86–101. Springer (2007)
Grädel, E., Thomas, W., Wilke, T. (eds.): Automata, logics, and infinite games: a guide to current research [outcome of a Dagstuhl seminar, February 2001], LNCS, vol. 2500. Springer (2002)
Hedberg, M.: A coherence theorem for Martin-Löf’s type theory. J. Funct. Program. 8(4), 413–436 (1998)
Hofmann, M., Lange, M.: Automatentheorie und Logik. eXamen.press, Springer, Berlin (2011)
Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation - international edition (2. ed). Addison-Wesley, Boston (2001)
Johnsonbaugh, R., Miller, D.P.: Converses of pumping lemmas. In: Austing, R.H., Cassel, L.N., Miller, J.E., Joyce, D.T. (eds.) Proceedings of the 21st SIGCSE Technical Symposium on Computer Science Education, 1990, Washington, DC, USA, 1990. pp. 27–30. ACM (1990)
Khoussainov, B., Nerode, A.: Automata Theory and its Applications. Springer, Berlin (2012)
Kleene, S.C.: Representation of events in nerve nets and finite automata. In: Shannon, C.E., McCarthy, J. (eds.) Automata Studies, pp. 3–42. Princeton University Press, Princeton (1956)
Kozen, D.: Automata and computability. Undergraduate texts in computer science. Springer, Berlin (1997)
Krauss, A., Nipkow, T.: Proof pearl: Regular expression equivalence and relation algebra. J. Autom. Reason. 49(1), 95–106 (2012)
Moreira, N., Pereira, D., de Sousa, S.M.: Deciding kleene algebra terms equivalence in Coq. J. Log. Algebr. Methods Program. 84(3), 377–401 (2015)
Nipkow, T.: Verified lexical analysis. In: Grundy, J., Newey, M.C. (eds.) Theorem Proving in Higher Order Logics (TPHOLs ’98). LNCS, vol. 1479, pp. 1–15. Springer (1998)
Paulson, L.C.: A formalisation of finite automata using hereditarily finite sets. In: Felty, A.P., Middeldorp, A. (eds.) Automated deduction (CADE-25). LNCS, vol. 9195, pp. 231–245. Springer (2015)
Pighizzini, G.: Two-way finite automata: old and recent results. Fundam. Inform. 126(2–3), 225–246 (2013)
Pous, D.: Kleene algebra with tests and coq tools for while programs. In: Blazy et al. [3], pp. 180–196
Rabin, M.O., Scott, D.: Finite automata and their decision problems. IBM J. Res. Dev. 3(2), 114–125 (1959)
Reinhardt, K.: The complexity of translating logic to finite automata. In: Grädel et al. [17], pp. 231–238
Rosenberg, A.L.: State. In: Goldreich, O., Rosenberg, A.L., Selman, A.L. (eds.) Theoretical computer science, essays in memory of Shimon even. LNCS, vol. 3895, pp. 375–398. Springer (2006)
Shepherdson, J.: The reduction of two-way automata to one-way automata. IBM J. Res. Dev. 3, 198–200 (1959)
The Coq Proof Assistant: http://coq.inria.fr
The Mathematical Components Project: http://math-comp.github.io/math-comp/
Trakhtenbrot, B.A.: Finite automata and the logic of monadic predicates. Dokl. Akad. Nauk SSSR 140, 326–329 (1961)
Traytel, D., Nipkow, T.: Verified decision procedures for MSO on words based on derivatives of regular expressions. J. Funct. Program. 25, 1–30 (2015)
Vardi, M.Y.: A note on the reduction of two-way automata to one-way automata. Inf. Process. Lett. 30(5), 261–264 (1989)
Vardi, M.Y.: Endmarkers can make a difference. Inf. Process. Lett. 35(3), 145–148 (1990)
Wu, C., Zhang, X., Urban, C.: A formalisation of the Myhill-Nerode theorem based on regular expressions (proof pearl). In: van Eekelen, M.C.J.D., Geuvers, H., Schmaltz, J., Wiedijk, F. (eds.) Interactive Theorem Proving (ITP 2011). LNCS, vol. 6898, pp. 341–356. Springer (2011)
Wu, C., Zhang, X., Urban, C.: A formalisation of the Myhill-Nerode theorem based on regular expressions. J. Autom. Reason. 52(4), 451–480 (2014)
Acknowledgements
We thank Jan-Oliver Kaiser, who was involved in our previous work on one-way automata and also in some of the early experiments with two-way automata. We also thank Damien Pous and the anonymous reviewers for helpful comments.
Author information
Authors and Affiliations
Corresponding author
Additional information
C. Doczkal: This author has been funded by the European Research Council (ERC) under the European Union’s Horizon 2020 programme (CoVeCe, Grant agreement No 678157). This work was supported by the LABEX MILYON (ANR-10-LABX-0070) of Université de Lyon, within the program “Investissements d’Avenir” (ANR-11-IDEX-0007) operated by the French National Research Agency (ANR).
Electronic supplementary material
Below is the link to the electronic supplementary material.
Rights and permissions
About this article
Cite this article
Doczkal, C., Smolka, G. Regular Language Representations in the Constructive Type Theory of Coq. J Autom Reasoning 61, 521–553 (2018). https://doi.org/10.1007/s10817-018-9460-x
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10817-018-9460-x