Bag Equivalence via a Proof-Relevant Membership Relation

  • Nils Anders Danielsson
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7406)

Abstract

Two lists are bag equivalent if they are permutations of each other, i.e. if they contain the same elements, with the same multiplicity, but perhaps not in the same order. This paper describes how one can define bag equivalence as the presence of bijections between sets of membership proofs. This definition has some desirable properties:
  • Many bag equivalences can be proved using a flexible form of equational reasoning.

  • The definition generalises easily to arbitrary unary containers, including types with infinite values, such as streams.

  • By using a slight variation of the definition one gets set equivalence instead, i.e. equality up to order and multiplicity. Other variations give the subset and subbag preorders.

  • The definition works well in mechanised proofs.

Keywords

Type Theory Implicit Argument Container Type List Membership Mechanise Proof 
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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abbott, M., Altenkirch, T., Ghani, N.: Containers: Constructing strictly positive types. Theoretical Computer Science 342, 3–27 (2005)MathSciNetMATHCrossRefGoogle Scholar
  2. 2.
    Abbott, M., Altenkirch, T., Ghani, N., McBride, C.: Constructing Polymorphic Programs with Quotient Types. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 2–15. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  3. 3.
    Altenkirch, T., Levy, P., Staton, S.: Higher-Order Containers. In: Ferreira, F., Löwe, B., Mayordomo, E., Mendes Gomes, L. (eds.) CiE 2010. LNCS, vol. 6158, pp. 11–20. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  4. 4.
    Altenkirch, T., Morris, P.: Indexed containers. In: LICS 2009, pp. 277–285 (2009)Google Scholar
  5. 5.
    Contejean, E.: Modeling Permutations in Coq for Coccinelle. In: Comon-Lundh, H., Kirchner, C., Kirchner, H. (eds.) Rewriting, Computation and Proof. LNCS, vol. 4600, pp. 259–269. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  6. 6.
    Danielsson, N.A.: Total parser combinators. In: ICFP 2010, pp. 285–296 (2010)Google Scholar
  7. 7.
    Gonthier, G., Mahboubi, A., Tassi, E.: A small scale reflection extension for the Coq system. Tech. Rep. inria-00258384, version 10, INRIA (2011)Google Scholar
  8. 8.
    Hermida, C., Jacobs, B.: An Algebraic View of Structural Induction. In: Pacholski, L., Tiuryn, J. (eds.) CSL 1994. LNCS, vol. 933, pp. 412–426. Springer, Heidelberg (1995)CrossRefGoogle Scholar
  9. 9.
    Hofmann, M., Streicher, T.: The groupoid model refutes uniqueness of identity proofs. In: LICS 1994, pp. 208–212 (1994)Google Scholar
  10. 10.
    Hoogendijk, P., de Moor, O.: Container types categorically. Journal of Functional Programming 10(2), 191–225 (2000)MathSciNetMATHCrossRefGoogle Scholar
  11. 11.
    Hoogendijk, P.F.: (Relational) Programming Laws in the Boom Hierarchy of Types. In: Bird, R.S., Morgan, C.C., Woodcock, J.C.P. (eds.) MPC 1992. LNCS, vol. 669, pp. 163–190. Springer, Heidelberg (1993)CrossRefGoogle Scholar
  12. 12.
    Hoogendijk, P.F., Backhouse, R.C.: Relational programming laws in the tree, list, bag, set hierarchy. Science of Computer Programming 22(1-2), 67–105 (1994)MathSciNetMATHCrossRefGoogle Scholar
  13. 13.
    Joyal, A.: Une théorie combinatoire des séries formelles. Advances in Mathematics 42(1), 1–82 (1981)MathSciNetMATHCrossRefGoogle Scholar
  14. 14.
    Meertens, L.: Algorithmics: Towards programming as a mathematical activity. In: Mathematics and Computer Science, CWI Monographs, vol. 1, pp. 289–334. North-Holland (1986)Google Scholar
  15. 15.
    Morris, P.W.J.: Constructing Universes for Generic Programming. Ph.D. thesis, The University of Nottingham (2007)Google Scholar
  16. 16.
    Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Chalmers University of Technology and Göteborg University (2007)Google Scholar
  17. 17.
    Streicher, T.: Investigations Into Intensional Type Theory. Habilitationsschrift, Ludwig-Maximilians-Universität München (1993)Google Scholar
  18. 18.
    The Agda Team: The Agda Wiki (2012), http://wiki.portal.chalmers.se/agda/
  19. 19.
    The Coq Development Team: The Coq Proof Assistant Reference Manual, Version 8.3pl3 (2011)Google Scholar
  20. 20.
    Voevodsky, V.: Univalent foundations project - a modified version of an NSF grant application (2010) (unpublished)Google Scholar
  21. 21.
    Yorgey, B.A.: Species and functors and types, oh my! In: Haskell 2010, pp. 147–158 (2010)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Nils Anders Danielsson
    • 1
    • 2
  1. 1.Chalmers University of TechnologySweden
  2. 2.University of GothenburgSweden

Personalised recommendations