Textbook
The cardinality of a finite set $A$, written $|A|$, is the number of its distinct elements. The empty set has $|\varnothing|=0$. Neither listing order nor repeated entries change a set, so $|\{2,4,4\}|=2$.
The set $\{\varnothing\}$ has one element, the empty set itself, and therefore has cardinality 1. The same bars denote absolute value when their argument is a number. This article concerns finite sets only; an infinite set cannot be counted by reaching a last element.
Counting a finite set assigns its elements numbers $1,\ldots,n$ so that each element receives one number and no number is reused. The final $n$ does not depend on numbering order. Adding an existing element leaves cardinality unchanged; adding a new one increases it by one. Equal cardinality need not mean equal sets: numbering records how many objects there are, without preserving which objects were counted.
Definitions and further reading: Mathematics for Computer Science.
In plain language
A finite set’s cardinality counts distinct objects: listing Bob twice does not create a second person. The elements must be identified first and counted once each; file length matches the answer only without repeated entries. A box containing one empty box has one item even though the inner box is empty. Names must still identify people unambiguously; administrative convenience cannot merge namesakes into one guest.
Example
The example starts with the listing $\{2,4,4\}$. Removing the repeated entry allows a count of the elements, followed by a comparison with a set containing the empty set.
Finite Set Cardinality: Counting Elements
Listing
The repeated 4 is not a new element.
Step 1 of 3: Listing
Read all steps
Listing
The repeated 4 is not a new element.
- State
- 2included4included4excluded
Counting
There are two distinct elements.
- State
- 2current4current
A nested element
The empty set inside the braces counts as one object.
- State
- ∅current
The first step removes a repeated occurrence of four, not the value four itself: that element remains. The second counts two and four, giving cardinality two. The last step changes the set under consideration: its sole element is now $\varnothing$. Counting the outer level leaves the inner braces intact. The inner object contains zero elements, but remains one object in the surrounding set.
Related concept: Set membership.