Counterfactuals and Causability in Explainable Artificial Intelligence: Theory, Algorithms, and Applications