A mathematical theory of climbing