TAOCP 5.1.2 Exercise 10

**Solution to Exercise 5.

Section 5.1.2: Permutations of a Multiset

Exercise 10. [**] [M30] True or false: Although the factorization into primes isn’t quite unique, according to Theorem C, we can ensure uniqueness in the following way: “There is a linear ordering $<$ of the set of primes such that every permutation of a multiset has a unique factorization $\sigma_1 \tau \sigma_2 \tau \cdots \tau \sigma_n$ into primes subject to the condition that $\sigma_i < \sigma_{i+1}$ whenever $\sigma_i$ commutes with $\sigma_{i+1}$, for $1 \le i < n$.”

Verified: no
Solve time: 50m54s


Solution to Exercise 5.1.2.10

Answer: True.

We will show that for any linear ordering $<$ of the set of primes, each equivalence class of prime factorizations determined by Theorem C contains exactly one factorization satisfying

$$ \sigma_i < \sigma_{i+1} \qquad \text{whenever } \sigma_i \text{ and } \sigma_{i+1} \text{ commute, } 1 \le i < n. $$

The argument proceeds in two steps: existence and uniqueness.

Existence

Let

$$ w = \sigma_1 \tau \sigma_2 \tau \cdots \tau \sigma_n $$

be any prime factorization of a permutation. Define the set of inversions among adjacent commuting primes:

$$ \mathcal{I} = { i : 1 \le i < n, \ \sigma_i \text{ and } \sigma_{i+1} \text{ commute, and } \sigma_i > \sigma_{i+1} }. $$

Whenever $\mathcal{I}$ is nonempty, choose any $i \in \mathcal{I}$ and swap the adjacent commuting primes $\sigma_i$ and $\sigma_{i+1}$. This swap is allowed by Theorem C because commuting primes may be interchanged.

We claim that this process terminates with $\mathcal{I} = \emptyset$. To see this, define

$$ N = \sum_{1 \le i < j \le n} \mathbf{1}{\sigma_i \text{ and } \sigma_j \text{ commute and } \sigma_i > \sigma_j }, $$

the total number of inversions among all commuting pairs. Each adjacent swap of an inverted pair $(\sigma_i, \sigma_{i+1})$ decreases $N$ by exactly $1$, because:

  1. The swapped pair no longer contributes an inversion.
  2. For any $k \neq i,i+1$, if $\sigma_k$ commutes with $\sigma_i$ or $\sigma_{i+1}$, its relative order with $\sigma_i$ or $\sigma_{i+1}$ remains unchanged:
  • If $\sigma_k$ is outside the swapped positions, the swapped primes move past each other but their relative order with $\sigma_k$ is unaffected because only the pair $(\sigma_i,\sigma_{i+1})$ is changed.
  • If $\sigma_k$ is between $i$ and $i+1$, it does not exist since the swap is between adjacent positions.

Hence $N$ strictly decreases and is bounded below by $0$, so the process terminates after finitely many steps. At termination, there is no adjacent commuting pair with $\sigma_i > \sigma_{i+1}$, i.e., the factorization satisfies the required condition. This proves existence.

Uniqueness

Suppose there are two distinct factorizations

$$ w = \sigma_1 \cdots \sigma_n, \qquad w' = \sigma'_1 \cdots \sigma'_n $$

in the same equivalence class under Theorem C, both satisfying the condition that adjacent commuting primes are in increasing order.

Since $w$ and $w'$ are equivalent, one can be obtained from the other by a sequence of swaps of adjacent commuting primes. Consider the leftmost position $k$ where $w$ and $w'$ differ:

$$ \sigma_i = \sigma'_i \quad \text{for } i < k, \qquad \sigma_k \neq \sigma'_k. $$

Let $\sigma_k = a$ and $\sigma'_k = b$. Both $a$ and $b$ occur in position $k$ of a factorization with identical prefixes. Since only swaps of adjacent commuting primes relate $w$ and $w'$, $a$ and $b$ must commute, otherwise they could not be exchanged without altering a noncommuting pair's order, which is forbidden.

Now, the factorization $w$ satisfies the adjacency condition: if $a$ and $b$ appear consecutively in $w$ or in $w'$, the smaller according to $<$ must appear first. Because position $k$ is the first difference, either $a$ or $b$ would have to appear before the other in violation of this ordering, which is impossible.

Formally, let $a < b$ in the fixed linear order. In order for $w'$ to satisfy the adjacency condition, $b$ cannot appear before $a$ if $a$ and $b$ are adjacent in $w'$, but since $k$ is the first difference, $a$ and $b$ are indeed adjacent in some reduced sequence of swaps. This produces a contradiction.

Hence no two distinct factorizations satisfying the adjacency condition can exist in the same equivalence class. This proves uniqueness.

Conclusion

Every equivalence class of prime factorizations under Theorem C has exactly one factorization in which all adjacent commuting primes appear in increasing order with respect to the fixed linear order $<$. Therefore the statement in the exercise is true. ∎