Consider a simple Lie algebra $\mathfrak{g}$ which contains a subalgebra isomorphic to $\mathfrak{sl}(2,\mathbb{R})$ and its nontrivial irreducible representation $\pi:\mathfrak{g}\to\mathrm{End}(V)$. I've shown that $\pi$ is faithful. Now I'm trying to prove that the trace bilinear form $B_V$ on $\mathfrak{g}$ by $B(X,Y)=\mathrm{tr}(\pi(X)\pi(Y))$ is nondegenerate, that is, $B(X,Y)=0$ for all $Y\in\mathfrak{g}$ implies $X=0$.
I suppose one can immediately conclude that it is nondegenerate if $B_V$ is nonzero, but how to elaborate it?
Define $S:=\{X\in\mathfrak{g}\mid B(X,Y)=0,\ \forall Y\in\mathfrak{g}\}$. Let $X\in S$ and $Z\in\mathfrak{g}$. We claim that $B([X,Z],Y)=B(X,[Z,Y])$ and it immediately follows that $B([X,Z],Y)=0$. To verify it, write $[\pi(X),\pi(Z)]\pi(Y)=\pi(X)\pi(Z)\pi(Y)-\pi(Z)\pi(X)\pi(Y)$, $\pi(X)[\pi(Z),\pi(Y)]=\pi(X)\pi(Z)\pi(Y)-\pi(X)\pi(Y)\pi(Z)$, and apply the fact that $\mathrm{tr}(\pi(Z)\pi(X)\pi(Y))=\mathrm{tr}(\pi(X)\pi(Y)\pi(Z))$. Hence $[X,Z]\in S$, i.e., $S$ is an ideal of $\mathfrak{g}$.
We conclude that $\pi(S)\cong S$ since $\pi$ is faithful. It follows from Cartan's criterion (see Theorem 4.3 in Introduction to Lie Algebras and Representation Theory by Humphreys) that $S$ is solvable, i.e., $\pi(S)$ is solvable. Since $\pi$ is irreducible and $\mathfrak{g}$ is simple, $S\cong\pi(S)=0$. Thus, $B_V$ is nondegenerate.