A generalized uncertainty principle in quantum gravity