The dual lattice is:

L={xRnvL.x,vZ}={xRnvL.x,v0(modZ)} \begin{align} \Ldual &= \left\{ \vx \in \RR^n \mid \forall \vv \in \Lat. \ip{\vx}{\vv} \in \ZZ \right\} \\ &= \left\{ \vx \in \RR^n \mid \forall \vv \in \Lat. \ip{\vx}{\vv} \equiv 0 \pmod{\ZZ} \right\} \end{align}

Spiritually, it serves a very similar role to the orthogonal complement for linear spaces:

S={xRnvS.x,v=0} \Sperp = \left\{ \vx \in \RR^n \mid \forall \vv \in \Sspace. \ip{\vx}{\vv} = 0 \right\}

The difference accounts for the “discrete” structure of lattices vs the continuous nature of linear subspaces:

  1. Lattices have full rank over R\RR, hence L={0}\Lperp = \{0\} is uninteresting.
  2. Lattices require integer combinations and so we need to capture that instead somehow.

Orthogonal Complements

The reason why the orthogonal complement is useful, is that it in some ways captures “everything outside” the original space S\Sspace, i.e. the “complement space”, everything else.

Because the world is made of everything inside a space, and everything outside of it, with nothing in-between, Rn=SS\RR^n = \Sspace \oplus \Sperp, to check that some xRn\vx \in \RR^n is in S\Sspace, you can check that it has no “component” in S\Sperp, by “measuring” it with ,v\langle \cdot, \vv \rangle for every v\vv in the dual S\Sperp, i.e. check that it is orthogonal to the orthogonal complement of S\Sspace:

xS    vS.x,v=0 \vx \in \Sspace \iff \forall \vv \in \Sperp. \ip{\vx}{\vv} = 0

And instead of checking against all of S\Sperp you can check against a basis B\Bp for S\Sperp:

xS    i.x,bi=0 \vx \in \Sspace \iff \forall i. \ip{\vx}{\Bpi{i}} = 0

This is advantageous, because, for instance, testing membership of S\Sspace otherwise requires Gaussian elimination, which takes cubic time.

Additionally, the complement dual basis also allows checking if you are almost in the space S\Sspace, by checking that you are almost not in the dual S\Sperp, i.e. part of x\vx which is in S\Sperp is small: if x,bi\ip{\vx}{\Bpi{i}} is small, relative to x,bi\nrm{\vx}, \nrm{\Bpi{i}} then you are almost orthogonal to every vector in the complement space, which means that if you write x\vx in the basis B,B\Bas, \Bp (which span the whole space):

x=Bc+BcRn \vx = \Bas \vc + \Bp \vcp \in \RR^n

Then the coefficients c\vcp of B\Bp are small, so see this:

x,bj=icibi,bj+icibi,bj=icibi,bj \ip{\vx}{\Bpi{j}} = \sum_i c_i \ip{\Bi{i}}{\Bpi{j}} + \sum_i c^\perp_i \ip{\Bpi{i}}{\Bpi{j}} = \sum_i c^\perp_i \ip{\Bpi{i}}{\Bpi{j}}

If the complement basis B\Bp is also orthogonal, i.e. bi,bj=0\langle \Bpi{i}, \Bpi{j} \rangle = 0 for all iji \neq j, then:

x,bj=cjbj,bj=cjbj2 \ip{\vx}{\Bpi{j}} = c^\perp_j \cdot \ip{\Bpi{j}}{\Bpi{j}} = c^\perp_j \cdot \nrm{\Bpi{j}}^2

So if the vectors in B\Bp “small” and (almost) orthogonal, then so is e=BcRn\ve = \Bp \vcp \in \RR^n, which means x=Bc+e\vx = \Bas \vc + \ve lies close to S\Sspace: by the triangle inequality, Bcicibi\nrm{\Bp \vcp} \leq \sum_i |c^\perp_i| \cdot \nrm{\Bpi{i}}.

Remember: this requires B\Bp to have short vectors, sounds familiar?

Dual Lattices

The same intuition applies to the dual of a lattice:

xL    vL.v,xZ \vx \in \Lat \iff \forall \vv \in \Ldual. \ip{\vv}{\vx} \in \ZZ

Again, you don’t need to check all of L\Ldual, a basis D\Bd for L\Ldual suffices:

xL    i.x,diZ \vx \in \Lat \iff \forall i. \ip{\vx}{\Bdi{i}} \in \ZZ

