Causality seems to play an important role in physics. There also seems to be a close parallel between "$P$ causes $Q$" and "if $P$ then $Q$." Mathematical logic studies logical inference; has there been any formal mathematical study of causal inference?



Has there been any mathematical study of causality?
I am converting my comments into an answer.


Setting aside the alleged parallel between causation and inference for a moment, there has indeed been some mathematical investigation of cause and effect. The Stanford Encyclopedia of Philosophy article on [causal models](https://plato.stanford.edu/entries/causal-models/) is a good starting point for reading about this topic. One of the theories mentioned there has been described in some detail in semi-popular terms in [*The Book of Why*](https://en.wikipedia.org/wiki/The_Book_of_Why) by Judea Pearl and Dana Mackenzie. This theory lies more in the domain of statistics than mathematics proper, and tries to address that perennial problem that statistical correlations do not in themselves prove causation. Pearl has also written a more technical monograph, [*Causality: Models, Reasoning, and Inference*](https://en.wikipedia.org/wiki/Causality_(book)).


Returning to the word "inference," let us note there are several interpretations of what that word means. In mathematics, the flavors that most commonly arise are the *material conditional* $P \Rightarrow Q$, which is equivalent to $(\neg P) \vee Q$, and the *provability* relation $T \vdash \phi$. Though both of these relations might superficially resemble the relation "$P$ causes $Q$," most people who have thought about the analogy have concluded that causality more closely resembles a different kind of conditional statement, namely a *counterfactual* conditional. Roughly speaking, "$P$ caused $Q$" seems akin to the statement, "If $P$ had not occurred then $Q$ would not have occurred." A counterfactual conditional is a very different beast from the material conditional. In everyday speech, the material conditional rarely comes up, except when someone half-jokingly says something like, "If Chris is a good cook then I'm the king of England!" Conditionals in everyday speech are much more likely to be counterfactual, and nowadays, counterfactuals are usually analyzed using [possible world semantics](https://plato.stanford.edu/entries/possible-worlds/) and modal logic. Again the Stanford Encyclopedia of Philosophy has a good article on [David Lewis's attempt to analyze causation in terms of counterfactuals](https://plato.stanford.edu/entries/causation-counterfactual/). Though the mathematics of modal logic is rigorous, the question of whether Lewis has successfully used it to analyze causality is a philosophical one, and is controversial.


Finally, although you might think that causality plays an essential [role in modern physics](https://en.wikipedia.org/wiki/Causality_(physics)), the truth is more subtle. The fundamental equations of physics make no explicit mention of causality, and are in fact time-reversible. Intuitively, causality involves an [arrow of time](https://en.wikipedia.org/wiki/Arrow_of_time), which is a notoriously difficult concept to explain in terms of modern physics. Causality does get mentioned sometimes in physics, e.g., in special relativity, but not in a way that suggests a direct connection with provability or the material conditional.


To summarize, while your intuition might suggest that mathematical logic should be intimately related to causality, closer inspection reveals that the relationship is not as tight as you might have expected.


