Causality and the transitivity of counterfactuals