Help proving equivalence of an element being integral, and a subring being finitely generated There is a lemma in my notes,
Given a (commutative, unital) ring $B$, and a subring $A \subset B$, the following are equivalent:
(i) $b \in B$ is integral over $A$
(ii) $A[b]$ is finite over $A$ (as an $A$-module)
I assume that $A[b] = \{f(b): f\in A[X]\}$. The proof is meant to be easy, but I can't figure out either direction. I can see that $A$ is a subring of $A[b]$ (which is itself a subring of $B$). Therefore I know $(A[b],+,A,\cdot)$ is a well defined module (with the obvious operations).
For the $(\rightarrow)$ direction, by assumption there is some monic $\bar{f}\in A[X]$ s.t. $\bar{f}(b)=0$. To prove $A[b]$ is finite over $A$, I must show that every element of $A[b]$ may be written in the form $\sum_{i=1}^n a_if_i(b)$ where each $a_i \in A$, and $\{f_1(b),...f_n(b)\} \subset A[b]$. I am struggling to come up with the appropriate polys $f_1,...f_n$ that will generate $A[b]$. I know that I will surely have to make use of $\bar{f}$, but I cannot see how. For example, say I take the generating set to be $1,X,\bar{f}$. The problem I see is that any scalar product with $\bar{f}$ is again zero (since $\bar{f}=0$), and evaluating $1,X$ on $b$ simply gives $1,b$. So the only elements of $B$ I can generate from this set are sums of $1,b$. Extending this, if I add $X^2, X^3,...X^n$ to the generating set, the elements I can represent are all the sums of 1, $b$ and powers of $b$ up to $n$. But I don't see how I can tell for some finite $n$ that these sums give me all of $A[b]$.
For the $(\leftarrow)$ direction, I know I have some set $\{f_1(b),...,f_n(b)\}\subset A[b]$ whose linear combinations with coefficients in $A$ generate the whole set $A[b]$. But I can't see how this tells me there is some monic $f$ such that $f(b)=0$. I know the zero polynomial in $A[X]$ obviously means $0 \in A[b]$, but this is not the same thing as having a monic polynomial evaluating to zero.
Can someone point me in the right direction?
 A: Let $d=\deg\left(\overline{f}\right)$ be the degree of the monic polynomial $\overline{f}\in A\left[X\right]$ satisfying $\overline{f}\left(b\right)=0$. This means that you can write:
\begin{equation*}
b^{d}+g\left(b\right)=0
\end{equation*}
for some polynomial $g\in A\left[X\right]$ with degree smaller than $d$. In particular, $b^{d}$ can be written as a $A$-linear combination in the elements $\left\{b^{0},\ldots,b^{d-1}\right\}$ in $A\left[b\right]$.
Now, let $n\geqslant d$ be an integer and suppose that for any $m\in\left\{d,\ldots,n\right\}$ the element $b^{m}\in A\left[b\right]$ can be written as a $A$-linear combination in the elements $\left\{b^{0},\ldots,b^{d-1}\right\}$ in $A\left[b\right]$. You have:
\begin{equation*}
b^{m+1}+b^{m+1-d}g\left(b\right)=0\text{.}
\end{equation*}
So by induction on m, any $b^{m}$ can be written as such a $A$-linear combination. This means that for any polynomial $f\in A\left[X\right]$, the element $f\left(b\right)$ can also be written as such, so that the family $\left\{b^{0},\ldots,b^{d-1}\right\}$ generates $A\left[b\right]$ as a $A$-module: it is therefore finite over $A$.
Conversely, if some set $\left\{f_{1}\left(b\right),\ldots,f_{n}\left(b\right)\right\}\subset A\left[b\right]$ generates $A\left[b\right]$ as a $A$-module, then you can take $d'$ to be the biggest of all degrees of the polynomials $\left\{f_{1}\left(b\right),\ldots,f_{n}\left(b\right)\right\}$.
By assumption, you can write:
\begin{equation*}
b^{d'+1}=\sum_{i=1}^{n}a_{i}f_{i}\left(b\right)
\end{equation*}
with all $a_{i}\in A$. But by definition of $d$', the polynomial:
\begin{equation*}
b^{d'+1}-\sum_{i=1}^{n}a_{i}f_{i}\left(b\right)=0
\end{equation*}
has degree $d'+1$ and is monic. In particular, $b$ is integral over $A$.
Notice that I did not use the fact that $A\to B$ is injective.
A: Division with remainder by a monic polynomial is possible over any commutative ring.
If $g(x)\in A[x]$ is a monic polynomial such that $g(b)=0$, then for every $f(x)\in A[x]$ you can write
$$
f(x)=g(x)q(x)+r(x)
$$
where $r$ has degree less than $n=\deg g$ (or is the zero polynomial, in case you don't assign degree $-\infty$ to the zero polynomial).
In particular $f(b)$ can be written as $r(b)$, where $r(x)=a_0+a_1x+\dots+a_{n-1}x^{n-1}$ and so $A[b]$ is generated as an $A$-module by $1,b,\dots,b^{n-1}$.
For the converse, suppose $A[b]$ is generated as an $A$-module by $f_1(b),\dots,f_n(b)$. If $d$ is the largest among the degrees of $f_1(x),\dots,f_n(x)$, then
$$
b^{d+1}=\sum_{k=1}^n a_kf_k(b)
$$
and so the polynomial
$$
g(x)=x^{d+1}-\sum_{k=1}^n a_kf_k(x)\in A[x]
$$
is a monic polynomial such that $g(b)=0$.
