Let $R$ be a commutative unital ring. Let $n\in\mathbb{N}\_+$. Consider a $n\times n$-matrix $A=(a\_{ij})\_{i,j=1}^n$ with entries in $R$. A diagonal matrix is defined obviously. We can define several notions about diagonalizability (for some prime $\mathfrak{p}\subseteq R$):


1. $A$ is *diagonalizable in $R$*: if there exists an $n\times n$-matrix $P$ with entires in $R$ such that $\det(P)\in R^\times$ and $PAP^{-1}$ is diagonal;
2. $A$ is *diagonalizable in $R\_{\mathfrak{p}}$*: consider $A$ as a matrix over $R\_{\mathfrak{p}}$ and similarly defined;
3. $A$ is *diagonalizable in $\kappa(\mathfrak{p})$*: similarly defined;
4. $A$ is *diagonalizable in $\overline{\kappa(\mathfrak{p})}$*: similarly defined, where we consider an algebraic closure.


Obviously $(1)\implies(2)\implies(3)\implies(4)$. Moreover $(4)$ has the minimal polynomial criterion. I have two observations:


* (2) is an open condition on $\mathfrak{p}$: the primes $\mathfrak{p}$ such that $A$ is diagonalizable in $R\_{\mathfrak{p}}$ form an open subset of $\mathrm{Spec}(R)$;
* (4) is a *constructible condition* on $\mathfrak{p}$: the primes $\mathfrak{p}$ such that $(4)$ holds form a constructible subset. This is seen from the morphism, whose image is where $(4)$ holds
$$\mathrm{GL}\_n\times\mathbb{A}^n\to \mathbb{A}^{n\times n},\quad P,\lambda\_1,\cdots,\lambda\_n\mapsto P\begin{pmatrix}\lambda\_1\\&\ddots\\&&\lambda\_n\end{pmatrix}P^{-1}. $$


I do not expect either $(3)\implies(2)$ or $(4)\implies(3)$, though my intuition of local diagonalizability is $(4)$. My question is about $(2)\implies(1)$. For the title I mean the following.



> 
> If $A$ is diagonalizable in $R\_{\mathfrak{p}}$ for all primes $\mathfrak{p}$, can we claim that $A$ is diagonalizable?
> 
> 
> 



