Theory of Automatic Robot Assembly and Programming