I'm a bit puzzled about the following considerations, and am looking for some explanations or maybe some references about it.


**Setting:** Let $E/F$ be a CM extension of number fields ($F$ being totally real) and let $(V, \langle\cdot{},\cdot{}\rangle)$ be a $n$-dimensional nondegenerate $E/F$-hermitian space (with respect to the complex conjugation $c\in\mathrm{Gal}(E/F)$), for some positive integer $n$. *Lattices* will all be of full rank.


One defines a (connected) reductive group scheme $\mathrm{U}(V)$ over $\mathrm{Spec}\,F$ by setting, for all $F$-algebra $R$, 
$$\mathrm{U}(V)(R) =\{g\in \mathrm{GL}(V\otimes\_F R);\, \langle g\cdot{}v,g\cdot{}w\rangle =\langle v,w\rangle,\, \forall v,\,w \in V\otimes\_F R\}.$$


By definition, one gets a closed immersion between (affine) $F$-group schemes $\mathrm{U}(V)\hookrightarrow \mathrm{GL}(V\_F)=\mathrm{Res}\_{E/F}\mathrm{GL}(V)$ 


Let $\tau$ denote any finite place of $F$. If $L$ is an $\mathcal{O}\_E$-lattice in $V$ (resp. an $\mathcal{O}\_{E\_{\tau}}$–lattice in $V\_{\tau}$, with $\mathcal{O}\_{E\_{\tau}}:=\mathcal{O}\_E\otimes\_{\mathcal{O}\_F}\mathcal{O}\_{F\_{\tau}}$ and $V\_{\tau}=V\otimes\_F F\_{\tau}$. 
e.g., if $\tau$ is inert in $E/F$ then $\mathcal{O}\_{E\_{\tau}}$ is just the ring of integers of the quadratic extension $E\_{\tau}=E\otimes\_F F\_{\tau}$ of $F\_{\tau}$, and $V\_{\tau}$ is the $n$-dimensional $E\_{\tau}$-vector space $V\otimes\_E E\_{\tau}$)
one defines its dual by setting
$$L^{\vee}=\{z\in V;\,\langle z, L\rangle \in \mathcal{O}\_E\}$$
(resp. $L^{\vee}=\{z\in V\_{\tau};\,\langle z, L\rangle \in \mathcal{O}\_{E\_{\tau}}\}$)


Now, take any $\mathcal{O}\_E$-lattice $L$ and assume that $L\subset L^{\vee}$ and set $N=[L^{\vee}:L]$. Take $S$ to be the finite set of finite places of $F$ containing the prime divisors of $N\mathcal{O}\_F$, and set $\mathcal{O}\_F^S$ to be the ring of $S$-integers in $F$, 
$$\mathcal{O}\_F^S=\{x\in F;\, \mathrm{ord}\_v(x)\ge 0, \, \forall v\notin S\}.$$ Away from $S$, the local lattice $L\_{\tau}:=L\otimes\_{\mathcal{O}\_E}\mathcal{O}\_{E\_{\tau}}$ is self-dual. Accordingly, the local pairing


$$\langle \cdot{},\cdot{}\rangle\_{\mathcal{O}\_{E\_{\tau}}}:\, L\_{\tau}\times L\_{\tau}\rightarrow \mathcal{O}\_{E\_{\tau}}$$ is perfect, for all $\tau\notin S$.


1. My first question. *Is the functor which goes from the category of $\mathcal{O}\_F^S$-algebras to the category of groups, and sends any $R/\mathcal{O}\_F^S$ to the group
$$\underline{\mathrm{U}}\_V(R):=\{g\in \mathrm{GL}(L\otimes\_{\mathcal{O}\_F}R);\, \langle g\cdot{}v,g\cdot{}w \rangle=\langle v,w \rangle\in\mathcal{O}\_E\otimes\_{\mathcal{O}\_F}R, \,\forall v,\,w\in L\otimes\_{\mathcal{O}\_F}R\}$$
(whose restriction to $F$-algebras coincides with $\mathrm{U}(V)$), representable by a smooth $\mathrm{Spec}\,\mathcal{O}\_F^S$-group scheme $\underline{\mathrm{U}}\_V$, such that $\underline{\mathrm{U}}\_V\times\mathrm{Spec}\,F\simeq \mathrm{U}(V)$ ?
Moreover, are the fibers $(\underline{\mathrm{U}}\_V)\_v$ of $\underline{\mathrm{U}}\_V$ at $v$ already reductive for all $v\notin S$, or do we possibly need to enlarge $S$ ?*


