I am following a proof of the next theorem, rephrased from Theorem 8.5 of the book "Introduction to the theory of differential inclusions" by Georgi V. Smirnov.
Let $\{\lambda_1,\dots,\lambda_n\}$ be eigenvalues of a constant matrix $A \in \mathbb{R}^{n\times n}$ and $X \in \mathbb{R}^{n\times n}$ be a variable in the set of symmetric matrices. Consider a linear system $XA + A^TX = 0$. It is equivalent to $Bx = 0$ where $x = (X_{11},X_{12},X_{22},\dots,X_{1n},\dots,X_{nn}) \in \mathbb{R}^{n(n+1)/2}$. Define \begin{align} C &= \{\text{all eigenvalues of $B$}\}, \\ D &= \{m_1\lambda_1 + \cdots + m_n\lambda_n \mid m_i \in \{0,1,2\},\,m_1 + \cdots + m_n = 2\}. \end{align} Then, C = D.
I understood the part $D \subset C$ but I am stuck in the part $C\subset D$. If $|D| = n(n+1)/2$, then it is obvious but in the case $|D| < n(n+1)/2$ the book says only "In the general case the result can be obtained taking the limit". Would you give me any hint or reference how to use the limit?
Edit
I hope this is a correct proof of the part $C \subset D$ that uses the limit.
Since $D\subset C$ and $|C|$ is at most $n(n+1)/2$, if $|D| = n(n+1)/2$, then $D = C$. Suppose $|D| < n(n+1)/2$. Consider a linear system $X(A + dA) + (A + dA)^TX = 0$ where $dA \in \mathbb{R}^{n\times n}$. It is equivalent to $(B + dB)x = 0$ and $\|dA\| \to 0 \Leftrightarrow \|dB\| \to 0$. Let $\{\lambda_1'(dA),\dots,\lambda_n'(dA)\}$ and $C = \{\rho_1,\dots,\rho_{n(n+1)/2}\}$ be eigenvalues of $A + dA$ and $B$, respectively. Define \begin{align} C' &= \{\rho_1'(dB),\dots,\rho_{n(n+1)/2}'(dB)\} = \{\text{all eigenvalues of $B + dB$}\}, \\ D' &= \{m_1\lambda_1'(dA) + \cdots + m_n\lambda_n'(dA) \mid m_i \in \{0,1,2\},\,m_1 + \cdots + m_n = 2\}. \end{align} Solutions of the characteristic equations $\det(A + dA - \lambda I) = 0$ and $\det(B + dB - \rho I) = 0$ are continuous functions with respect to parameters. So, for all $\varepsilon > 0$, there exists $\delta > 0$ such that $\max_i |\lambda_i'(dA) - \lambda_i| < \varepsilon$ and $\max_i|\rho_i'(dB) - \rho_i| < \varepsilon$ if $\|dA\| < \delta$ and $\|dB\|< \delta$; we assume that eigenvalues are properly listed. Also, there exists $\|dA\| < \delta$ such that all eigenvalues of $A + dA$ are distinct. Furthermore, there exists $\|dA\| < \delta$ satisfying $|D'| = n(n+1)/2$. Let $\rho \in C$. There exists $\rho' = m_1\lambda_1(dA) + \cdots + m_n\lambda_n(dA) \in C'$ such that \begin{equation} |\rho - (m_1\lambda_1 + \cdots + m_n\lambda_n)| \le |\rho - \rho'| + |\rho' - (m_1\lambda_1 + \cdots + m_n\lambda_n)| < (1 + 2n)\varepsilon. \end{equation} Since $\varepsilon$ is arbitrary, $\rho = m_1\lambda_1 + \cdots + m_n\lambda_n \in D$.