In mathematics, a **multiset** (aka **bag** or **mset**) is a modification of the concept of a set that, unlike a set, allows for multiple instances for each of its elements. The positive integer number of instances, given for each element is called the **multiplicity** of this element in the multiset. As a consequence, an infinite number of multisets exist, which contain only elements *a* and *b*, but vary by the multiplicity of their elements:

- The set {
*a*,*b*} contains only elements*a*and*b*, each having multiplicity 1, when {*a*,*b*} is seen as a multiset. - In multiset {
*a*,*a*,*b*}, the element*a*has multiplicity 2, and*b*has multiplicity 1. - In multiset {
*a*,*a*,*a*,*b*,*b*,*b*},*a*and*b*both have multiplicity 3.

These objects are all different, when viewed as multisets, although they are the same set, since they all consist of the same elements. As with sets, and in contrast to tuples, order does not matter in discriminating multisets, so {*a*, *a*, *b*} and {*a*, *b*, *a*} denote the same multiset. To distinguish between sets and multisets, a notation that incorporates square brackets is sometimes used: the multiset {a, a, b} can be denoted as [a, a, b].^{[1]}

The cardinality of a multiset is constructed by summing up the multiplicities of all its elements. For example, in the multiset {*a*, *a*, *b*, *b*, *b*, *c*} the multiplicities of the members *a*, *b*, and *c* are respectively 2, 3, and 1, and therefore the cardinality of this multiset is 6.

Nicolaas Govert de Bruijn coined the word *multiset* in the 1970s, according to Donald Knuth.^{[2]}^{:694}
However, the use of the concept for multisets predates the coinage of word *multiset* by many centuries. Knuth himself attributes the first study of multisets to the Indian mathematician Bhāskarāchārya, who described permutations of multisets around 1150. Knuth also lists other names that were proposed or used for this concept, including *list*, *bunch*, *bag*, *heap*, *sample*, *weighted set*, *collection*, and *suite*.^{[2]}^{:694}

## Contents

## History

Wayne Blizard traced multisets back to the very origin of numbers, arguing that “in ancient times, the number *n* was often represented by a collection of *n* strokes, tally marks, or units.”^{[3]} These and similar collections of objects are multisets, because strokes, tally marks, or units are considered indistinguishable. This shows that people implicitly used multisets even before mathematics emerged.

Practical needs for this structure have caused multisets to be rediscovered several times, appearing in literature under different names.^{[4]}^{:323} For instance, they were important in early AI languages, such as QA4, where they were referred to as *bags,* a term attributed to Peter Deutsch.^{[5]} A multiset has been also called an aggregate, heap, bunch, sample, weighted set, occurrence set, and fireset (finitely repeated element set).^{[4]}^{:320}^{[6]}

Although multisets were used implicitly from ancient times, their explicit exploration happened much later. The first known study of multisets is attributed to the Indian mathematician Bhāskarāchārya circa 1150, who described permutations of multisets.^{[2]}^{:694} The work of Marius Nizolius (1498–1576) contains another early reference to the concept of multisets.^{[7]} Athanasius Kircher found the number of multiset permutations when one element can be repeated.^{[8]} Jean Prestet published a general rule for multiset permutations in 1675.^{[9]} John Wallis explained this rule in more detail in 1685.^{[10]}

Multisets appeared explicitly in the work of Richard Dedekind.^{[11]}^{:114}^{[12]}

Other mathematicians formalized multisets and began to study them as precise mathematical structures in the 20th century. For example, Whitney (1933) described *generalized sets* ("sets" whose characteristic functions may take any integer value - positive, negative or zero).^{[4]}^{:326}^{[13]}^{:405} Monro (1987) investigated the category **Mul** of multisets and their morphisms, defining a *multiset* as a set with an equivalence relation between elements "of the same *sort*", and a *morphism* between multisets as a function which respects *sorts*. He also introduced a *multinumber*: a function *f(x)* from a multiset to the natural numbers, giving the *multiplicity* of element *x* in the multiset. Monro argued that the concepts of multiset and multinumber are often mixed indiscriminately, though both are useful.^{[4]}^{:327-328}^{[14]}

## Examples

One of the simplest and most natural examples is the multiset of prime factors of a number *n*. Here the underlying set of elements is the set of prime divisors of *n*. For example, the number 120 has the prime factorization

