A Generative Theory of Problem Solving