# Understanding Nakayama lemma proof

I understand how the determinant trick works to show that $\varphi^n + a_1 \varphi^{n-1} + \dots + a_n = 0$ as an endomorphism of $A$-module $M$ given that $\varphi \in \text{Hom}_A(M,M)$ and $\varphi(M) \subset IM$. The Nakayama lemma goes:

Let $M$ be a finite $A$-module and $I$ an ideal of $A$. If $M = IM$ then there exists $a \in A$ such that $aM = 0$ and $a \equiv 1 \pmod I$.

Proof. Setting $\varphi = 1_M$ in the previous theorem (determinant trick) gives the relation $a = 1 + a_1 + \dots + a_n = 0$ as endomorphisms of $M$, that is $aM = 0$, and $a = 1 \pmod I$.

The last part is what I don't understand, if $a = 1 + a_1 + \dots + a_n = 0$ as an endomorphism, how does that immediately translate over to the ring $A$ to show that $a \equiv 1 \pmod I$?

I think you're getting a bit confused in how the proof goes. Here's a rephrasing of the argument. By the determinant trick, there exist elements $a_{1}, \ldots, a_{n} \in I$ such that $\mathrm{Id}_{M}^{n} + a_{n}\mathrm{Id}_{M}^{n-1} + \cdots + a_{1}\mathrm{Id}_{M} = 0$ as endomorphisms of $M$. Put $a = 1+a_{1}+\cdots +a_{n}$; then for any $m \in M$, $$(\mathrm{Id}_{M}^{n} + a_{n}\mathrm{Id}_{M}^{n-1} + \cdots + a_{1}\mathrm{Id}_{M})(m) = (1+a_{1}+\cdots+a_{n}) \cdot m = a \cdot m = 0$$ Hence, $aM = 0$, and $a \equiv 1 \pmod{I}$.
The elements $a_1,\dots,a_n$ are all in $I$. So $a=1 + a_1 + \dots + a_n$ implies $a\equiv 1\pmod{I}$. (Note that the statement "as endomorphisms of $M$" only applies to the statement $a=0$, not to $a=1 + a_1 + \dots + a_n$.)