Provably Safe Learning-Based Robot Control via Anomaly Detection and Generalization Theory