Variational principle for quasi-local algebras over the lattice