On the other hand, a more general construction related to reductive groups is described (for instance) in Chapter II of Getz-Hahn's book *An Introduction to Automorphic Representations with a view toward Trace Formulae*, whose online version can be found on this page <https://services.math.duke.edu/~hahn/Chapter2.pdf>


Namely, one may apply their Lemma 2.4.2 in the following way: the choice of $L$ defines an integral model $\mathrm{GL}(V)\_{\mathcal{O}\_F}$, namely, whose $R$-points are given by $\mathrm{GL}(L\otimes\_{\mathcal{O}\_F}R)$ for any $\mathcal{O}\_F$-algebra $R$, hence one has a composition of closed immersions
$$\mathrm{U}(V)\hookrightarrow \mathrm{GL}(V\_F)\hookrightarrow \mathrm{GL}(V)\_{\mathcal{O}\_F}.$$


By setting $\underline{\mathrm{U}}\_V\subset \mathrm{GL}(V)\_{\mathcal{O}\_F}$ to be the Zariski closure of $\mathrm{U}(V)$ in $\mathrm{GL}(V)\_{\mathcal{O}\_F}$, then there exists a finite set $S'$ of finite places of $F$, such that $(\underline{\mathrm{U}}\_V)\_{\mathcal{O}\_F^{S'}}$ is a smooth $\mathcal{O}\_F^{S'}$-group scheme which is a model for $\mathrm{U}(V)$. 


Then, for its generic fiber $\mathrm{U}(V)$ is already reductive, one may apply Proposition 3.1.9 of Conrad's *Reductive group schemes* paper (using a so-called "spreading out" argument) to deduce that the fibers of $(\underline{\mathrm{U}}\_V)\_{\mathcal{O}\_F^{S'}}$ are reductive outside a finite number of places, i.e., that there exists a finite set $S''$ of finite places of $F$ containing $S'$ and such that $(\underline{\mathrm{U}}\_V)\_{\mathcal{O}\_F^{S''}}$ has reductive fibers.


2. My second question. *Is the above construction strictly equivalent to the (more explicit but less general) previous one ? Assuming the previous construction works with $S$, how can one compare $S$ and $S''$ in general ?*


**EDIT**: One of the aims behind my question is to convince myself of the link between the notion of an hyperspecial maximal compact subgroup $K\_{\tau}$ of $\mathrm{U}(V)(F\_{\tau})$ on the one hand (which arises as the $\mathcal{O}\_{F\_{\tau}}$-points of my almost-everywhere reductive model obtained by the second construction), and the notion of stabilizer of a self-dual local $\mathcal{O}\_{E\_{\tau}}$-lattice (which arises as the $\mathcal{O}\_{F\_{\tau}}$-points of the expected model obtained by the first construction). 


Many thanks for any kind of help, and please don't hesitate to relocate this question to Stackexchange if you feel it's not advanced enough.


Yoël.



Global integral model for unitary groups
Regarding the second part of question 1, which is what the fibres of the integral model given by a choice of L will look like: you might find the paper of Gan, Hanke and Yu, [On an exact mass formula of Shimura](http://www.math.nus.edu.sg/~matgwt/Mass.pdf), helpful. They assume that $L$ is *maximal* -- i.e. there is no larger lattice $L' \supsetneq L$ such that $\langle x, x \rangle \in \mathcal{O}\_F$ for all $x \in L'$ -- and for such lattices they describe what the resulting group scheme (the thing you call $\underline{U}(V)$) looks like locally at the bad places. (It's not always reductive, but they describe its maximal reductive quotient explicitly). 


