Anomaly cancelation in field theory and F-theory on a circle