Aubry-Mather theory for functions on lattices