Logical Foundations of Proof Complexity