which gives the multiset {2, 2, 2, 3, 5}.

A related example is the multiset of solutions of an algebraic equation. A quadratic equation, for example, has two solutions. However, in some cases they are both the same number. Thus the multiset of solutions of the equation could be {3, 5}, or it could be {4, 4}. In the latter case it has a solution of multiplicity 2. More generally, the fundamental theorem of algebra asserts that the complex solutions of a polynomial equation of degree d always form a multiset of cardinality d.

A special case of the above are the eigenvalues of a matrix, if these are defined as the multiset of roots of its characteristic polynomial. However a choice is made here: the (usual) definition of eigenvalues does not refer to the characteristic polynomial, and this give rise to another notion of multiplicity, and therefore to another multiset. The geometric multiplicity of an eigenvalue *λ* of a matrix *A* is the dimension of the kernel of *A* – *λI*; the geometric multiplicity of an eigenvalue is not larger and often smaller than its *algebraic multiplicity*, which is the multiplicity as a root of the characteristic polynomial. The geometric multiplicity of an eigenvalue is its multiplicity as a root of the minimal polynomial of *A*. Therefore, the multiset of eigenvalues with geometric multiplicities is the multiset of roots of the minimal polynomial.

## Definition

A **multiset** may be formally defined as a 2-tuple (*A*, *m*) where *A* is the *underlying set* of the multiset, formed from its distinct elements, and is a function from *A* to the set of the positive integers, giving the *multiplicity*, that is, the number of occurrences, of the element *a* in the multiset as the number *m*(*a*).

Representing the function *m* by its graph, that is the set of ordered pairs allows for writing the multiset {*a*, *a*, *b*} as ({*a*, *b*}, {(*a*, 2), (*b*, 1)}), and the multiset {*a*, *b*} as ({*a*, *b*}, {(*a*, 1), (*b*, 1)}). This notation is however not commonly used and more compact notations are employed.

If is a finite set, the multiset (*A*, *m*) is often represented as

- sometimes simplified to

where upper indices equal to 1 are omitted. For example, the multiset {*a*, *a*, *b*} may be written or If the elements of the multiset are numbers, a confusion is possible with ordinary arithmetic operations, those normally can be excluded from the context. On the other hand, the latter notation is coherent with the fact that the prime factorization of a positive integer is a uniquely defined multiset, as asserted by the fundamental theorem of arithmetic. Also, a monomial is a multiset of indeterminates.^{[further explanation needed]}

A multiset corresponds to an ordinary set if the multiplicity of every element is one (as opposed to some larger natural number). An indexed family, (*a*_{i})_{i∈I}, where *i* varies over some index-set *I*, may define a multiset, sometimes written {*a*_{i}}. In this view the underlying set of the multiset is given by the image of the family, and the multiplicity of any element *x* is the number of index values *i* such that . In this article the multiplicities are considered to be finite, i.e. no element occurs infinitely many times in the family: even in an infinite multiset, the multiplicities are finite numbers.

It is possible to extend the definition of a multiset by allowing multiplicities of individual elements to be infinite cardinals instead of natural numbers, but not all properties carry over to this generalization.

## Basic properties and operations

Elements of a multiset are generally taken in a fixed set U, sometimes called a *universe*, which is typically the set of natural numbers. An element of U that does not belong to a given multiset is said to have a multiplicity 0 in this multiset. This extends the multiplicity function of the multiset to a function from U to the set of nonnegative integers. This defines a one to one correspondence between these functions and the multisets that have their elements in U.

This extended multiplicity function is commonly called simply the **multiplicity function**, and suffices for defining multisets, when the universe containing the elements has been fixed. This multiplicity function is a generalization of the indicator function of a subset, and shares some properties with it.

The **support** of a multiset in a universe U is the underlying set of the multiset. Using the multiplicity function , it is characterized as

- .

A multiset is *finite* if its support is finite, or, equivalently, if its cardinality

is finite. The *empty multiset* is the unique multiset with an empty support (underlying set), and thus a cardinality 0.

The usual operations of sets may be extended to multisets by using the multiplicity function, in a similar way as using the indicator function for subsets. In the following, A and B are multisets in a given universe U, with multiplicity functions and