Is diagonalizability a local property?
Here is a simple counterexample (simplified and generalised after Mohan's comment): let $R$ be a domain with a non-free finite projective module $P$, and let $Q$ be a finite projective module with $P \oplus Q \cong R^n$. This gives an idempotent matrix $A \in M\_n(R)$ corresponding to $(p,q) \mapsto (p,0)$.


For each prime ideal $\mathfrak p \subseteq R$, the modules $P\_{\mathfrak p}$ and $Q\_{\mathfrak p}$ are free. If $S \colon P\_{\mathfrak p} \oplus Q\_{\mathfrak p} \stackrel\sim\to R\_{\mathfrak p}^n$ is the isomorphism above and $D \colon P\_{\mathfrak p} \oplus Q\_{\mathfrak p} \to P\_{\mathfrak p} \oplus Q\_{\mathfrak p}$ the diagonal matrix $(p,q) \mapsto (p,0)$, then $A\_{\mathfrak p} = SDS^{-1}$ is diagonalisable. (We can really think of $D$ as a matrix, at least after choosing bases for $P\_{\mathfrak p}$ and $Q\_{\mathfrak p}$.)


But $A$ is not globally diagonalisable since $P$ is not free: if $A = SDS^{-1}$ for some diagonal idempotent matrix $D$ and some invertible matrix $S$, then $S$ induces an isomorphism $S \colon \operatorname{im}(D) \stackrel\sim\to \operatorname{im}(A)$. But $\operatorname{im}(D)$ is free whereas $\operatorname{im}(A) \cong P$ is not free.


**Example.** Carrying this out for $R = \mathbf Z[\sqrt{-5}]$ and $P = (2,1+\sqrt{-5}) \subseteq R$ produces the matrix
$$A = \begin{pmatrix} -2 & -1-\sqrt{-5} \\ 1-\sqrt{-5} & 3 \end{pmatrix}.$$
The image contains the vectors $\left(\begin{smallmatrix} -2 \\ 1-\sqrt{-5} \end{smallmatrix}\right)$ and $\left(\begin{smallmatrix} -1-\sqrt{-5} \\ 3\end{smallmatrix}\right)$, which are linearly dependent but not common multiples of some other vector in $R^2$.


**Motivation.** If $A\_{\mathfrak p}$ is diagonalisable for all $\mathfrak p \subseteq R$, then there exists an open cover $U\_1 \cup \ldots \cup U\_m = \operatorname{Spec} R$ such that $A|\_{U\_i}$ is diagonalisable for all $i$. This gives matrices $S\_i \in \operatorname{GL}\_n(U\_i)$ such that $D\_i := S\_i^{-1}A|\_{U\_i}S\_i$ is diagonal.


Assuming for simplicity that $R$ is a domain, we conclude in particular that all eigenvalues $\lambda\_1,\ldots,\lambda\_r$ of $A$ lie in $R$, since they lie in $R\_{\mathfrak p}$ for all prime ideals $\mathfrak p$. Choose some diagonal matrix $D \in M\_n(R)$ with the same eigenvalues/multiplicities as $A$, and assume without loss of generality that $D\_i = D|\_{U\_i}$ for all $i$. Then $S\_j^{-1}S\_i \in \operatorname{GL}\_n(U\_i \cap U\_j)$ is a matrix commuting with $D$, giving a cocycle in $H^1(\operatorname{Spec} R,G)$, where $G = C\_{\operatorname{GL}\_n}(D)$ is the centraliser of $D$. This cocycle is a coboundary if and only if $A$ and $D$ are globally conjugate matrices.


Under the additional hypothesis that $\lambda\_i - \lambda\_j \in R^\times$ whenever $i \neq j$, a straightforward computation shows $G = \prod\_{i=1}^r \operatorname{GL}\_{m\_i}$, where $m\_i$ is the algebraic multiplicity of the eigenvalue $\lambda\_i$. Thus, in this case the only obstruction is in $\prod\_{i=1}^r H^1(\operatorname{Spec} R, \operatorname{GL}\_n)$, leading to the example above.


But in general, $G$ need not be a flat group scheme over $R$, so the situation is considerably more complicated. For instance, if $D$ is the diagonal matrix $\left(\begin{smallmatrix}2 & 0 \\ 0 & 5\end{smallmatrix}\right)$, then $G \times \operatorname{Spec} \mathbf F\_3$ is the full group $\operatorname{GL}\_{2,\mathbf F\_3}$, so $G$ has a vertical component above $p=3$. Even in the case of a PID, it is not so clear to me what is going on...


**Remark.** If $R$ is no longer a domain, it is probably more natural to look at the centraliser of $A$ instead of $D$ (which is some sort of 'Zariski inner form' of $C\_{\operatorname{GL}\_n}(D)$ in the domain case, so it should have the same $H^1$). I expect there might be other global obstructions coming from the non-injectivity of the maps $R \to R\_{\mathfrak p}$: perhaps there are too many global choices of $D$ to run the argument above.


You could also imagine an obstruction in $H^1(\operatorname{Spec} R, S\_n)$ for globally ordering the eigenvalues in the matrix $D$, although all examples I know where $H^1(\operatorname{Spec} R, S\_n) \neq 1$ also have $H^1(\operatorname{Spec} R, \operatorname{GL}\_m) \neq 1$ for $m \gg 0$. (An irreducible scheme has no higher cohomology in constant sheaves, even for $H^1$ with non-abelian coefficients, so we didn't see this problem in the case above.)


