Factor out HappensBefore interface

Users should be able to plug in different implementations of the
HappensBefore interface. For example, in some models of computation
the happens-before relation may not be a partial order!