Fix the occurrence analyser's interaction with local RULES for imported Ids
Ticket #18603 (closed) demonstrated that the occurrence analyser's handling of
local RULES for imported Ids
(which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker.
The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions]
This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think.
Oh, and it fixes the bug.