Elements of Causal Inference: Foundations and Learning Algorithms