When Is a Type Refinement an Inductive Type?

  • Robert Atkey
  • Patricia Johann
  • Neil Ghani
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6604)


Dependently typed programming languages allow sophisticated properties of data to be expressed within the type system. Of particular use in dependently typed programming are indexed types that refine data by computationally useful information. For example, the ℕ-indexed type of vectors refines lists by their lengths. Other data types may be refined in similar ways, but programmers must produce purpose-specific refinements on an ad hoc basis, developers must anticipate which refinements to include in libraries, and implementations often store redundant information about data and their refinements. This paper shows how to generically derive inductive characterisations of refinements of inductive types, and argues that these characterisations can alleviate some of the aforementioned difficulties associated with ad hoc refinements. These characterisations also ensure that standard techniques for programming with and reasoning about inductive types are applicable to refinements, and that refinements can themselves be further refined.


  1. 1.
    Abbott, M., Altenkirch, T., Ghani, N.: Containers - constructing strictly positive types. Theoretical Computer Science 342, 3–27 (2005)MathSciNetCrossRefGoogle Scholar
  2. 2.
    Altenkirch, T., McBride, C., Morris, P.: Generic Programming with Dependent Types. In: Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.) SSDGP 2006. LNCS, vol. 4719, pp. 209–257. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  3. 3.
    Backhouse, R., Gibbons, J., Hinze, R., Jeuring, J. (eds.): SSDGP 2006. LNCS, vol. 4719. Springer, Heidelberg (2007)zbMATHGoogle Scholar
  4. 4.
    Barr, M., Wells, C.: Toposes, Triples and Theories. Springer, Heidelberg (1983)zbMATHGoogle Scholar
  5. 5.
    Benke, M., Dybjer, P., Jansson, P.: Universes for generic programs and proofs in dependent type theory. Nordic Journal of Computing 10(4), 265–289 (2003)MathSciNetzbMATHGoogle Scholar
  6. 6.
    Bird, R.S., de Moor, O.: Algebra of Programming. Prentice Hall, Englewood Cliffs (1997)zbMATHGoogle Scholar
  7. 7.
    Brady, E., McBride, C., McKinna, J.: Inductive Families Need Not Store Their Indices. In: Berardi, S., Coppo, M., Damiani, F. (eds.) TYPES 2003. LNCS, vol. 3085, pp. 115–129. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  8. 8.
    Carboni, A., Lack, S., Walters, R.F.C.: Introduction to extensive and distributive categories. Journal of Pure and Applied Algebra 84, 145–158 (1993)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Chapman, J., Dagand, P.-E., McBride, C., Morris, P.: The gentle art of levitation. In: Proc. ICFP, pp. 3–14 (2010)Google Scholar
  10. 10.
    Chuang, T.-R., Lin, J.-L.: An algebra of dependent data types. Technical Report TR-IIS-06-012, Institute of Information Science, Academia Sinica, Taiwan (2006)Google Scholar
  11. 11.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 2nd edn. MIT Press and McGraw-Hill (2001)Google Scholar
  12. 12.
    Davies, R.: Practical Refinement-Type Checking. PhD thesis, Carnegie Mellon University, available as Technical Report CMU-CS-05-110 (2005)Google Scholar
  13. 13.
    Denney, E.: Refinement types for specification. In: Proc. PROCOMET, pp. 148–166. Chapman and Hall, Boca Raton (1998)Google Scholar
  14. 14.
    Dunfield, J.: A Unified System of Type Refinements. PhD thesis, Carnegie Mellon University, available as Technical Report CMU-CS-07-129 (2007)Google Scholar
  15. 15.
    Freeman, T., Pfenning, F.: Refinement types for ML. In: Proc. Symposium on Programming Language Design and Implementation, pp. 268–277 (June 1991)Google Scholar
  16. 16.
    Ghani, N., Johann, P., Fumex, C.: Fibrational Induction Rules for Initial Algebras. In: Dawar, A., Veith, H. (eds.) CSL 2010. LNCS, vol. 6247, pp. 336–350. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  17. 17.
    Gordon, A.D., Fournet, C.: Principles and applications of refinement types. Technical Report MSR-TR-2009-147, Microsoft Research (October 2009)Google Scholar
  18. 18.
    Hermida, C., Jacobs, B.: Structural induction and coinduction in a fibrational setting. Information and Computation 145(2), 107–152 (1998)MathSciNetCrossRefGoogle Scholar
  19. 19.
    Jacobs, B.: Comprehension categories and the semantics of type dependency. Theoretical Computer Science 107, 169–207 (1993)MathSciNetCrossRefGoogle Scholar
  20. 20.
    Jacobs, B.: Categorical Logic and Type Theory. Studies in Logic and the Foundations of Mathematics, vol. 141. North Holland, Amsterdam (1999)zbMATHGoogle Scholar
  21. 21.
    Kawaguchi, M., Rondon, P.M., Jhala, R.: Type-based data structure verification. In: PLDI, pp. 304–315 (2009)Google Scholar
  22. 22.
    Lovas, W., Pfenning, F.: Refinement types for logical frameworks and their interpretation as proof irrelevance. Log. Meth, in Comp. Sci. (2010) (to appear) Google Scholar
  23. 23.
    McBride, C.: Ornamental algebras, algebraic ornaments (2010) (unpublished note)Google Scholar
  24. 24.
    Pfenning, F.: Refinement types for logical frameworks. In: Barendregt, H., Nipkow, T. (eds.) TYPES 1993. LNCS, vol. 806, pp. 285–299. Springer, Heidelberg (1994)Google Scholar
  25. 25.
    Rushby, J., Owre, S., Shankar, N.: Subtypes for specifications: Predicate subtyping in pvs. IEEE Transactions on Software Engineering 24(9), 709–720 (1998)CrossRefGoogle Scholar
  26. 26.
  27. 27.
    Xi, H.: Dependently typed data structures. Revision after WAAAPL 1999 (2000)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Robert Atkey
    • 1
  • Patricia Johann
    • 1
  • Neil Ghani
    • 1
  1. 1.University of StrathclydeUK

Personalised recommendations