Descriptor-Free Representation of Arrays with Dependent Types

  • Kai Trojahner
  • Clemens Grelck
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5836)


Besides element type and values, a multidimensional array is characterized by the number of axes (rank) and their respective lengths (shape vector). Both properties are essential for bounds checking and to compute linear offsets into heap memory at run time. In order to have an array’s rank and shape available at any time during program execution, both are typically kept in an array descriptor that is maintained at run time in addition to the array itself.

In this paper, we propose a different approach: we treat array rank and shape as first-class citizens themselves. Firstly, we use dependent types to reflect structural properties of arrays in the type system. Secondly, we annotate a program with the explicit array properties wherever necessary. This choice not only renders implicit run time array descriptors obsolete, but exposing all rank and shape computations explicitly in intermediate code also allows us to perform extensive compile time optimisation on them. We have implemented the proposed approach in our experimental array language Qube; preliminary experimental results indicate the suitability of the proposed approach.


Dependent Type Index Vector Type Check Shape Vector Array Property 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Falkoff, A., Iverson, K.: The Design of APL. IBM Journal of Research and Development 17(4), 324–334 (1973)CrossRefzbMATHGoogle Scholar
  2. 2.
    Moler, C., Little, J., Bangert, S.: Pro-Matlab User’s Guide. The MathWorks, Cochituate Place, 24 Prime Park Way, Natick, MA, USA (1987)Google Scholar
  3. 3.
    Scholz, S.B.: Single Assignment C — Efficient Support for High-Level Array Operations in a Functional Setting. Journal of Functional Programming 13(6), 1005–1059 (2003)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Grelck, C.: Shared Memory Multiprocessor Support for Functional Array Processing in SAC. Journal of Functional Programming 15(3), 353–401 (2005)CrossRefzbMATHGoogle Scholar
  5. 5.
    Trojahner, K., Grelck, C.: Dependently Typed Array Programs Don’t Go Wrong. Technical Report A-08-06, Schriftenreihe der Institute für Informatik/Mathematik University of Lübeck, Lübeck, Germany (2008)Google Scholar
  6. 6.
    Grelck, C., Scholz, S.B.: SAC: A Functional Array Language for Efficient Multithreaded Execution. International Journal of Parallel Programming 34(4), 383–427 (2006)CrossRefzbMATHGoogle Scholar
  7. 7.
    Barthe, G., Coquand, T.: An introduction to dependent type theory. In: Barthe, G., Dybjer, P., Pinto, L., Saraiva, J. (eds.) APPSEM 2000. LNCS, vol. 2395, pp. 1–41. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  8. 8.
    Zenger, C.: Indexed Types. Theorectical Computer Science 187(1-2), 147–165 (1997)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Xi, H., Pfenning, F.: Eliminating array bound checking through dependent types. In: Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, Montreal, pp. 249–257 (1998)Google Scholar
  10. 10.
    Boehm, H., Demers, A., Shenker, S.: Mostly parallel garbage collection. In: Proceedings of the ACM SIGPLAN 1991 Conference on Programming Languages Design and Implementation. ACM SIGPLAN Notices, vol. 26, pp. 157–164. ACM, New York (1991)CrossRefGoogle Scholar
  11. 11.
    Grelck, C., Trojahner, K.: Implicit Memory Management for SAC. In: Grelck, C., Huch, F. (eds.) Proceedings of the 16th International Workshop on Implementation and Application of Functional Languages, IFL, Lübeck, Germany, September 8-10. Technical Report, vol. 0408, pp. 335–348. University of Kiel (2004)Google Scholar
  12. 12.
    Bernecky, R., Herhut, S., Scholz, S.-B., Trojahner, K., Grelck, C., Shafarenko, A.: Index Vector Elimination – Making Index Vectors Affordable. In: Horváth, Z., Zsók, V., Butterfield, A. (eds.) IFL 2006. LNCS, vol. 4449, pp. 19–36. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  13. 13.
    Iverson, K.: A Programming Language. John Wiley, New York City (1962)CrossRefzbMATHGoogle Scholar
  14. 14.
    Iverson, K.: J. Introduction and Dictionary. Iverson Software Inc., Toronto (1995)Google Scholar
  15. 15.
    Jenkins, M.: Q’Nial: A Portable Interpreter for the Nested Interactive Array Language Nial. Software Practice and Experience 19(2), 111–126 (1989)CrossRefGoogle Scholar
  16. 16.
    Jay, C.B., Steckler, P.A.: The Functional Imperative: Shape! In: Hankin, C. (ed.) ESOP 1998. LNCS, vol. 1381, pp. 139–153. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  17. 17.
    Kreye, D.: A Compilation Scheme for a Hierarchy of Array Types. In: Arts, T., Mohnen, M. (eds.) IFL 2002. LNCS, vol. 2312, pp. 18–35. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  18. 18.
    Grelck, C., Scholz, S.-B., Shafarenko, A.: A Binding Scope Analysis for Generic Programs on Arrays. In: Butterfield, A., Grelck, C., Huch, F. (eds.) IFL 2005. LNCS, vol. 4015, pp. 212–230. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  19. 19.
    Trojahner, K., Grelck, C., Scholz, S.-B.: On optimising shape-generic array programs using symbolic structural information. In: Horváth, Z., Zsók, V., Butterfield, A. (eds.) IFL 2006. LNCS, vol. 4449, pp. 1–18. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  20. 20.
    Xi, H.: Applied Type System (extended abstract). In: Berardi, S., Coppo, M., Damiani, F. (eds.) TYPES 2003. LNCS, vol. 3085, pp. 394–408. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  21. 21.
    Norell, U.: Towards a practical programming language based on dependent type theory. PhD thesis. PhD thesis, Chalmers University of Technology, Göteborg, Sweden (2007)Google Scholar
  22. 22.
    McBride, C.: Epigram: Practical programming with dependent types. In: Advanced Functional Programming, pp. 130–170 (2004)Google Scholar
  23. 23.
    Nanevski, A., Morrisett, G., Birkedal, L.: Polymorphism and Separation in Hoare Type Theory. In: International Conference on Functional Programming, pp. 62–73. ACM Press, New York (2006)Google Scholar
  24. 24.
    Swierstra, W., Altenkirch, T.: Dependent types for distributed arrays. In: Achten, P., Koopman, P., Morazán, M. (eds.) Trends in Functional Programming, vol. 9. Intellect Books (2008)Google Scholar
  25. 25.
    Brady, E.: Practical Implementation of a Dependently Typed Functional Programming Language. PhD thesis, Department of Computer Science, University of Durham, Durham, UK (2005)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Kai Trojahner
    • 1
  • Clemens Grelck
    • 2
    • 3
  1. 1.Institute of Software Technology and Programming LanguagesUniversity of LübeckGermany
  2. 2.Institute of InformaticsUniversity of AmsterdamNetherlands
  3. 3.School of Computer ScienceUniversity of HertfordshireUnited Kingdom

Personalised recommendations