20.2: Addition and subtraction rules
( \newcommand{\kernel}{\mathrm{null}\,}\)
As usual in mathematics, breaking a big problem into smaller parts is a useful strategy.
Assume U is a finite set.
- If U=A1⊔A2, then |U|=|A1|+|A2|.
- If U=A1∪A2, then |U|=|A1|+|A2|−|A1∩A2|.
- Proof Idea.
-
After recalling the definition of disjoint union, Statement 1 should be obvious. To prove Statement 2, apply Statement 1 to the following disjoint unions:
U=A1⊔(A2∖A1),A2=(A2∖A1)⊔(A1∩A2).
Then combine the resulting equalities of cardinalities.
Statement 1 of Theorem 20.2.1 can be extended to a disjoint union of any number of subsets.
How many words of length 3 or less are there using alphabet Σ={α,ω}?
Solution
Write Σ∗≤3 to mean the set of words in alphabet Σ of length 3 or less. Then
Σ∗≤3=Σ∗0⊔Σ∗1⊔Σ∗2⊔Σ∗3,
so we can break into cases based on length and then apply the Addition Rule.
Count Σ∗0.
There is only one word of length 0: the empty word. So |Σ∗0|=1.
Count Σ∗1.
There are only two words of length 1: the single-letter words wα=α and wω=ω. So |Σ∗1|=2.
Count Σ∗2.
We can count be simply listing the elements:
Σ∗2={αα,αω,ωα,ωω}.
So |Σ∗2|=4.
Count Σ∗3.
This time we will just use inductive reasoning. Each word in Σ∗2 may be extended to a word in Σ∗3 by appending either an α or an ω onto the end. So there must be twice as many words in Σ∗3 as in Σ∗2, i.e. |Σ∗3|=8.
Total count.
Using the Addition Rule, we obtain the total by adding up our preliminary results:
|Σ∗≤3|=1+2+4+8=15.
Another common strategy in mathematics is to consider the opposite.
Assume U is a finite set. For every subset A⊆U, we have |A|=|U|−|AC|.
- Proof Idea.
-
Since U=A⊔AC is always true, simply apply Statement 1 of Theorem 20.2.1 to this disjoint union and rearrange to isolate |A|.
For alphabet Σ={a,b,c,…,y,z}, how many words in Σ∗2 do not begin with the letter a? It's much easier to count the number of words in Σ∗2 that do begin with a, as there are only 26 possibilities for the second letter.
Later in this chapter we will learn a rule that will allow us to easily calculate the total number of words in Σ∗2 to be 262 (see Worked Example 20.3.6). Accepting this fact for the moment, we can then use the Subtraction Rule to compute
#{2-letter words not beginning with a}=|Σ∗2|−#{2-letter words beginning with a}=262−26=26(26−1)=26⋅25.