The Metaphysical Foundations of Logic