Counterfactual reasoning via grounded distance