Deriving Dependently-Typed OOP from First Principles