skip to main content

Regular language type inference with term rewriting

Published:03 August 2020Publication History
Skip Abstract Section

Abstract

This paper defines a new type system applied to the fully automatic verification of safety properties of tree-processing higher-order functional programs. We use term rewriting systems to model the program and its semantics and tree automata to model algebraic data types. We define the regular abstract interpretation of the input term rewriting system where the abstract domain is a set of regular languages. From the regular abstract interpretation we derive a type system where each type is a regular language. We define an inference procedure for this type system which allows us check the validity of safety properties. The inference mechanism is built on an invariant learning procedure based on the tree automata completion algorithm. This invariant learning procedure is regularly-complete and complete in refutation, meaning that if it is possible to give a regular type to a term then we will eventually find it, and if there is no possible type (regular or not) then we will eventually find a counter-example.

Skip Supplemental Material Section

Supplemental Material

Presentation at ICFP '20

References

  1. Franz Baader and Tobias Nipkow. 1998. Term Rewriting and All That. Cambridge University Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Achim Blumensath and Erich Grädel. 2000. Automatic Structures. In 15th Annual IEEE Symposium on Logic in Computer Science, Santa Barbara, California, USA, June 26-29, 2000. IEEE Computer Society, 51-62. https://doi.org/10.1109/LICS. 2000.855755 Google ScholarGoogle ScholarCross RefCross Ref
  3. Giuseppe Castagna, Kim Nguyen, Zhiwu Xu, Hyeonseung Im, Sergueï Lenglet, and Luca Padovani. 2014. Polymorphic functions with set-theoretic types: part 1: syntax, semantics, and evaluation. In The 41st Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '14, San Diego, CA, USA, January 20-21, 2014, Suresh Jagannathan and Peter Sewell (Eds.). ACM, 5-18. https://doi.org/10.1145/2535838.2535840 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Giuseppe Castagna, Tommaso Petrucciani, and Kim Nguyen. 2016. Set-theoretic types for polymorphic variants. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016, Jacques Garrigue, Gabriele Keller, and Eijiro Sumii (Eds.). ACM, 378-391. https://doi.org/10.1145/ 2951913.2951928 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Adrien Champion, Tomoya Chiba, Naoki Kobayashi, and Ryosuke Sato. 2018. ICE-Based Refinement Type Discovery for Higher-Order Functional Programs. In Tools and Algorithms for the Construction and Analysis of Systems, Dirk Beyer and Marieke Huisman (Eds.). Springer International Publishing, Cham, 365-384.Google ScholarGoogle Scholar
  6. Koen Claessen, Moa Johansson, Dan Rosén, and Nicholas Smallbone. 2015. TIP: Tons of Inductive Problems. In Intelligent Computer Mathematics, Manfred Kerber, Jacques Carette, Cezary Kaliszyk, Florian Rabe, and Volker Sorge (Eds.). Springer International Publishing, Cham, 333-337.Google ScholarGoogle Scholar
  7. Edmund Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith. 2000. Counterexample-Guided Abstraction Refinement. In Computer Aided Verification, E. Allen Emerson and Aravinda Prasad Sistla (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 154-169.Google ScholarGoogle ScholarCross RefCross Ref
  8. Hubert Comon, Max Dauchet, Rémi Gilleron, Christof Löding, Florent Jacquemard, Denis Lugiez, Sophie Tison, and Marc Tommasi. 2007. Tree Automata Techniques and Applications. Available on: http://tata.gforge.inria.fr/. release October, 12th 2007.Google ScholarGoogle Scholar
  9. Experiments. 2020. Experiments with Regular Language Type Inference. https://people.irisa.fr/Thomas.Genet/timbuk/ timbuk4/experiments.htmlGoogle ScholarGoogle Scholar
  10. Thomas Genet. 2016. Termination criteria for tree automata completion. J. Log. Algebraic Methods Program. 85, 1 ( 2016 ), 3-33. https://doi.org/10.1016/j.jlamp. 2015. 05.003 Google ScholarGoogle ScholarCross RefCross Ref
  11. Thomas Genet, Yohan Boichut, Benoît Boyer, Valérie Murat, and Yan Salmon. 2001. Reachability Analysis and Tree Automata Calculations. IRISA / Université de Rennes 1. http://people.irisa.fr/Thomas.Genet/timbuk/Google ScholarGoogle Scholar
  12. Thomas Genet, Timothée Haudebourg, and Thomas Jensen. 2018. Verifying Higher-Order Functions with Tree Automata. In Foundations of Software Science and Computation Structures, Christel Baier and Ugo Dal Lago (Eds.). Springer International Publishing, Cham, 565-582.Google ScholarGoogle Scholar
  13. Thomas Genet, Tristan Le Gall, Axel Legay, and Valérie Murat. 2013. A Completion Algorithm for Lattice Tree Automata. In Implementation and Application of Automata, Stavros Konstantinidis (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 134-145.Google ScholarGoogle Scholar
  14. Thomas Genet and Vlad Rusu. 2010. Equational approximations for tree automata completion. J. Symb. Comput. 45, 5 ( 2010 ), 574-597. https://doi.org/10.1016/j.jsc. 2010. 01.009 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Timothée Haudebourg and Thomas Genet. 2020. Timbuk 4. https://gitlab.inria.fr/regular-pv/timbuk/timbukGoogle ScholarGoogle Scholar
  16. Timothée Haudebourg, Thomas Genet, and Thomas Jensen. 2020. Regular Language Type Inference with Term Rewriting-extended version. Technical Report. Univ Rennes, Inria, IRISA. https://hal.inria.fr/hal-02795484.Google ScholarGoogle Scholar
  17. J. Roger Hindley. 1969. The Principal Type-Scheme of an Object in Combinatory Logic. Trans. Amer. Math. Soc. 146 ( 1969 ), 29-60. http://www.jstor.org/stable/1995158Google ScholarGoogle Scholar
  18. Inria. 2016. The Coq proof assistant reference manual: Version 8.6. https://coq.inria.fr/distrib/current/files/ReferenceManual.pdfGoogle ScholarGoogle Scholar
  19. Thomas Johnsson. 1985. Lambda Lifting: Transforming Programs to Recursive Equations. In FPCA'85 (LNCS, Vol. 201 ). Springer, 190-203.Google ScholarGoogle Scholar
  20. Neil D. Jones. 1987. Flow analysis of lazy higher-order functional programs. In Abstract Interpretation of Declarative Languages, Samson Abramsky and Chris Hankin (Eds.). Ellis Horwood, 103-122.Google ScholarGoogle Scholar
  21. Neil D. Jones and Nils Andersen. 2007. Flow analysis of lazy higher-order functional programs. Theor. Comput. Sci. 375, 1-3 ( 2007 ), 120-136. https://doi.org/10.1016/j.tcs. 2006. 12.030 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Richard Kennaway, Jan Willem Klop, M. Ronan Sleep, and Fer-Jan de Vries. 1996. Comparing Curried and Uncurried Rewriting. J. Symb. Comput. 21, 1 ( 1996 ), 15-39. https://doi.org/10.1006/jsco. 1996.0002 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Bakhadyr Khoussainov and Anil Nerode. 1995. Automatic presentations of structures. In Logic and Computational Complexity, Daniel Leivant (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 367-392.Google ScholarGoogle Scholar
  24. Naoki Kobayashi. 2009. Types and higher-order recursion schemes for verification of higher-order programs. In Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, Savannah, GA, USA, January 21-23, 2009, Zhong Shao and Benjamin C. Pierce (Eds.). ACM, 416-428. https://doi.org/10.1145/1480881.1480933 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Naoki Kobayashi, Ryosuke Sato, and Hiroshi Unno. 2011a. MoCHi: Model Checker for Higher-Order Programs. http://www-kb.is.s.u-tokyo.ac.jp/~ryosuke/mochi/Google ScholarGoogle Scholar
  26. Naoki Kobayashi, Ryosuke Sato, and Hiroshi Unno. 2011b. Predicate abstraction and CEGAR for higher-order model checking. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2011, San Jose, CA, USA, June 4-8, 2011, Mary W. Hall and David A. Padua (Eds.). ACM, 222-233. https://doi.org/10. 1145/1993498.1993525 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Naoki Kobayashi, Naoshi Tabuchi, and Hiroshi Unno. 2010. Higher-order multi-parameter tree transducers and recursion schemes for program verification. In Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010, Madrid, Spain, January 17-23, 2010, Manuel V. Hermenegildo and Jens Palsberg (Eds.). ACM, 495-508. https://doi.org/10.1145/1706299.1706355 Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Tristan Le Gall and Bertrand Jeannet. 2007. Lattice Automata: A Representation for Languages on Infinite Alphabets, and Some Applications to Verification. In Static Analysis, Hanne Riis Nielson and Gilberto Filé (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 52-68.Google ScholarGoogle Scholar
  29. Yuma Matsumoto, Naoki Kobayashi, and Hiroshi Unno. 2015. Automata-Based Abstraction for Automated Verification of Higher-Order Tree-Processing Programs. In Programming Languages and Systems, Xinyu Feng and Sungwoo Park (Eds.). Springer International Publishing, Cham, 295-312.Google ScholarGoogle Scholar
  30. Microsoft Research and Inria. 2013. F*. https://www.fstar-lang.orgGoogle ScholarGoogle Scholar
  31. Robin Milner. 1978. A Theory of Type Polymorphism in Programming. J. Comput. Syst. Sci. 17, 3 ( 1978 ), 348-375. https://doi.org/10.1016/ 0022-0000 ( 78 ) 90014-4 Google ScholarGoogle ScholarCross RefCross Ref
  32. Tobias Nipkow, Lawrence C. Paulson, and Markus Wenzel. 2002. Isabelle/HOL-A Proof Assistant for Higher-Order Logic. LNCS, Vol. 2283. Springer.Google ScholarGoogle Scholar
  33. C.-H. Luke Ong. 2006. On Model-Checking Trees Generated by Higher-Order Recursion Schemes. In 21th IEEE Symposium on Logic in Computer Science (LICS 2006 ), 12-15 August 2006, Seattle, WA, USA, Proceedings. IEEE Computer Society, 81-90. https://doi.org/10.1109/LICS. 2006.38 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. C.-H. Luke Ong and Steven J. Ramsay. 2011. Verifying higher-order functional programs with pattern-matching algebraic data types. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011, Thomas Ball and Mooly Sagiv (Eds.). ACM, 587-598. https://doi.org/10.1145/ 1926385.1926453 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. John Reynolds. 1969. Automatic Computation of Data Set Definitions. Information Processing 68 ( 1969 ), 456-461.Google ScholarGoogle Scholar
  36. Simona Ronchi Della Rocca. 1988. Principal type scheme and unification for intersection type discipline. Theoretical Computer Science 59 ( 1988 ).Google ScholarGoogle Scholar
  37. Patrick Maxim Rondon, Ming Kawaguchi, and Ranjit Jhala. 2008. Liquid types. In Proceedings of the ACM SIGPLAN 2008 Conference on Programming Language Design and Implementation, Tucson, AZ, USA, June 7-13, 2008, Rajiv Gupta and Saman P. Amarasinghe (Eds.). ACM, 159-169. https://doi.org/10.1145/1375581.1375602 Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Ryosuke Sato and Naoki Kobayashi. 2017. Modular Verification of Higher-Order Functional Programs. In Programming Languages and Systems, Hongseok Yang (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 831-854.Google ScholarGoogle Scholar
  39. Niki Vazou. 2016. Liquid Haskell: Haskell as a Theorem Prover. Ph.D. Dissertation. University of California, San Diego, USA.Google ScholarGoogle Scholar
  40. Niki Vazou, Alexander Bakst, and Ranjit Jhala. 2015. Bounded refinement types. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015, Vancouver, BC, Canada, September 1-3, 2015, Kathleen Fisher and John H. Reppy (Eds.). ACM, 48-61. https://doi.org/10.1145/2784731.2784745 Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Niki Vazou, Patrick M. Rondon, and Ranjit Jhala. 2013. Abstract Refinement Types. In Programming Languages and Systems, Matthias Felleisen and Philippa Gardner (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 209-228.Google ScholarGoogle Scholar
  42. Niki Vazou, Eric L. Seidel, and Ranjit Jhala. 2014. LiquidHaskell: experience with refinement types in the real world. In Proceedings of the 2014 ACM SIGPLAN symposium on Haskell, Gothenburg, Sweden, September 4-5, 2014, Wouter Swierstra (Ed.). ACM, 39-51. https://doi.org/10.1145/2633357.2633366 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Regular language type inference with term rewriting

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!