Categories, Logic and the Foundations of Physics