Explanation-based generalization, from Ivan Bratko's book.

This requires some fixes to copy-term in core.logic. They will be in
master shortly.