[proofplan]
The proof separates odd and even weights. Odd weights vanish because the matrix $-I \in \mathrm{SL}_2(\mathbb{Z})$ fixes every point of the upper half-plane but acts on weight-$k$ modular forms by the scalar $(-1)^k$. For even weights, the [structure theorem for level-one modular forms](/theorems/4235) identifies a basis of $M_k(\mathrm{SL}_2(\mathbb{Z}))$ with the monomials $E_4^a E_6^b$ of total weight $k$, so the dimension is reduced to counting nonnegative integer solutions of $4a+6b=k$.
[/proofplan]
[step:Use the action of $-I$ to eliminate odd weights]
Let $\mathbb{H} := \{z \in \mathbb{C} : \operatorname{Im}(z) > 0\}$ denote the complex upper half-plane. Let
\begin{align*}
f: \mathbb{H} &\to \mathbb{C}
\end{align*}
be an element of $M_k(\mathrm{SL}_2(\mathbb{Z}))$. The defining transformation law for a modular form of weight $k$ says that, for every matrix
\begin{align*}
\gamma =
\begin{pmatrix}
a & b\\
c & d
\end{pmatrix}
\in \mathrm{SL}_2(\mathbb{Z})
\end{align*}
and every $z \in \mathbb{H}$,
\begin{align*}
f\left(\frac{az+b}{cz+d}\right) = (cz+d)^k f(z).
\end{align*}
Apply this with $\gamma = -I$, so $a=d=-1$ and $b=c=0$. Then $\gamma z=z$ and $cz+d=-1$, hence
\begin{align*}
f(z) = (-1)^k f(z)
\end{align*}
for every $z \in \mathbb{H}$. If $k$ is odd, then $(-1)^k=-1$, so
\begin{align*}
f(z) = -f(z)
\end{align*}
for every $z \in \mathbb{H}$. Therefore $f(z)=0$ for every $z \in \mathbb{H}$, and hence
\begin{align*}
M_k(\mathrm{SL}_2(\mathbb{Z})) = \{0\}.
\end{align*}
[guided]
The point of this step is that level-one modular forms transform under every element of $\mathrm{SL}_2(\mathbb{Z})$, including the central element $-I$. Let
\begin{align*}
f: \mathbb{H} &\to \mathbb{C}
\end{align*}
be a modular form of weight $k$, where $\mathbb{H} := \{z \in \mathbb{C} : \operatorname{Im}(z)>0\}$. The transformation law gives
\begin{align*}
f\left(\frac{az+b}{cz+d}\right) = (cz+d)^k f(z)
\end{align*}
for every
\begin{align*}
\begin{pmatrix}
a & b\\
c & d
\end{pmatrix}
\in \mathrm{SL}_2(\mathbb{Z})
\end{align*}
and every $z \in \mathbb{H}$.
Now take the particular matrix $-I$. It acts on $\mathbb{H}$ by
\begin{align*}
z \mapsto \frac{-z+0}{0z-1} = z,
\end{align*}
so it fixes every point of $\mathbb{H}$. However, the automorphy factor is $cz+d=-1$. Therefore the transformation law becomes
\begin{align*}
f(z)=(-1)^k f(z).
\end{align*}
When $k$ is odd, this is
\begin{align*}
f(z)=-f(z),
\end{align*}
so $2f(z)=0$ for every $z \in \mathbb{H}$. Since the functions are complex-valued and $2 \neq 0$ in $\mathbb{C}$, this forces $f(z)=0$ for every $z$. Thus the only modular form of odd weight is the zero form.
[/guided]
[/step]
[step:Reduce the even-weight dimension to a lattice-point count]
Assume now that $k$ is even, and define the integer $n := k/2$. By the structure theorem for level-one modular forms (citing a result not yet in the wiki: Structure Theorem for Level-One Modular Forms), the graded $\mathbb{C}$-algebra of level-one modular forms is
\begin{align*}
\bigoplus_{j \ge 0} M_j(\mathrm{SL}_2(\mathbb{Z})) \cong \mathbb{C}[E_4,E_6],
\end{align*}
where $E_4 \in M_4(\mathrm{SL}_2(\mathbb{Z}))$ and $E_6 \in M_6(\mathrm{SL}_2(\mathbb{Z}))$ are algebraically independent. Therefore the monomials
\begin{align*}
E_4^a E_6^b
\end{align*}
with $a,b \in \mathbb{Z}_{\ge 0}$ and
\begin{align*}
4a+6b=k
\end{align*}
form a $\mathbb{C}$-basis of $M_k(\mathrm{SL}_2(\mathbb{Z}))$. Dividing the weight equation by $2$, we obtain the equivalent Diophantine equation
\begin{align*}
2a+3b=n.
\end{align*}
Hence
\begin{align*}
\dim_{\mathbb{C}} M_k(\mathrm{SL}_2(\mathbb{Z}))
=
\#\{(a,b)\in \mathbb{Z}_{\ge 0}^2 : 2a+3b=n\}.
\end{align*}
[guided]
For even $k$, the structure theorem for level-one modular forms converts the analytic problem into a finite counting problem. The theorem says that the graded ring of level-one modular forms is the polynomial algebra generated by the Eisenstein series $E_4$ and $E_6$:
\begin{align*}
\bigoplus_{j \ge 0} M_j(\mathrm{SL}_2(\mathbb{Z})) \cong \mathbb{C}[E_4,E_6],
\end{align*}
where $E_4$ has weight $4$ and $E_6$ has weight $6$ (citing a result not yet in the wiki: Structure Theorem for Level-One Modular Forms).
Because this is a polynomial algebra, the distinct monomials
\begin{align*}
E_4^a E_6^b
\end{align*}
are linearly independent over $\mathbb{C}$. The weight of such a monomial is
\begin{align*}
4a+6b.
\end{align*}
Therefore the weight-$k$ piece has a basis indexed exactly by pairs $(a,b)\in \mathbb{Z}_{\ge 0}^2$ satisfying
\begin{align*}
4a+6b=k.
\end{align*}
Since $k$ is even, define $n:=k/2$. Dividing the equation by $2$ gives
\begin{align*}
2a+3b=n.
\end{align*}
Thus computing the dimension of $M_k(\mathrm{SL}_2(\mathbb{Z}))$ is the same as counting the nonnegative integer solutions of this equation:
\begin{align*}
\dim_{\mathbb{C}} M_k(\mathrm{SL}_2(\mathbb{Z}))
=
\#\{(a,b)\in \mathbb{Z}_{\ge 0}^2 : 2a+3b=n\}.
\end{align*}
[/guided]
[/step]
[step:Count the nonnegative solutions of $2a+3b=n$]
For a fixed $b \in \mathbb{Z}_{\ge 0}$, the equation $2a+3b=n$ determines
\begin{align*}
a = \frac{n-3b}{2}.
\end{align*}
Thus $a$ is a nonnegative integer precisely when
\begin{align*}
0 \le b \le \left\lfloor \frac{n}{3}\right\rfloor
\end{align*}
and $n-3b$ is even. Since $3b \equiv b \pmod{2}$, the parity condition is
\begin{align*}
b \equiv n \pmod{2}.
\end{align*}
Therefore the desired dimension is the number of integers $b$ satisfying
\begin{align*}
0 \le b \le \left\lfloor \frac{n}{3}\right\rfloor,
\qquad
b \equiv n \pmod{2}.
\end{align*}
Write
\begin{align*}
k = 12q+r,
\end{align*}
where $q=\left\lfloor k/12\right\rfloor$ and $r\in\{0,2,4,6,8,10\}$, since $k$ is even. Then
\begin{align*}
n = \frac{k}{2} = 6q+\frac{r}{2}.
\end{align*}
We count the admissible values of $b$ in each residue class.
If $r=0$, then $n=6q$ and $\lfloor n/3\rfloor=2q$. The admissible $b$ are the even integers in $\{0,1,\dots,2q\}$, namely $0,2,\dots,2q$, giving $q+1$ solutions.
If $r=2$, then $n=6q+1$ and $\lfloor n/3\rfloor=2q$. The admissible $b$ are the odd integers in $\{0,1,\dots,2q\}$, namely $1,3,\dots,2q-1$, giving $q$ solutions.
If $r=4$, then $n=6q+2$ and $\lfloor n/3\rfloor=2q$. The admissible $b$ are the even integers in $\{0,1,\dots,2q\}$, giving $q+1$ solutions.
If $r=6$, then $n=6q+3$ and $\lfloor n/3\rfloor=2q+1$. The admissible $b$ are the odd integers in $\{0,1,\dots,2q+1\}$, giving $q+1$ solutions.
If $r=8$, then $n=6q+4$ and $\lfloor n/3\rfloor=2q+1$. The admissible $b$ are the even integers in $\{0,1,\dots,2q+1\}$, giving $q+1$ solutions.
If $r=10$, then $n=6q+5$ and $\lfloor n/3\rfloor=2q+1$. The admissible $b$ are the odd integers in $\{0,1,\dots,2q+1\}$, giving $q+1$ solutions.
Hence the count is $q$ exactly when $r=2$, and it is $q+1$ for all other even residues $r$ modulo $12$.
[guided]
We now solve the counting problem completely. Fix $b \in \mathbb{Z}_{\ge 0}$. The equation
\begin{align*}
2a+3b=n
\end{align*}
forces
\begin{align*}
a=\frac{n-3b}{2}.
\end{align*}
Thus, after choosing $b$, there is at most one possible value of $a$. This value is allowed exactly when two things happen: first $a\ge 0$, and second $a$ is an integer.
The inequality $a\ge 0$ is
\begin{align*}
n-3b \ge 0,
\end{align*}
which is equivalent to
\begin{align*}
0 \le b \le \left\lfloor \frac{n}{3}\right\rfloor.
\end{align*}
The integrality condition says that $n-3b$ is even. Since $3b$ has the same parity as $b$, this is equivalent to
\begin{align*}
b \equiv n \pmod{2}.
\end{align*}
So the problem is reduced to counting the integers $b$ in the interval
\begin{align*}
0 \le b \le \left\lfloor \frac{n}{3}\right\rfloor
\end{align*}
whose parity agrees with $n$.
Now write
\begin{align*}
k=12q+r,
\end{align*}
where $q=\lfloor k/12\rfloor$ and, because $k$ is even,
\begin{align*}
r\in\{0,2,4,6,8,10\}.
\end{align*}
Since $n=k/2$, we have
\begin{align*}
n=6q+\frac{r}{2}.
\end{align*}
We inspect the six possible even residues modulo $12$.
For $r=0$, the integer $n=6q$ is even and $\lfloor n/3\rfloor=2q$. Thus $b$ must be even in $\{0,1,\dots,2q\}$, giving
\begin{align*}
b=0,2,\dots,2q,
\end{align*}
so there are $q+1$ choices.
For $r=2$, the integer $n=6q+1$ is odd and $\lfloor n/3\rfloor=2q$. Thus $b$ must be odd in $\{0,1,\dots,2q\}$, giving
\begin{align*}
b=1,3,\dots,2q-1.
\end{align*}
There are $q$ choices. This is the exceptional residue class.
For $r=4$, the integer $n=6q+2$ is even and $\lfloor n/3\rfloor=2q$. Thus the admissible $b$ are again the even integers from $0$ to $2q$, so there are $q+1$ choices.
For $r=6$, the integer $n=6q+3$ is odd and $\lfloor n/3\rfloor=2q+1$. The admissible $b$ are the odd integers from $1$ to $2q+1$, so there are $q+1$ choices.
For $r=8$, the integer $n=6q+4$ is even and $\lfloor n/3\rfloor=2q+1$. The admissible $b$ are the even integers from $0$ to $2q$, so there are $q+1$ choices.
For $r=10$, the integer $n=6q+5$ is odd and $\lfloor n/3\rfloor=2q+1$. The admissible $b$ are the odd integers from $1$ to $2q+1$, so there are $q+1$ choices.
Therefore the number of nonnegative solutions of $2a+3b=n$ is $q$ when $k\equiv 2 \pmod{12}$ and is $q+1$ otherwise.
[/guided]
[/step]
[step:Translate the count back into the stated dimension formula]
Since $q=\left\lfloor k/12\right\rfloor$, the preceding count gives
\begin{align*}
\dim_{\mathbb{C}} M_k(\mathrm{SL}_2(\mathbb{Z}))
=
\begin{cases}
\left\lfloor \frac{k}{12}\right\rfloor, & k \equiv 2 \pmod{12},\\
\left\lfloor \frac{k}{12}\right\rfloor + 1, & k \not\equiv 2 \pmod{12},
\end{cases}
\end{align*}
for every even $k \ge 0$. Together with the odd-weight vanishing proved above, this proves the theorem.
[/step]