Again, nice, because it makes checking if you are in a lattice easy. In a vector space, every basis is more/less interchangeable: you can simply rescale the basis elements to make them “short” without it affecting the vector space. That is, famously, not the case for lattices: some bases are nicer than others and you can’t easily make a “bad basis” with:

  • Large vectors, very “skewed” vectors.

Into a “nice basis” with:

  • Short vectors, almost orthogonal vectors.

The good/bad distinction is exactly the same that decides if the basis B\Bp of the orthogonal complement S\Sperp able to test “proximity” to the space S\Sspace or not: there we also needed a “good basis”, but producing a “good basis” for a linear space is trivially easy because of its continuous nature (which enables Gaussian elimination). Completely analogously, the following is true: x,di\ip{\vx}{\Bdi{i}} is almost an integer (i.e. small in R/Z\RR / \ZZ) if x\vx is close to the lattice L\Lat as long as D\Bd has short vectors.

To see this, let xL\vx \in \Lat, vL\vv \in \Ldual and let e\ve be “small/short”, then:

x+e,v=e,v+x,v=e,v+k \ip{\vx + \ve}{\vv} = \ip{\ve}{\vv} + \ip{\vx}{\vv} = \ip{\ve}{\vv} + k

Where kZk \in \ZZ.

By Cauchy–Schwarz, e,vev|\ip{\ve}{\vv}| \leq \nrm{\ve} \cdot \nrm{\vv}. Now e\ve is short, i.e. x+e\vx + \ve is close to a lattice point, but when is v\nrm{\vv} short for the basis vectors v\vv of D\Bd?

If we have a good basis B\Bas for L\Lat, where the basis elements are almost orthogonal, i.e. bi,bj\ip{\Bi{i}}{\Bi{j}} is small whenever iji \neq j, then we can also get a good basis for the dual lattice i.e. every dj\nrm{\Bdi{j}} is as short as it can be, namely 1/bj\approx 1 / \nrm{\Bi{j}}.

The Dual Basis

The dual lattice for L(B)\Lgen{\Bas} has basis D\Bd with the property that:

di,bj=δij={1i=j0ij \ip{\Bdi{i}}{\Bi{j}} = \delta_{ij} = \begin{cases} 1 & i = j \\ 0 & i \neq j \end{cases}

    \implies: Anything in L(D)\Lgen{\Bd} lies in L\Ldual:

Since every vL(B)\vv \in \Lgen{\Bas} is an integer combination of B\Bas and every xL(D)\vx \in \Lgen{\Bd} is an integer combination of D\Bd.

    \impliedby: Conversely, anything that lies in L\Ldual also lies in L(D)\Lgen{\Bd}:

Let xL\vx \in \Ldual, we can write x\vx in the basis D\Bd since it has full rank over Rn\RR^n.

x=iaidi \vx = \sum_i a_i \cdot \Bdi{i}

For some aRn\va \in \RR^n. We can then consider:

x,bj=iaidi,bj=aj \ip{\vx}{\Bi{j}} = \sum_i a_i \cdot \ip{\Bdi{i}}{\Bi{j}} = a_j

Since xL\vx \in \Ldual, we have vL(B).v,xZ\forall \vv \in \Lgen{\Bas}. \ip{\vv}{\vx} \in \ZZ, but bj\Bi{j} is also clearly in L(B)\Lgen{\Bas} so by letting v=bj\vv = \Bi{j} we see that aja_j is actually an integer and we just wrote x\vx as an integer combination of D\Bd.

Finding D\Bd

The dual basis D\Bd pairs one-to-one with the basis elements in B\Bas: if you fix n1n-1 vectors b1,,bj1,bj+1,,bn\Bi{1}, \ldots, \Bi{j-1}, \Bi{j+1}, \ldots, \Bi{n} in Rn\RR^n, and require that a vector dj\Bdi{j} is orthogonal to all of them, that fixes a unique direction for dj\Bdi{j}, the condition dj,bj=1\langle \Bdi{j}, \Bi{j} \rangle = 1 then fixes the length of dj\Bdi{j}.

So when is dj\Bdi{j} short?

Observe that dj,bj=1\langle \Bdi{j}, \Bi{j} \rangle = 1 does not imply that either dj\Bdi{j} or bj\Bi{j} are short, just that dj\Bdi{j} is short in the bj\Bi{j} direction, in particular, if they point in very different directions both may be long, while dj,bj\langle \Bdi{j}, \Bi{j} \rangle stays 1.

Figure 1
$\ip{\vx}{\Bi{j}} = 1$
$\nrm{\Bi{j}} =$0.00 $\nrm{\Bdi{j}} =$0.00 angle $=$0 $\ip{\Bdi{j}}{\Bi{j}} =$1.00

If we subtract from each bj\Bi{j} its projection onto the span of the other bi\Bi{i}:

bj=bjProjb1,,bj1,bj+1,,bn(bj) \Bi{j}' = \Bi{j} - \mathsf{Proj}_{\Bi{1}, \ldots, \Bi{j-1}, \Bi{j+1}, \ldots, \Bi{n}}\left(\Bi{j}\right)

Then we get bj\Bi{j}', and we define the “height” of bj\Bi{j} above the n1n-1 dimensional basis b1,,bj1,bj+1,,bn\Bi{1}, \ldots, \Bi{j-1}, \Bi{j+1}, \ldots, \Bi{n} as hj=bjh_j = \nrm{\Bi{j}'}.