**Inclusion:**A is included in B, denoted*A*⊆*B*, if

**Intersection:**the*intersection*(called, in some contexts, the*infimum*or*greatest common divisor*) of A and B is the multiset C with multiplicity function

**Union:**the*union*(called, in some contexts, the*maximum*or*lowest common multiple*) of A and B is the multiset C with multiplicity function

^{[citation needed]}

**Sum:**the sum of multisets may be viewed as a generalization of the disjoint union of sets, and is defined by

- The sum defines a commutative monoid structure on the finite multisets in a given universe. This monoid is a free commutative monoid, with the universe as a basis.

Two multisets are *disjoint* if their supports are disjoint sets. This is equivalent to saying that their intersection is the empty multiset or that their sum equals their union.

## Counting multisets

The number of multisets of cardinality *k*, with elements taken from a finite set of cardinality *n*, is called the **multiset coefficient** or **multiset number**. This number is written by some authors as , a notation that is meant to resemble that of binomial coefficients; it is used for instance in (Stanley, 1997), and could be pronounced "*n* multichoose *k*" to resemble "*n* choose *k*" for . Unlike for binomial coefficients, there is no "multiset theorem" in which multiset coefficients would occur, and they should not be confused with the unrelated multinomial coefficients that occur in the multinomial theorem.

The value of multiset coefficients can be given explicitly as

where the second expression is as a binomial coefficient; many authors in fact avoid separate notation and just write binomial coefficients. So, the number of such multisets is the same as the number of subsets of cardinality *k* in a set of cardinality *n* + *k* − 1. The analogy with binomial coefficients can be stressed by writing the numerator in the above expression as a rising factorial power

to match the expression of binomial coefficients using a falling factorial power:

There are for example 4 **multisets** of cardinality 3 with elements taken from the set {1, 2} of cardinality 2 (*n* = 2, *k* = 3), namely {1, 1, 1}, {1, 1, 2}, {1, 2, 2}, {2, 2, 2}. There are also 4 **subsets** of cardinality 3 in the set {1, 2, 3, 4} of cardinality 4 (*n* + *k* − 1), namely {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}.

One simple way to prove the equality of multiset coefficients and binomial coefficients given above, involves representing multisets in the following way. First, consider the notation for multisets that would represent {*a*, *a*, *a*, *a*, *a*, *a*, *b*, *b*, *c*, *c*, *c*, *d*, *d*, *d*, *d*, *d*, *d*, *d*} (6 *a*s, 2 *b*s, 3 *c*s, 7 *d*s) in this form:

- • • • • • • | • • | • • • | • • ��� • • • •

This is a multiset of cardinality *k* = 18 made of elements of a set of cardinality *n* = 4. The number of characters including both dots and vertical lines used in this notation is 18 + 4 − 1. The number of vertical lines is 4 − 1. The number of multisets of cardinality 18 is then the number of ways to arrange the 4 − 1 vertical lines among the 18 + 4 − 1 characters, and is thus the number of subsets of cardinality 4 − 1 in a set of cardinality 18 + 4 − 1. Equivalently, it is the number of ways to arrange the 18 dots among the 18 + 4 − 1 characters, which is the number of subsets of cardinality 18 of a set of cardinality 18 + 4 − 1. This is

thus is the value of the multiset coefficient and its equivalencies:

One may define a generalized binomial coefficient

in which *n* is not required to be a nonnegative integer, but may be negative or a non-integer, or a non-real complex number. (If *k* = 0, then the value of this coefficient is 1 because it is the empty product.) Then the number of multisets of cardinality *k* in a set of cardinality *n* is

### Recurrence relation

A recurrence relation for multiset coefficients may be given as

with

The above recurrence may be interpreted as follows.
Let [*n*] := be the source set. There is always exactly one (empty) multiset of size 0, and if *n* = 0 there are no larger multisets, which gives the initial conditions.

Now, consider the case in which *n*,*k* > 0. A multiset of cardinality *k* with elements from [*n*] might or might not contain any instance of the final element *n*. If it does appear, then by removing *n* once, one is left with a multiset of cardinality *k* − 1 of elements from [*n*], and every such multiset can arise, which gives a total of

- possibilities.

If *n* does not appear, then our original multiset is equal to a multiset of cardinality *k* with elements from [*n* − 1], of which there are

Thus,

### Generating series

The generating function of the multiset coefficients is very simple, being

As multisets are in one to one correspondence with monomials, is also the number of monomials of degree d in n indeterminates. Thus, above series is also the Hilbert series of the polynomial ring

As is a polynomial in n, it is defined for any complex value of n.

### Generalization and connection to the negative binomial series

The multiplicative formula allows the definition of multiset coefficients to be extended by replacing *n* by an arbitrary number *α* (negative, real, complex):

With this definition one has a generalization of the negative binomial formula (with one of the variables set to 1), which justifies calling the negative binomial coefficients:

This Taylor series formula is valid for all complex numbers *α* and *X* with |*X*| < 1. It can also be interpreted as an identity of formal power series in *X*, where it actually can serve as definition of arbitrary powers of series with constant coefficient equal to 1; the point is that with this definition all identities hold that one expects for exponentiation, notably

- ,

and formulas such as these can be used to prove identities for the multiset coefficients.

If *α* is a nonpositive integer *n*, then all terms with *k* > −*n* are zero, and the infinite series becomes a finite sum. However, for other values of *α*, including positive integers and rational numbers, the series is infinite.

## Applications

Multisets have various applications.^{[6]} They are becoming fundamental in combinatorics.^{[15]}^{[16]}^{[17]}^{[18]} Multisets have become an important tool in database theory, which often uses the synonym *bag*.^{[19]}^{[20]}^{[21]} For instance, multisets are often used to implement relations in database systems. Multisets also play an important role in computer science.^{[2]}

There are also other applications. For instance, Richard Rado used multisets as a device to investigate the properties of families of sets. He wrote, "The notion of a set takes no account of multiple occurrence of any one of its members, and yet it is just this kind of information which is frequently of importance. We need only think of the set of roots of a polynomial f(x) or the spectrum of a linear operator."^{[4]}^{:328-329}

## Generalizations

Different generalizations of multisets have been introduced, studied and applied to solving problems.

- Real-valued multisets (in which multiplicity of an element can be any real number)
^{[22]}^{[23]}

- This seems straightforward, as many definitions for fuzzy sets and multisets are very similar and can be taken over for real-valued multisets by just replacing the value range of the characteristic function ([0, 1] or ℕ
_{0}= {0, 1, 2, 3, ...} respectively) by ℝ_{0}^{+}= [0, ∞[. However, this approach cannot be easily extended for generalized fuzzy sets which use a poset or lattice instead of a simple degree of membership. Several other approaches for fuzzy multisets have been developed that don't have this restriction.

- Fuzzy multisets
^{[24]} - Rough multisets
^{[25]} - Hybrid sets
^{[26]} - Multisets whose multiplicity is any real-valued step function
^{[27]} - Soft multisets
^{[28]} - Soft fuzzy multisets
^{[29]} - Named sets (unification of all generalizations of sets)
^{[30]}^{[31]}^{[32]}^{[33]}

## See also

- Frequency (statistics) as multiplicity analog
- Quasi-sets
- Set theory
- Partitions of multisets

## References

**^**Hein, James L. (2003).*Discrete mathematics*. Jones & Bartlett Publishers. pp. 29–30. ISBN 0-7637-2210-3.- ^
^{a}^{b}^{c}^{d}Knuth, Donald E. (1998).*Seminumerical Algorithms*. The Art of Computer Programming.**2**(3rd ed.). Addison Wesley. ISBN 0-201-89684-2. **^**Blizard, Wayne D (1989). "Multiset theory".*Notre Dame Journal of Formal Logic*.**30**(1): 36–66. doi:10.1305/ndjfl/1093634995.- ^
^{a}^{b}^{c}^{d}^{e}Blizard, Wayne D. (1991). "The Development of Multiset Theory".*Modern Logic*.**1**(4): 319–352. **^**Rulifson, J. F.; Derkson, J. A.; Waldinger, R. J. (November 1972).*QA4: A Procedural Calculus for Intuitive Reasoning*(Technical report). SRI International. 73.- ^
^{a}^{b}Singh, D.; Ibrahim, A. M.; Yohanna, T.; Singh, J. N. (2007). "An overview of the applications of multisets".*Novi Sad Journal of Mathematics*.**37**(2): 73–92. **^**Angelelli, I. (1965). "Leibniz's misunderstanding of Nizolius' notion of 'multitudo'".*Notre Dame Journal of Formal Logic*(6): 319–322.**^**Kircher, Athanasius (1650).*Musurgia Universalis*. Rome: Corbelletti.**^**Prestet, Jean (1675).*Elemens des Mathematiques*. Paris: André Pralard.**^**Wallis, John (1685).*A treatise of algebra*. London: John Playford.**^**Dedekind, Richard (1888).*Was sind und was sollen die Zahlen?*. Braunschweig: Vieweg.**^**Syropoulos, Apostolos (2001). "Mathematics of Multisets". In Calude, C. S.; et al. (eds.).*Multiset processing: Mathematical, computer science, and molecular computing points of view*. Springer-Verlag. pp. 347–358.**^**Whitney, H. (1933). "Characteristic Functions and the Algebra of Logic".*Annals of Mathematics*.**34**: 405–414.**^**Monro, G. P. (1987). "The Concept of Multiset".*Zeitschrift für Mathematische Logik und Grundlagen der Mathematik*.**33**: 171–178.**^**Aigner, M. (1979).*Combinatorial Theory*. New York/Berlin: Springer Verlag.**^**Anderson, I. (1987).*Combinatorics of Finite Sets*. Oxford: Clarendon Press.**^**Stanley, Richard P. (1997).*Enumerative Combinatorics*.**1**. Cambridge University Press. ISBN 0-521-55309-1.**^**Stanley, Richard P. (1999).*Enumerative Combinatorics*.**2**. Cambridge University Press. ISBN 0-521-56069-1.**^**Grumbach, S.; Milo, T (1996). "Towards tractable algebras for bags".*Journal of Computer and System Sciences*.**52**(3): 570–588. doi:10.1006/jcss.1996.0042.**^**Libkin, L.; Wong, L. (1994). "Some properties of query languages for bags".*Proceedings of the Workshop on Database Programming Languages*. Springer Verlag. pp. 97–114.**^**Libkin, L.; Wong, L. (1995). "On representation and querying incomplete information in databases with bags".*Information Processing Letters*.**56**(4): 209–214. doi:10.1016/0020-0190(95)00154-5.**^**Blizard, Wayne D. (1989). "Real-valued Multisets and Fuzzy Sets".*Fuzzy Sets and Systems*.**33**: 77–97. doi:10.1016/0165-0114(89)90218-2.**^**Blizard, Wayne D. (1990). "Negative Membership".*Notre Dame Journal of Formal Logic*.**31**(1): 346–368.**^**Yager, R. R. (1986). "On the Theory of Bags".*International Journal of General Systems*.**13**: 23–37. doi:10.1080/03081078608934952.**^**Grzymala-Busse, J. (1987). "Learning from examples based on rough multisets".*Proceedings of the 2nd International Symposium on Methodologies for Intelligent Systems*. Charlotte, North Carolina. pp. 325–332.**^**Loeb, D. (1992). "Sets with a negative numbers of elements".*Advances in Mathematics*.**91**: 64–74. doi:10.1016/0001-8708(92)90011-9.**^**Miyamoto, S. (2001). "Fuzzy Multisets and their Generalizations".*Multiset Processing*.**2235**: 225–235.**^**Alkhazaleh, S.; Salleh, A. R.; Hassan, N. (2011). "Soft Multisets Theory".*Applied Mathematical Sciences*.**5**(72): 3561–3573.**^**Alkhazaleh, S.; Salleh, A. R. (2012). "Fuzzy Soft Multiset Theory".*Abstract and Applied Analysis*.**^**Burgin, Mark (1990). "Theory of Named Sets as a Foundational Basis for Mathematics".*Structures in Mathematical Theories*. San Sebastian. pp. 417–420.**^**Burgin, Mark (1992). "On the concept of a multiset in cybernetics".*Cybernetics and System Analysis*.**3**: 165–167.**^**Burgin, Mark (2004). "Unified Foundations of Mathematics". arXiv:math/0403186.**^**Burgin, Mark (2011).*Theory of Named Sets*. Mathematics Research Developments. Nova Science Pub Inc. ISBN 978-1-61122-788-8.