Theory of machines