What's wrong or where is the AOC required in this proof? (free modules over a PID) The theorem in question is:
Theorem. Let $R$ be a principal ideal domain and let $F$ be a free $R$-module. Then any submodule $K\subseteq F$ is free.
This is proved in Hungerford theorem 6.1, and elsewhere using the axiom of choice and transfinite induction very explicitly. I have a feeling my proof is too simple, and so has to be very incorrect. It doesn't (explicitly) assume the axiom of choice, nor explicitly use transfinite induction.
Proof. Consider $F$ to be free over the set $X=\{x_i|i\in I\}$. That is, every element of $F$ can be written as a finite sum $\sum_j r_j x_j$. Denote $K_i=K\bigcap \langle x_i\rangle=\{r_i x_i|\sum_j r_j x_j\in K\}$.
First, I want to show each $K_i=\langle h_i\rangle$ for some $h_i\in K_i$. So consider the projection $p_i:K_i\to R$ with $p_i(r_i x_i)=r_i$ (which is well defined by the universal free property of $F$). This must have $\ker p_i=(0)$ (by the construction of the free module, $x_i$ is just a formal placeholder, and $r_i x_i=0$ if and only if $r_i=0$). Since $K_i$ is an $R$-module, $p_i(K_i)$ is an $R$-module and so is generated by a single element, $p_i(K_i)=\langle a_i\rangle$. Then $p_i:K_i\to \langle a_i\rangle$ is a one-to-one and onto homomorphism. Denote $h_i=p_i^{-1}(a_i)$. Then $K_i=\langle h_i\rangle$. Every nonzero principal ideal of an integral domain is isomorphic to the ring, so each $K_i$ is isomorphic to $R$ or $(0)$.
Next, consider the internal direct sum of all $K_i$, $\bigoplus^{i\in I} K_i$. Due to its construction by taking intersections, it is a subset of $K$. If we are given an arbitrary finite sum $\sum_i r_i x_i\in K$, each $r_i x_i$ must individually lie in some $K_i$, and so the whole thing is in the direct sum of the $K_i$. Thus $K=\bigoplus^{i\in I}\langle h_i\rangle\cong \bigoplus_{i\in I} R$ (where the last direct product is taken over all $i$ such that $K_i\neq (0)$), and so $K$ is free. $\square$
as far as I see, I have used:


*

*the existence of the direct sum over arbitrary families indexed by $I$

*the fact that an $R$-module is equal to some direct sum of $R$ if and only if it is free

*that every nonzero principal ideal of an integral domain $R$ is isomorphic to $R$.


but the proof can't be correct! The proof in Hungerford runs a page long (where most proofs in Hungerford are a paragraph or a few lines!), and emphasizes the use of the axiom of choice. Where have I been led astray?
 A: It's not true that $K\cap\langle x_i\rangle=\{r_i x_i|\sum_j r_j x_j\in K\}$.  For instance, an element of the form $ax_1+bx_2$ might be in $K$ even if $ax_1\not\in K$.  You can see this in a really simple example by taking $R=\mathbb{Z}$, $F=\mathbb{Z}^2$, and $K$ to be generated by $(1,1)$.  In this example $K\cap\langle x_i\rangle=0$ for all $i$, and it is not true that $K$ is the sum of the $K_i$.
A: EDIT: Eric Wofsey pointed out the fundamental error, which is ring theoretic. However, there is a step which appears to invoke choice (but see Eric's comments below), and I think it worthwhile to point it out.
Specifically, the following step smells like choice:
You state

Every nonzero ideal of an integral domain $R$ is isomorphic to $R$.

And from this you conclude that - since each $\langle h_i\rangle$ is isomorphic to $R$ - we have $$\bigoplus_{i\in I}\langle h_i\rangle\cong \bigoplus_{i\in I}R.$$ However, this appears to require you to choose an isomorphism $f_i: \langle h_i\rangle\rightarrow R$ for each $i\in I$; otherwise, how do you build the "large" isomorphism above?
It may be that there's a hidden uniformity here that lets you make this work without choice; as I said, ring theory isn't my specialty. But currently I think this step relies on choice.
Tl;dr: in general algebraic contexts, choice is needed to argue that "$A_i\cong B_i$ ($i\in I$)" implies "$\bigoplus A_i\cong\bigoplus B_i$" (or similar).
