TITLE: Orthogonal complement in a finite field ${\mathbb Z}^{n}_{q}$
QUESTION [10 upvotes]: When $V=\mathbb{Z}^n_q$ is a vector space, where $\mathbb Z_q$ is the set of integers modulo prime $q>2$, are the following statements true?     

If $U ⊂ V$ is a $k$-dimensional subspace, then
  $$
U^⊥= \{ x∈V∣x^Tu=0 \ \mathrm {for\ all}\ u∈U \}
$$
  is of dimension $n-k$.
(If statement 1 is true) $U^⊥$ can be written by $n-k$ orthogonal vectors.


For an example of statement 1, if $V=\mathbb{Z}^3_3$, and $U=\{ a_1(1,2,1)^T+a_2(0,1,1)^T\ |\ \forall a_1,a_2\in\mathbb Z_3\} $  then $U^⊥$ can be expressed with basis $(1,2,1)^T$.
I'm not familiar with using linear algebra in finite fields, so I don't know how I should handle "orthogonal" vectors. I wrote down some examples and am pretty sure that statement 1 holds in finite fields, as it does in real case, but I'm not so certain of statement 2. Furthermore, I don't have a clue on how to prove these statements.  
I'm not used to using English, so if there's anything wrong with my explanation, don't hesitate to ask. 
Thanks for your help!

REPLY [6 votes]: (2) is  false. For example, if $U$ is the 1D subspace $\{(0,0,0), (1,1,1)\}$ of $\mathbb{Z}_2^3$, then $U^\bot$ is the 2D subspace $\{(0,0,0), (1,1,0), (1,0,1), (0,1,1)\}$ which has no orthogonal basis. 
(1) is true. Here's a sketch without all the details.

Claim 1: Let $X$ be a vector space over a field $F$. Suppose $x_1,\ldots,x_k \in X$ are vectors, $\varphi_1,\ldots,\varphi_k \in X^*$ are functionals, and that $\varphi_i(x_j) = \delta_{ij}$, the Kronecker delta. Then, $x \mapsto \sum_{i=1}^k \varphi_i(x) x_i$ is a rank-$k$ projection with range $\operatorname{span}\{x_1,\ldots,x_k\}$ and kernel $\bigcap_{i=1}^k \ker(\varphi_i)$. In particular (e.g. by rank-nullity), $\dim(X) = k + \dim \left(\bigcap_{i=1}^k \ker(\varphi_i) \right)$.
Claim 2: Let $X$ be a vector space over a field $F$ and let $\varphi_1,\ldots, \varphi_k \in X^*$ be functionals. Then, $\varphi_1,\ldots,\varphi_k$ are linearly independent in $X^*$ if and only if  there exist $x_1,\ldots,x_k \in X$ such that $\varphi_i(x_j) = \delta_{ij}$. 

Claim 1 is quite direct. One of the implications of Claim 2 is easy, and the other implication comes from a Gramm-Schmidt type construction using Claim 1. 
Now, in your situation, the standard inner-product on $\mathbb{Z}_q^n$ can be thought of as a choice of isomorphism $\mathbb{Z}_q^n \cong (\mathbb{Z}_q^n)^*$ so that $U$ can be thought of as a subpace of $(\mathbb{Z}_q^n)^*$. Choose a basis $\varphi_1,\ldots,\varphi_n$ for $U$, note $U^\bot = \bigcap_{i=1}^k \ker(\varphi_i)$ in this instance, and apply the equality from Claim 1.