Decompose distinct

Depends on #317 , review after that one.
Can you add some comments to explain the existence of these two rules?  It isn't at all obvious why we have two rules that are each other's inverse.