Since dj\Bdi{j} is orthogonal to every bi\Bi{i} with iji \neq j, it is orthogonal to their entire span, which leaves exactly one line for it to live on: the line through bj\Bi{j}'. Hence dj=λbj\Bdi{j} = \lambda \cdot \Bi{j}' for some λR\lambda \in \RR, and since bjbj\Bi{j} - \Bi{j}' lies in the span of the other basis vectors it is orthogonal to bj\Bi{j}':

1=dj,bj=λbj,bj=λbj2 1 = \ip{\Bdi{j}}{\Bi{j}} = \lambda \cdot \ip{\Bi{j}'}{\Bi{j}} = \lambda \cdot \nrm{\Bi{j}'}^2

Which pins down λ\lambda, and with it the length of dj\Bdi{j}:

dj=1bj=1hj \nrm{\Bdi{j}} = \frac{1}{\nrm{\Bi{j}'}} = \frac{1}{h_j}

So dj\Bdi{j} is short exactly when bj\Bi{j} is almost orthogonal to the other basis vectors: subtracting the projection only ever shortens the vector, so hjbjh_j \leq \nrm{\Bi{j}}, with equality if and only if bj\Bi{j} is orthogonal to all the others:

djbj=bjhj1 \nrm{\Bdi{j}} \cdot \nrm{\Bi{j}} = \frac{\nrm{\Bi{j}}}{h_j} \geq 1

For a fixed lattice, det(L)=detB\det(\Lat) = \left| \det \Bas \right| is the same for every basis and det(L)jbj\det(\Lat) \leq \prod_j \nrm{\Bi{j}}, so the lengths cannot all be made small. B\Bas is in turn the dual basis of D\Bd, so the height of dj\Bdi{j} above the other dual vectors is 1/bj1 / \nrm{\Bi{j}}.

Written with the basis vectors as columns, the inner products di,bj\ip{\Bdi{i}}{\Bi{j}} are the entries of DB\Bd^\top \Bas, so we can write the relation between the dual and the original basis as:

DB=I    D=(B1) \Bd^\top \Bas = I \iff \Bd = \left(\Bas^{-1}\right)^\top

Bonus: Decode with The Dual

Let x=v+e\vx = \vv + \ve with vL\vv \in \Lat and e\ve short, then by Cauchy–Schwarz:

x,dj=v,dj+e,djwheree,djedj=ehj \ip{\vx}{\Bdi{j}} = \ip{\vv}{\Bdi{j}} + \ip{\ve}{\Bdi{j}} \quad \text{where} \quad \left| \ip{\ve}{\Bdi{j}} \right| \leq \nrm{\ve} \cdot \nrm{\Bdi{j}} = \frac{\nrm{\ve}}{h_j}

Where the first term is an integer, in fact a very particular one: for v=icibi\vv = \sum_i c_i \cdot \Bi{i} with cZn\vc \in \ZZ^n:

v,dj=icibi,dj=icibi,dj=cj \ip{\vv}{\Bdi{j}} = \ip{\textstyle\sum_i c_i \cdot \Bi{i}}{\Bdi{j}} = \sum_i c_i \cdot \ip{\Bi{i}}{\Bdi{j}} = c_j

Which is the jj-th coefficient of v\vv in the basis B\Bas.

Hence if e<hj/2\nrm{\ve} < h_j / 2 for every jj, then every x,dj\ip{\vx}{\Bdi{j}} lies within 1/21/2 of an integer and rounding it to the nearest integer recovers cjc_j, i.e. recovers v\vv itself. This is Babai’s rounding algorithm, and the radius it is guaranteed to decode is:

12minjhj=12maxjdj \frac{1}{2} \cdot \min_j h_j = \frac{1}{2 \cdot \max_j \nrm{\Bdi{j}}}