  Investigations of causality in operational systems aim at providing
human-understandable explanations of why a system behaves as it does. There is,
in particular, a demand to explain what went wrong on a given counterexample
execution that shows that a system does not satisfy a given specification. To
this end, this paper investigates a notion of counterfactual causality in
transition systems based on Stalnaker's and Lewis' semantics of counterfactuals
in terms of most similar possible worlds and introduces a novel corresponding
notion of counterfactual causality in two-player games. Using distance
functions between paths in transition systems, this notion defines whether
reaching a certain set of states is a cause for the violation of a reachability
or safety property. Similarly, using distance functions between memoryless
strategies in reachability and safety games, it is defined whether reaching a
set of states is a cause for the fact that a given strategy for the player
under investigation is losing. The contribution of the paper is two-fold: In
transition systems, it is shown that counterfactual causality can be checked in
polynomial time for three prominent distance functions between paths. In
two-player games, the introduced notion of counterfactual causality is shown to
be checkable in polynomial time for two natural distance functions between
memoryless strategies. Further, a notion of explanation that can be extracted
from a counterfactual cause and that pinpoints changes to be made to the given
strategy in order to transform it into a winning strategy is defined. For the
two distance functions under consideration, the problem to decide whether such
an explanation imposes only minimal necessary changes to the given strategy
with respect to the used distance function turns out to be coNP-complete and
not to be solvable in polynomial time if P is not equal to NP, respectively.
