Implication in mathematics - How can A imply B when A is False? [duplicate]
"If you stick a fork in an electrical outlet, you will get hurt."
This is true.
However, yesterday I didn't stick a fork in an electrical outlet, and then I jumped up and down on some legos for a while. Barefoot. Somehow, I still got hurt.
The formal sentence "If $A$ then $B$" is not the same as "$A$ causes $B$," or "$B$ is true if and only if $A$ is true." However, in natural language, we often do mean this (or something similar). So what's going on is that implication in formal logic - called the "material conditional" - doesn't always line up with our intuitive ideas about implication in natural language. This is indeed an issue, ranging from "annoying" to "philosophically fundamental" depending on who you talk to, and there's a lot written about it. However, within the context of formal logic, we use the material conditional.
The key here is the difference between $A \Rightarrow B$ (A implies B) and $A \Leftrightarrow B$ (A implies B and B also implies A). Consider the logical statements $A$ = "it is night" and $B$ = "I cannot see the Sun". $A$ implies $B$ here (if it's night I can't see the Sun, at least from this part of the Earth), but $B$ does not imply $A$: it could be cloudy, or an eclipse, or I could be indoors, et cetera.
The statement $A \Rightarrow B$ doesn't make any claim about whether $B$ also implies $A$. Defining it this way makes certain things a lot easier, since we can now say (e.g.) $x>7 \Rightarrow x>5$. This is a true mathematical statement ($A \Rightarrow B$) for real $x$. In other words, $A \Rightarrow B$ is true. But what if we let $x=6$? Now $B$ is true but $A$ is false; yet you'd still agree that $A \Rightarrow B$ is true. It just so happens that $A$ is false in this one case; that doesn't impact the overall truth or falsehood of $A \Rightarrow B$.
And yes, this does mean that a falsehood implies anything. "If $2+2=5$, then I am a penguin" is a true implication. This is called "Ex Falso Sequitur Quodlibet" (from a false thing, anything you want results) or the "Principle of Explosion". If you assume a contradiction (i.e. something false also being true) you can derive anything else.