An algebraic criterion for immersion