It is probably a very elementary question but I cannot figure it out: my book gives a proof for the theorem that congruent matrices have the same determinant, characteristic polynomial ($\phi(X)$) and the same trace. However, I do not understand the second and third operation they conduct in the proof. How do they go from $(X \mathbb{I_n} - P^{-1}\cdot A \cdot P)$ to $(P^{-1}\cdot (X \mathbb{I_n} - A) \cdot P)$ and why is $det(P^{-1})\cdot\det(X \mathbb{I_n} - A) \cdot det(P)$ equal to $\phi_A(X)$?
Many thanks for your help in advance!
Consider two matrices $A$ and $B$ ($\in \mathbb{R^{m \times n}}$) to be congruent. If there is an invertible matrix $P$, such that $B = P^{-1} \cdot A \cdot P$, then: \begin{equation} \begin{aligned} \phi_B(X) &= det(X \mathbb{I_n} - P^{-1}\cdot A \cdot P) \\ &= det(P^{-1}\cdot (X \mathbb{I_n} - A) \cdot P) \\ &= det(P^{-1})\cdot\det(X \mathbb{I_n} - A) \cdot det(P) \\ &= \phi_A(X) \end{aligned} \end{equation}