I am currently working through a proof for the spectral theorem for bounded self-adjoint operators. At one point, the following theorem is used without proof:
Let $A, B$ be two self-adjoint operators on the Hilbert space $\mathcal{H}$ with $\mathcal{D}(A) = \mathcal{D}(B)$. If $(Af,f) = (Bf,f)$ for all $f \in \mathcal{D}(A)$, it follows that $A = B$.
I only know a proof for the corresponding statement with $(Af,g) = (Bf,g)$ for general (i.e., not necessarily self-adjoint) operators $A,B$. Therefore I wanted to ask if the statement given above is actually true and if so, how it can be proven?