Bag Equivalence via a Proof-Relevant Membership Relation

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.

[1]  Fernando Ferreira,et al.  Programs, Proofs, Processes , 2012, Theory of Computing Systems.

[2]  Hubert Comon-Lundh,et al.  Rewriting, Computation and Proof, Essays Dedicated to Jean-Pierre Jouannaud on the Occasion of His 60th Birthday , 2007, Rewriting, Computation and Proof.

[3]  Paul F. Hoogendijk,et al.  Container types categorically , 2000, Journal of Functional Programming.

[4]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[5]  Enrico Tassi,et al.  A Small Scale Reflection Extension for the Coq system , 2008 .

[6]  Thorsten Altenkirch,et al.  Containers: Constructing strictly positive types , 2005, Theor. Comput. Sci..

[7]  Paul F. Hoogendijk (Relational) Programming Laws in the Boom Hierarchy of Types , 1992, MPC.

[8]  A. Joyal Une théorie combinatoire des séries formelles , 1981 .

[9]  Roland Carl Backhouse,et al.  Relational Programming Laws in the Tree, List, Bag, Set Hierarchy , 1994, Sci. Comput. Program..

[10]  Peter Morris,et al.  Indexed Containers , 2009, 2009 24th Annual IEEE Symposium on Logic In Computer Science.

[11]  Brent A. Yorgey Species and functors and types, oh my! , 2010, Haskell '10.

[12]  Thorsten Altenkirch,et al.  Constructing Polymorphic Programs with Quotient Types , 2004, MPC.

[13]  Thorsten Altenkirch,et al.  Higher-Order Containers , 2010, CiE.

[14]  Bart Jacobs,et al.  An Algebraic View of Structural Induction , 1994, CSL.

[15]  Martin Hofmann,et al.  The groupoid model refutes uniqueness of identity proofs , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[16]  Hugo Herbelin,et al.  The Coq proof assistant : reference manual, version 6.1 , 1997 .

[17]  Vladimir Voevodsky,et al.  Univalent Foundations of Mathematics , 2011, WoLLIC.

[18]  Nils Anders Danielsson Total parser combinators , 2010, ICFP '10.

[19]  Peter W. J. Morris,et al.  Constructing Universes for Generic Programming , 2007 .

[20]  Alex K. Simpson,et al.  Computational Adequacy in an Elementary Topos , 1998, CSL.

[21]  Lambert Meertens,et al.  Algorithmics : towards programming as a mathematical activity , 1986 .

[22]  Vladimir Voevodsky Univalent Foundations Project ( a modified version of an NSF grant application ) , 2010 .

[23]  Brent A. Yorgey Species and functors and types, oh my! , 2010 .