Second-order difference equation for Sobolev-type orthogonal polynomials: Part I: theoretical results