Motions of asteroids at the Kirkwood gaps: I. On the 3:1 resonance with Jupiter