Foundations for algorithms