Suppose $A$ and $B$ are two real symmetric $n\times n$ matrices, $B$ is invertible and $\det(A-\lambda B)=0$ has $n$ different real roots. Prove that $A$ and $B$ can contract diagonalization at the same time, i.e. there exists a matrix $P$ such that $P^{T}AP=\operatorname{diag}(a_{1}...a_{n})$ and $P^{T}BP=\operatorname{diag}(b_{1}...b_{n})$.
Thanks for your help.
Presumably, the $P$ in your question is invertible, otherwise one may simply take $P=0$.
By the given conditions, $AB^{-1}$ has $n$ real and distinct eigenvalues $\lambda_1,\ldots,\lambda_n$. Let $u_1,\ldots,u_n$ be a corresponding eigenbasis of $AB^{-1}$ and let $v_j=B^{-1}u_j$. Then those $v_j$s are linearly independent and $AV=BVD$, where $V$ is the invertible augmented matrix $[v_1,v_2,\ldots,v_n]$ and $D=\operatorname{diag}(\lambda_1,\ldots,\lambda_n)$. Multiply both sides by $V^T$, we get $V^TAV=V^TBVD$. Therefore $V^TBV$ commutes with $D$ and in turn, it commutes with $V^TAV$.
Commuting real symmetric matrices can be simultaneously orthogonally diagonalised. So, there exists a real orthogonal matrix $Q$ such that both $Q^TV^TAVQ$ and $Q^TV^TBVQ$ are diagonal matrices. Now, take $P=VQ$ and we are done.