Background reading q-ary lattices

Lift the image of A

Let q = 7, A be the column (1, 2), and s = 3. With error (0, 1), the equation is b = (3, 0) modulo 7. Choose the integer lift t = (3, 7) of b. The points consistent with an equation without error form L = the set of points A·z + 7w for integer z and integer pair w, a full-rank lattice in the real plane.

A basis is (1, 2), (0, 7). These generate (7, 0) because 7(1, 2) − 2(0, 7) = (7, 0). The same lattice consists of integer pairs satisfying y ≡ 2x (mod 7). Its determinant is 7.

Plot the target and nearby points

 y / x   1  2  3  4  5
  9    ●  ·  ·  ·  ·
  8    ·  ·  ·  ●  ·
  7    ·  ·  ×  ·  ·
  6    ·  ·  ●  ·  ·
  5    ·  ·  ·  ·  ·
  4    ·  ●  ·  ·  ·
  3    ·  ·  ·  ·  ●
  2    ●  ·  ·  ·  ·

Here × is t = (3, 7). Its nearest lattice point is (3, 6). Of the four integer points at distance 1, only (3, 6) satisfies the congruence. Subtracting it recovers e = (0, 1), and its first coordinate recovers s modulo 7 in this example.

Check another lift

Use the canonical lift (3, 0) instead. Subtract (0, 7) from the target and from its nearest lattice point. The new nearest point is (3, −1), and the residual is still (0, 1). Each lift differs by a lattice vector, which translates the geometry and preserves the residual.