Let $A^\star:\operatorname{dom}A^\star\subseteq F^\star\to E^\star$ be the adjoint of $A$. Then $\operatorname{ker}A=(\operatorname{im}A^\star)^\perp$

I'm trying to do exercise 2.18 in Brezis' book of Functional Analysis. Could you have a check on my attempt?

Let $$(E, |\cdot|_E), (F, |\cdot|_F)$$ be Banach spaces and $$A: \operatorname{dom} A \subseteq E \to F$$ be a densely defined unbounded linear operators. Moreover, the graph of $$A$$, denoted by $$\operatorname{graph} A:= \{(x, Ax) \mid x\in \operatorname{dom} A\}$$, is closed in $$E \times F$$. Let $$A^\star: \operatorname{dom} A^\star \subseteq F^\star \to E^\star$$ be the adjoint of $$A$$. Then $$\operatorname{ker} A = (\operatorname{im} A^\star)^\perp.$$

Proof: By the construction of $$A^\star$$, we have the identity $$\langle A^\star f, x \rangle_{E^\star, E} = \langle f, Ax \rangle_{F^\star, F}, \quad \forall f\in \operatorname{dom} A^\star, x\in \operatorname{dom} A.$$

Fix $$x \in \operatorname{ker} A$$. Then $$Ax=0$$ and thus $$\langle A^\star f, x \rangle_{E^\star, E} = 0$$ for all $$f\in \operatorname{dom} A^\star$$. This in turn implies $$\langle g, x \rangle_{E^\star, E} = 0$$ for all $$g\in \operatorname{im} A^\star$$. As such, $$x \in (\operatorname{im} A^\star)^\perp$$.

Now we are going to prove the converse. Fix $$x \in (\operatorname{im} A^\star)^\perp$$, i.e., $$\langle A^\star f, x \rangle_{E^\star, E} = 0$$ for all $$f\in \operatorname{dom} A^\star$$. This implies $$\langle f, Ax \rangle_{F^\star, F} = 0$$ for all $$f\in \operatorname{dom} A^\star$$. We claim that $$Ax=0$$. Assume the contrary that $$(x, 0) \notin \operatorname{graph} A$$. By Hahn-Banach theorem, there is $$(g_1, g_2) \in E^\star \times F^\star \cong (E \times F)^\star$$ such that $$\langle g_1, z \rangle + \langle g_2, A z \rangle < \alpha < \langle g_1, x \rangle + \langle g_2, 0 \rangle = \langle g_1, x \rangle, \quad \forall z \in \operatorname{dom} A.$$

Because $$\operatorname{dom} A$$ is a linear subspace of $$E$$, we get $$\langle g_1, z \rangle + \langle g_2, A z \rangle =0$$ for all $$z \in \operatorname{dom} A$$. It follows that $$|\langle g_2, A z \rangle| = |\langle g_1, z \rangle| \le \|g_1\| |z|_E$$ for all $$z \in \operatorname{dom} A$$. Hence $$g_2 \in \operatorname{dom} A^\star$$ and thus $$\langle g_2, A x \rangle = 0$$. It follows that $$\langle g_1, x \rangle = - \langle g_2, A x \rangle = 0$$, which is a contradiction.

Update: Without $$\operatorname{graph} A$$ being closed, we still get $$\operatorname{ker} A^\star = (\operatorname{im} A)^\perp$$.

By the construction of $$A^\star$$, we have the identity $$\langle A^\star f, x \rangle_{E^\star, E} = \langle f, Ax \rangle_{F^\star, F}, \quad \forall f\in \operatorname{dom} A^\star, x\in \operatorname{dom} A.$$

Fix $$f \in \operatorname{ker} A^\star$$. Then $$A^\star f=0$$ and thus $$\langle f, Ax \rangle_{F^\star, F} = 0$$ for all $$x\in \operatorname{dom} A$$. This in turn implies $$\langle f, y \rangle_{F^\star, F} = 0$$ for all $$y\in \operatorname{im} A$$. As such, $$x \in (\operatorname{im} A)^\perp$$.

Now we are going to prove the converse. Fix $$f \in (\operatorname{im} A)^\perp$$, i.e., $$\langle f, Ax \rangle_{F^\star, F} = 0$$ for all $$x \in \operatorname{dom} A$$. Clearly, $$f \in \operatorname{dom} A^\star$$. It follows that $$\langle A^\star f, x \rangle_{E^\star, E} = 0$$ for all $$x \in \operatorname{dom} A$$. Because $$A^\star f \in E^\star$$ and $$\operatorname{dom} A$$ is dense in $$E$$, we get $$A^\star f = 0$$ and thus $$f \in \operatorname{ker} A^\star$$.