TITLE: Proving uniqueness in the structure theorem for finitely generated modules over a principal ideal domain
QUESTION [7 upvotes]: In an introductory algebra course, one proves the Structure theorem for finitely generated modules over a principal ideal domain.
http://en.wikipedia.org/wiki/Structure_theorem_for_finitely_generated_modules_over_a_principal_ideal_domain
In every book that I have looked in, the uniqueness part of the proof is a mess.
Can anyone give me a reference for a nicer proof of the uniqueness part? I am especially interested in a proof of uniqueness when the underlying ring is the ring of polynomials in one variable over a field.

REPLY [4 votes]: I will give a proof of uniqueness that handles the torsion and torsion-free components simultaneously and that characterizes the invariant factors directly, rather than doing it indirectly through the elementary divisors $p^i$. Specifically, I prove the following result.

Proposition. Let $A$ be a commutative ring and $I_1 \subseteq I_2 \subseteq \dots \subseteq I_n$ an increasing sequence of proper ideals of $A$ (some or all of which may be zero). Let $E$ be an $A$-module for which an isomorphism
  \begin{equation} \tag{*}
E \cong A/I_1 \times \dots \times A/I_n
\end{equation}
  holds.
$(1)$ The minimal number of generators of $E$ is $n$.
$(2)$ For $k = 1, \dots, n$, the ideal $I_k$ is equal to the set of all $x \in A$ such that the $A$-module $xE$ can be generated by fewer than $k$ elements.

Proof of $(1)$. Since $E$ is in an obvious way the homomorphic image of $A^n$, it is clear that $E$ has a generating set consisting of $n$ elements. Conversely, assume that $E$ can be generated by $r$ elements for some $r < n$. Let $M$ be a maximal ideal containing $I_n$. We have an obvious $A$-linear surjection $E \to (A/M)^n$. Consequently, $(A/M)^n$ can be generated by $r$ elements as an $A$-module and hence also as an $A/M$-vector space, which is absurd.
Proof of $(2)$. Let $x \in A$, and let $k \leq n$. For any ideal $I$ of $A$, denote by $I_x$ the ideal of $A$ that is the inverse image of $I$ under the map $A \to A, \ y \mapsto xy$. We have
\begin{equation}
xE \cong A/{(I_1)}_x \times \dots \times A/{(I_n)}_x.
\end{equation}
This decomposition is of the type $\text{(*)}$ except for the fact that some of the factors $A/{(I_j)}_x$ at the end may be zero. By $(1)$, the module $xE$ can be generated by fewer than $k$ elements if and only if the $k$th factor $A/{(I_k)}_x$ is zero, or equivalently when $x \in I_k$.
Note. The existence of $M$ asserted in the proof of $(1)$ follows from Krull's Theorem. However, its existence is trivial when $A$ is a p.i.d., which is the case of interest here. If $A$ is a p.i.d. other than a field, we can let $M = pA$, where $p$ is an irreducible element dividing a generator of $I_n$. If $A$ is a field, let $M = {0}$. 
The use of Krull's Theorem can also be avoided entirely by replacing $M$ with $I_n$ and using the fact that there can be no $B$-linear surjection $f \colon B^r \to B^n$, where $B = A/I_n$. For if there were, it would split, say $fg = \operatorname{id}_{B^n}$. This is absurd, because the characteristic polynomial of $fg$ is divisible by $X^{n-r}$, as shown here.