In $\mathbb{R}^n$, we say that a linear subspace is *rational* if it admits a basis in $\mathbb{Q}^n$ (or equivalently in $\mathbb{Z}^n$). This means that $E\cap \mathbb{Z}^n$ is a submodule of $\mathbb{Z}^n$ of rank equal to the dimension of the given subspace. By convention, we declare that $\{0\}$ is rational.


Now, if $E$ is any linear subspace of $\mathbb{R}^n$, we denote by $b(E)$ (*resp.* by $c(E)$) the dimension of the biggest rational subspace of $\mathbb{R}^n$ contained in $E$ (*resp.* of the smallest rational subspace of $\mathbb{R}^n$ containing $E$). 


My questions:


1) How can one compute $b(E)$ and $c(E)$? I am mainly looking for an algorithm (if it is possible). My entries for the algorithm are either a basis of $E$, or a system of equations (or any equivalent characterization). 


2) It is clear that $0\leq b(E)\leq \dim(E)\leq c(E)\leq n$. In an article, I have read that every case is possible. How can one construct examples of the different cases? I have some ideas but I am stuck in verifying because of the first question.


I would already be happy if someone can point me to a reference.



Rational subspaces
Given a matrix $M$ whose kernel is $E$, let $\{\alpha\_1, \ldots, \alpha\_k\}$ be a basis for the linear span over $\mathbb Q$ of the entries of $M$. Then $M = \sum\_{j=1}^k \alpha\_j M\_k$ where $M\_j$ are matrices with rational entries. Let $N$ be the matrix obtained by stacking the $M\_j$ vertically.  

 Any member of $E \cap {\mathbb Q}^n$ is in the kernel of $N$, while the kernel of $N$ has a basis consisting of vectors in ${\mathbb Q}^n$. Thus $b(E)$ is the dimension of the kernel of $N$.


EDIT:
In the other direction, consider the annihilator $E^\perp = \{y \in {\mathbb R}^n: y \cdot x = 0 \ \text{for all}\ x \in E\}$. Note that the annihilator of a rational subspace is rational (a basis in ${\mathbb Q}^n$ can be obtained using Gaussian elimination). It follows that the smallest rational subspace containing $E$ is the 
annihilator of the largest rational subspace contained in $E^\perp$. Thus
$c(E) = n - b(E^\perp)$.


