Prerequisite: Closest Vector Problem

In one dimension, decoding to the nearest multiple of b1b_1 is just rounding. In two or more dimensions, beginners often assume that once a basis is reduced (short and as orthogonal as Gauss reduction allows), Babai's polynomial-time decoding algorithms find the exact closest vector. The verified counterexample in our public math corpus (babai-counterexample) shows all three decoding behaviors diverging on one small grid.

Verify that the basis is already Gauss- and LLL-reduced

Take the 2D lattice Λ(B)\Lambda(B) generated by column vectors:

b1=[20],b2=[12],t=[11/109/10]=[1.10.9]b_1 = \begin{bmatrix} 2 \\ 0 \end{bmatrix}, \qquad b_2 = \begin{bmatrix} 1 \\ 2 \end{bmatrix}, \qquad t = \begin{bmatrix} 11/10 \\ 9/10 \end{bmatrix} = \begin{bmatrix} 1.1 \\ 0.9 \end{bmatrix}

Check reduction first: ∥b1∥2=4≤∥b2∥2=5\|b_1\|^2 = 4 \le \|b_2\|^2 = 5, and the Gram–Schmidt coefficient is μ2,1=⟨b2,b1⟩/∥b1∥2=2/4=1/2\mu_{2,1} = \langle b_2, b_1 \rangle / \|b_1\|^2 = 2 / 4 = 1/2, satisfying ∣μ2,1∣≤1/2|\mu_{2,1}| \le 1/2 with equality. No further Gauss or LLL step changes this basis! Its orthogonalized vectors are b~1=(2,0)⊤\tilde{b}_1 = (2, 0)^\top and b~2=b2−12b1=(0,2)⊤\tilde{b}_2 = b_2 - \tfrac{1}{2} b_1 = (0, 2)^\top.

Run all three methods by hand on t=(1.1,0.9)t = (1.1, 0.9)

Method 1: Babai Coordinate Rounding — returns (0,0)(0, 0)

Express tt directly in the skewed basis t=c1b1+c2b2t = c_1 b_1 + c_2 b_2 by solving Bc=tB c = t:

c2=9/102=920=0.45,c1=11/10−1⋅(9/20)2=1340=0.325c_2 = \frac{9/10}{2} = \frac{9}{20} = 0.45, \qquad c_1 = \frac{11/10 - 1 \cdot (9/20)}{2} = \frac{13}{40} = 0.325

Round both real coefficients independently: ⌊0.325⌉=0\lfloor 0.325 \rceil = 0 and ⌊0.45⌉=0\lfloor 0.45 \rceil = 0, giving vround=(0,0)v_{\mathrm{round}} = (0, 0) with squared distance 1.12+0.92=2.02=101/501.1^2 + 0.9^2 = 2.02 = 101/50. Why did c1c_1 drop below 0.50.5 even though tx=1.1>1t_x = 1.1 > 1? Because the fractional tilt 0.45⋅b20.45 \cdot b_2 stole 0.450.45 of horizontal coordinate before rounding threw c2c_2 away!

Method 2: Babai Nearest Plane — returns (2,0)(2, 0)

Nearest Plane fixes that bug by rounding top-down along orthogonal Gram–Schmidt layers and propagating the rounding decision before solving lower coordinates:

  1. Project onto b~2=(0,2)⊤\tilde{b}_2 = (0, 2)^\top: y2=⌊0.9/2⌉=⌊0.45⌉=0y_2 = \lfloor 0.9 / 2 \rceil = \lfloor 0.45 \rceil = 0 (commits to horizontal lattice layer y=0y = 0).
  2. Subtract 0⋅b20 \cdot b_2 from tt, leaving t′=(1.1,0.9)⊤t' = (1.1, 0.9)^\top, and project onto b~1=(2,0)⊤\tilde{b}_1 = (2, 0)^\top: y1=⌊1.1/2⌉=⌊0.55⌉=1y_1 = \lfloor 1.1 / 2 \rceil = \lfloor 0.55 \rceil = 1.

Output vNP=1⋅b1+0⋅b2=(2,0)v_{\mathrm{NP}} = 1 \cdot b_1 + 0 \cdot b_2 = (2, 0), cutting squared distance to (−0.9)2+0.92=1.62=81/50(-0.9)^2 + 0.9^2 = 1.62 = 81/50.

Method 3: Exact CVP — returns (1,2)(1, 2)

Why did Nearest Plane still miss? Because committing greedily to horizontal layer y=0y = 0 (vertical gap 0.90.9) ignored layer y=2y = 2 (vertical gap 1.11.1), where b2=(1,2)b_2 = (1, 2) sits almost dead-center horizontally under tx=1.1t_x = 1.1 (gap 0.10.1)! Its squared distance is 0.12+(−1.1)2=1.22=61/500.1^2 + (-1.1)^2 = 1.22 = 61/50:

AlgorithmReturned pointOffset t−vt - v∥t−v∥2\|t - v\|^2Decision region geometry
1. Coordinate Rounding(0, 0)(1.1, 0.9)101/50 = 2.02Partitions ℝ² into skewed parallelepipeds B·[-½, ½)²
2. Babai Nearest Plane(2, 0)(−0.9, 0.9)81/50 = 1.62Partitions ℝ² into axis-aligned Gram–Schmidt rectangles
3. Exact Closest Vector (CVP)(1, 2)(0.1, −1.1)61/50 = 1.22Partitions ℝ² into true hexagonal Voronoi cells

Verify exact rational distances and decision regions in Python

from fractions import Fraction

b1 = (Fraction(2), Fraction(0))
b2 = (Fraction(1), Fraction(2))
t = (Fraction(11, 10), Fraction(9, 10))

def dist_sq(p, q):
    return (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2

# 1. Coordinate rounding: solve [2, 1; 0, 2] * [c1; c2] = t
c2 = t[1] / b2[1]
c1 = (t[0] - b2[0] * c2) / b1[0]
v_round = (round(c1) * b1[0] + round(c2) * b2[0], round(c2) * b2[1])

# 2. Babai Nearest Plane: commit y2 = round(c2) first, then recompute horizontal coordinate
y2 = round(c2)
y1 = round((t[0] - b2[0] * y2) / b1[0])
v_np = (y1 * b1[0] + y2 * b2[0], y2 * b2[1])

# 3. Exhaustive CVP search over nearby integer combinations:
candidates = [(i * b1[0] + j * b2[0], j * b2[1]) for i in range(-2, 4) for j in range(-2, 4)]
v_cvp = min(candidates, key=lambda p: dist_sq(t, p))

for name, v in [("Rounding     ", v_round), ("Nearest Plane", v_np), ("Exact CVP    ", v_cvp)]:
    d2 = dist_sq(t, v)
    print(f"{name}: v={tuple(map(int, v))}, ||t - v||^2 = {d2} = {float(d2):.2f}")

Notice that Nearest Plane still satisfies Babai's worst-case guarantee: its residual lies inside the orthogonal box [−1,1]×[−1,1][-1, 1] \times [-1, 1] of half-diagonal 12+12=2≈1.414\sqrt{1^2 + 1^2} = \sqrt{2} \approx 1.414 (∥t−vNP∥=1.62≈1.273≤2\|t - v_{\mathrm{NP}}\| = \sqrt{1.62} \approx 1.273 \le \sqrt{2}). To cross the boundary between Neighboring Gram–Schmidt layers and recover (1,2)(1, 2), check multi-layer branches via Lattice Enumeration or embed tt into an SVP basis with Kannan's embedding.