We study linear relations among correlation functions on a lattice obtained from integration-by-parts identities. We use the framework of twisted cocycles and determine for a scalar theory a basis of correlation functions, in which all other correlation functions may be expressed.