Local definitions of gapped Hamiltonians and topological and invertible states, I