A Formal Framework for Speedup Learning from Problems and Solutions