TExcelTAD
Home › Discrete Mathematics › Bijections and the Division Rule

Bijections and the Division Rule

Two more counting tools come from the mapping rules of Finite Cardinality. The bijection rule counts a set by matching it with one that is easier to count. The division rule counts objects when each one has been counted the same number of times, kk, by dividing by kk. Together they explain the formulas for combinations, circular arrangements and arrangements with repeated letters.

The bijection rule

If there is a bijection A→BA \to B, then ∣A∣=∣B∣\lvert A \rvert = \lvert B \rvert.

Example: emoji packs. A chat app sells packs of 9 stickers, and each sticker is one of 4 designs (cat, dog, fox, owl); only the number of each design matters. Write a pack as a string of 9 stars (stickers) and 3 bars (separators between designs). For instance

text
*** | | ***** | *

means 3 cats, no dogs, 5 foxes and 1 owl. Every pack gives exactly one string and every string of 9 stars and 3 bars gives one pack, so we count strings of length 12 with 3 bars: choose the 3 bar positions, (123)=220\binom{12}{3} = 220. This is the stars and bars method. In general, choosing nn items from kk kinds with repetition can be done in (n+k−1k−1)\binom{n + k - 1}{k - 1} ways.

python · try it yourself
from itertools import combinations_with_replacement
from math import comb

designs = ["cat", "dog", "fox", "owl"]
count = sum(1 for _ in combinations_with_replacement(designs, 9))
print("by enumeration:", count, " stars and bars:", comb(12, 3))
by enumeration: 220  stars and bars: 220

The division rule

If f:A→Bf: A \to B is kk-to-1 (every element of BB is the image of exactly kk elements of AA), then

∣B∣=∣A∣k\lvert B \rvert = \frac{\lvert A \rvert}{k}

Round tables. Seat nn people at a round table, where only who sits next to whom (in which order) matters, not which chair. Map each row arrangement to the circular seating obtained by bending the row into a circle. Each circular seating comes from nn rows (one per starting point), so there are n!n=(n−1)!\frac{n!}{n} = (n-1)! circular seatings.

Combinations. How many kk-element subsets does an nn-element set have? Map each kk-permutation (ordered choice of kk items) to the set of its items. Each kk-set is the image of k!k! orderings, so

(nk)=P(n,k)k!=n!k! (n−k)!\binom{n}{k} = \frac{P(n, k)}{k!} = \frac{n!}{k!\,(n-k)!}

Anagrams and multisets

How many distinct arrangements does the word BANANA have? If the letters were all different there would be 6!6!. But swapping the three A's among themselves gives the same word (3!3! ways), and swapping the two N's too (2!2! ways). Each distinct word is counted 3!⋅2!⋅1!3! \cdot 2! \cdot 1! times:

6!3! 2! 1!=60\frac{6!}{3!\,2!\,1!} = 60
python · try it yourself
from itertools import permutations
from math import factorial

word = "BANANA"
distinct = set(permutations(word))
print("distinct arrangements:", len(distinct))
print("formula:", factorial(6) // (factorial(3) * factorial(2) * factorial(1)))
print("examples:", sorted("".join(p) for p in distinct)[:5])
distinct arrangements: 60
formula: 60
examples: ['AAABNN', 'AAANBN', 'AAANNB', 'AABANN', 'AABNAN']

This is the bookkeeper rule, studied in the next lesson.

In software

The division rule is how you count objects "up to symmetry": distinct necklaces, distinct game boards up to rotation, distinct molecules. Hash-based deduplication of permutations (store a sorted tuple as the canonical form) implements the kk-to-1 map in code. Stars and bars counts the ways to distribute nn identical tasks among kk workers or to split a budget into whole units.

Exercises

Exercise 1: Committees

How many 3-person committees can be chosen from 10 people? Use the division rule.

Answer
Solution

P(10,3)=720P(10, 3) = 720 ordered choices; each committee is counted 3!=63! = 6 times. 720/6=120720 / 6 = 120.

Exercise 2: Anagrams

How many distinct arrangements does MISSISSIPPI have?

Answer
Solution

11 letters: M once, I four times, S four times, P twice.

11!1! 4! 4! 2!=399168001⋅24⋅24⋅2=34650\frac{11!}{1!\,4!\,4!\,2!} = \frac{39916800}{1 \cdot 24 \cdot 24 \cdot 2} = 34650

Exercise 3: Stars and bars (code)

In how many ways can 10 identical tasks be assigned to 4 servers if each server must get at least 1 task? Use stars and bars and check by brute force.

Answer

(93)=84\binom{9}{3} = 84.

Solution

Give each server 1 task first; then distribute the remaining 6 freely: (6+33)=84\binom{6 + 3}{3} = 84.

python · try it yourself
from math import comb

brute = sum(1 for a in range(1, 11) for b in range(1, 11) for c in range(1, 11) if 1 <= 10 - a - b - c)
print(brute, comb(9, 3))
84 84

Test yourself

In how many ways can 7 people sit around a round table (rotations considered the same)?

  1. 5040
  2. 720
  3. 7
  4. 120

How many distinct arrangements does the word LEVEL have?

  1. 120
  2. 60
  3. 30
  4. 20

How many ways can you choose 5 scoops from 3 ice cream flavours (repetition allowed, order irrelevant)?

  1. 15
  2. 21
  3. 10
  4. 243