Lie group formalism for difference equations