Advertisement

On the Implementation of Construction Functions for Non-free Concrete Data Types

  • Frédéric Blanqui
  • Thérèse Hardin
  • Pierre Weis
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4421)

Abstract

Many algorithms use concrete data types with some additional invariants. The set of values satisfying the invariants is often a set of representatives for the equivalence classes of some equational theory. For instance, a sorted list is a particular representative wrt commutativity. Theories like associativity, neutral element, idempotence, etc. are also very common. Now, when one wants to combine various invariants, it may be difficult to find the suitable representatives and to efficiently implement the invariants. The preservation of invariants throughout the whole program is even more difficult and error prone. Classically, the programmer solves this problem using a combination of two techniques: the definition of appropriate construction functions for the representatives and the consistent usage of these functions ensured via compiler verifications. The common way of ensuring consistency is to use an abstract data type for the representatives; unfortunately, pattern matching on representatives is lost. A more appealing alternative is to define a concrete data type with private constructors so that both compiler verification and pattern matching on representatives are granted. In this paper, we detail the notion of private data type and study the existence of construction functions. We also describe a prototype, called Moca, that addresses the entire problem of defining concrete data types with invariants: it generates efficient construction functions for the combination of common invariants and builds representatives that belong to a concrete data type with private constructors.

Keywords

Normal Form Data Type Pattern Match Construction Function Equational Theory 
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.

References

  1. 1.
    Benanav, D., Kapur, D., Narendran, P.: Complexity of matching problems. J. of Symbolic Computation 3(1-2), 203–216 (1987)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Bendix, P., Knuth, D.: Simple word problems in universal algebra. In: Leech, J. (ed.) Computational problems in abstract algebra, Pergamon Press, Oxford (1970)Google Scholar
  3. 3.
    Burton, F., Cameron, R.: Pattern matching with abstract data types. J. of Functional Programming 3(2), 171–190 (1993)MathSciNetCrossRefGoogle Scholar
  4. 4.
    Burton, W., et al.: Views: An extension to Haskell pattern matching (1996), http://www.haskell.org/extensions/views.html
  5. 5.
    Le Chenadec, P.: Canonical forms in finitely presented algebras. Research notes in theoretical computer science. Pitman, London (1986)zbMATHGoogle Scholar
  6. 6.
    Contejean, E., et al.: CiME version 2.02. LRI, CNRS UMR 8623, Université Paris-Sud, France (2004), http://cime.lri.fr/
  7. 7.
    Coq Development Team: The Coq Proof Assistant Reference Manual, Version 8.0. INRIA, France (2006), http://coq.inria.fr/
  8. 8.
    Dershowitz, N., Jouannaud, J.-P.: Rewrite systems. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, vol. B, North-Holland, Amsterdam (1990)Google Scholar
  9. 9.
    Doligez, D.: Zenon, version 0.4.1 (2006), http://focal.inria.fr/zenon/
  10. 10.
    Doligez, D., et al.: The Objective Caml system release 3.09, Documentation and user’s manual. INRIA, France (2005), http://caml.inria.fr/
  11. 11.
    Jones, S.P.: Haskell 98 Language and Libraries, The revised report. Cambridge University Press, Cambridge (2003)Google Scholar
  12. 12.
    Gaillourdet, J.-M., et al.: The new Waldmeister loop at work. In: Baader, F. (ed.) CADE 2003. LNCS (LNAI), vol. 2741, Springer, Heidelberg (2003)Google Scholar
  13. 13.
    Hullot, J.-M.: Compilation de formes canoniques dans les théories équationnelles. PhD thesis, Université Paris 11, France (1980)Google Scholar
  14. 14.
    Jouannaud, J.-P.: Modular church-rosser modulo. In: Pfenning, F. (ed.) RTA 2006. LNCS, vol. 4098, Springer, Heidelberg (2006)Google Scholar
  15. 15.
    Moreau, P.-E., et al.: Tom Manual version 2.3. INRIA & LORIA, Nancy, France (2006), http://tom.loria.fr/
  16. 16.
    Moreau, P.-E., Ringeissen, C., Vittek, M.: A pattern matching compiler for multiple target languages. In: Hedin, G. (ed.) CC 2003 and ETAPS 2003. LNCS, vol. 2622, Springer, Heidelberg (2003)Google Scholar
  17. 17.
    Okasaki, C.: Views for standard ML. In: Proc. of ML’98 (1998)Google Scholar
  18. 18.
    Peterson, G., Stickel, M.: Complete sets of reductions for some equational theories. J. of the ACM 28(2), 233–264 (1981)zbMATHCrossRefMathSciNetGoogle Scholar
  19. 19.
    Rao, K.: Completeness of hierarchical combinations of term rewriting systems. In: Shyamasundar, R.K. (ed.) Foundations of Software Technology and Theoretical Computer Science. LNCS, vol. 761, Springer, Heidelberg (1993)Google Scholar
  20. 20.
    Rioboo, R., Doligez, D., Hardin, T.: all. FoCal Reference Manual, version 0.3.1. Université Paris 6, CNAM & INRIA (2005), http://focal.inria.fr/
  21. 21.
    Thompson, S.: Laws in Miranda. In: Proc. of LFP’86 (1986)Google Scholar
  22. 22.
    Thompson, S.: Lawful functions and program verification in Miranda. Science of Computer Programming 13(2-3), 181–218 (1990)CrossRefMathSciNetzbMATHGoogle Scholar
  23. 23.
    Wadler, P.: Views: a way for pattern matching to cohabit with data abstraction. In: Proc. of POPL’87 (1987)Google Scholar
  24. 24.
    Weis, P.: Private constructors in OCaml (2003), http://alan.petitepomme.net/cwn/2003.07.01.html#5

Copyright information

© Springer Berlin Heidelberg 2007

Authors and Affiliations

  • Frédéric Blanqui
    • 1
  • Thérèse Hardin
    • 2
  • Pierre Weis
    • 3
  1. 1.INRIA & LORIA, BP 239, 54506 Villers-lès-Nancy CedexFrance
  2. 2.UPMC, LIP6, 104, Av. du Pr. Kennedy, 75016 ParisFrance
  3. 3.INRIA, Domaine de Voluceau, BP 105, 78153 Le Chesnay CedexFrance

Personalised recommendations