The Foundations of Frege's Logic