Speed up termination checker
Lots of duplication of work was happening, both ignoring functions
that were already known to be total, and repeating checks when arguments
not decreasing, now pruned.