Counterfactual Planning in AGI Systems