skip to main content
10.1145/1706299.1706315acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Dependent types from counterexamples

Published:17 January 2010Publication History

ABSTRACT

Motivated by recent research in abstract model checking, we present a new approach to inferring dependent types. Unlike many of the existing approaches, our approach does not rely on programmers to supply the candidate (or the correct) types for the recursive functions and instead does counterexample-guided refinement to automatically generate the set of candidate dependent types. The main idea is to extend the classical fixed-point type inference routine to return a counterexample if the program is found untypable with the current set of candidate types. Then, an interpolating theorem prover is used to validate the counterexample as a real type error or generate additional candidate dependent types to refute the spurious counterexample. The process is repeated until either a real type error is found or sufficient candidates are generated to prove the program typable. Our system makes non-trivial use of "linear" intersection types in the refinement phase.

The paper presents the type inference system and reports on the experience with a prototype implementation that infers dependent types for a subset of the Ocaml language. The implementation infers dependent types containing predicates from the quantifier-free theory of linear arithmetic and equality with uninterpreted function symbols.

References

  1. L. Augustsson. Cayenne -- a language with dependent types. In ICFP, pages 239--250, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. T. Ball, O. Kupferman, and M. Sagiv. Leaping loops in the presence of abstraction. In CAV, pages 491--503, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. T. Ball and S.K. Rajamani. The SLAM project: debugging system software via static analysis. In POPL, pages 1--3, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Bengtson, K. Bhargavan, C. Fournet, A.D. Gordon, and S. Maffeis. Refinement types for secure implementations. In CSF, pages 17--32, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Beyer, D. Zufferey, and R. Majumdar. CSIsat: Interpolation for LA EUF. In CAV, pages 304--308, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. W.-N. Chin and S.-C. Khoo. Calculating sized types. Higher-Order and Symbolic Computation, 14(2-3):261--300, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. W.-N. Chin, S.-C. Khoo, and D.N. Xu. Extending sized type with collection analysis. In PEPM, pages 75--84, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Cimatti, A. Griggio, and R. Sebastiani. Efficient interpolant generation in satisfiability modulo theories. In TACAS, pages 397--412, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. E.M. Clarke, O. Grumberg, S. Jha, Y. Lu, and H. Veith. Counterexample-guided abstraction refinement. In CAV, pages 154--169, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. J. Condit, M. Harren, Z.R. Anderson, D. Gay, and G.C. Necula. Dependent types for low-level programming. In ESOP, pages 520--535, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. W. Craig. Linear reasoning. a new form of the Herbrand-Gentzen theorem. J. Symb. Log., 22(3):250--268, 1957.Google ScholarGoogle ScholarCross RefCross Ref
  12. C. Flanagan. Hybrid type checking. In POPL, pages 245--256, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. C. Flanagan, A. Sabry, B.F. Duba, and M. Felleisen. The essence of compiling with continuations. In PLDI, pages 237--247, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. T. Freeman and F. Pfenning. Refinement types for ML. In PLDI, pages 268--277, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. T.A. Henzinger, R. Jhala, R. Majumdar, and K.L. McMillan. Abstractions from proofs. In POPL, pages 232--244, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. T.A. Henzinger, R. Jhala, R. Majumdar, and G. Sutre. Lazy abstraction. In POPL, pages 58--70, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. H. Jain, E.M. Clarke, and O. Grumberg. Efficient Craig interpolation for linear Diophantine (dis)equations and linear modular equations. In CAV, pages 254--267, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. Jhala and K.L. McMillan. Interpolant-based transition relation approximation. In CAV, pages 39--51, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. T. Johnsson. Lambda lifting: Transforming programs to recursive equations. In FPCA, pages 190--203, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. D. Kapur, R. Majumdar, and C.G. Zarba. Interpolation for data structures. In SIGSOFT FSE, pages 105--116, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. A.J. Kfoury and J.B. Wells. Principality and type inference for intersection types using expansion variables. Theor. Comput. Sci., 311(1-3):1--70, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. K. Knowles and C. Flanagan. Compositional reasoning and decidable checking for dependent contract types. In PLPV, pages 27--38, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. K.W. Knowles and C. Flanagan. Type reconstruction for general refinement types. In ESOP, pages 505--519, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. N. Kobayashi. Types and higher-order recursion schemes for verification of higher-order programs. In POPL, pages 416--428, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. D. Kroening and G. Weissenbacher. Counterexamples with loops for predicate abstraction. In CAV, pages 152--165, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. K.L. McMillan. Interpolation and SAT-based model checking. In CAV, pages 1--13, 2003.Google ScholarGoogle Scholar
  27. K.L. McMillan. An interpolating theorem prover. Theor. Comput. Sci., 345(1):101--121, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. K.L. McMillan. Lazy abstraction with interpolants. In CAV, pages 123--136, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. P.M. Neergaard and H.G. Mairson. Types, potency, and idempotency: why nonlinearity and amnesia make a type system work. In ICFP, pages 138--149, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. C.-H.L. Ong. On model-checking trees generated by higher-order recursion schemes. In LICS, pages 81--90, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. X. Ou, G. Tan, Y. Mandelbaum, and D. Walker. Dynamic typing with dependent types. In IFIP TCS, pages 437--450, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  32. W. Pugh. The Omega test: a fast and practical integer programming algorithm for dependence analysis. In SC, pages 4--13, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. P.M. Rondon, M. Kawaguchi, and R. Jhala. Liquid types. In PLDI, pages 159--169, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. R. Statman. The typed lambda-calculus is not elementary recursive. Theor. Comput. Sci., 9:73--81, 1979.Google ScholarGoogle ScholarCross RefCross Ref
  35. T. Terauchi. Dependent types from counterexamples, 2009. http://www.kb.ecei.tohoku.ac.jp/~terauchi/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. H. Unno and N. Kobayashi. Dependent type inference with interpolants. In PPDP, pages 277--288, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. J.B. Wells. The essence of principal typings. In ICALP, pages 913--925, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. H. Xi and F. Pfenning. Dependent types in practical programming. In POPL, pages 214--227, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Dependent types from counterexamples

          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
          • Published in

            cover image ACM Conferences
            POPL '10: Proceedings of the 37th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
            January 2010
            520 pages
            ISBN:9781605584799
            DOI:10.1145/1706299
            • cover image ACM SIGPLAN Notices
              ACM SIGPLAN Notices  Volume 45, Issue 1
              POPL '10
              January 2010
              500 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/1707801
              Issue’s Table of Contents

            Copyright © 2010 ACM

            Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 17 January 2010

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article

            Acceptance Rates

            Overall Acceptance Rate824of4,130submissions,20%

            Upcoming Conference

            POPL '25

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader