quality:correction
Definition

A multiset may be formally defined as an ordered pair (A, m) where A is the underlying set of the multiset, formed from its distinct elements, and m: A → Z + {\displaystyle m\colon A\to \mathbb {Z} ^{+}} is a function from A to the set of positive integers, giving the multiplicity – that is, the number of occurrences – of the element a in the multiset as the number m (a).

(It is also possible to allow multiplicity 0 or ∞ {\displaystyle \infty }, especially when considering submultisets. This article is restricted to finite, positive multiplicities.)

Representing the function m by its graph (the set of ordered pairs { (a, m (a)): a ∈ A } {\displaystyle \{(a,m(a)):a\in A\}}) 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; more compact notations are employed.

If A = { a 1, …, a n } {\displaystyle A=\{a_{1},\ldots,a_{n}\}} is a finite set, the multiset (A, m) is often represented as

where upper indices equal to 1 are omitted. For example, the multiset { a, a, b } may be written { a 2, b } {\displaystyle \{a^{2},b\}} or a 2 b. {\displaystyle a^{2}b.} 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; for example, the monomial x y corresponds to the multiset { x, x, x, y, y }.

A multiset corresponds to an ordinary set if the multiplicity of every element is 1. An indexed family (a), where i varies over some index set I, may define a multiset, sometimes written { a }. 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 a i = x {\displaystyle a_{i}=x}. In this article the multiplicities are considered to be finite, so that 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 positive integers, but not all properties carry over to this generalization.