Numerically exact diffusion coefficients for lattice systems with periodic boundary conditions. I. Theory