# What does an implication implies?

When learning about logic the majority of us understand perfectly the logic behind how `and`

, `or`

and `not`

works, but not so much for `implies`

, according to a boolean table this is how implies works:

P |
Q |
P -> Q |
---|---|---|

`True` |
`True` |
`True` |

`True` |
`False` |
`False` |

`False` |
`True` |
`True` |

`False` |
`False` |
`True` |

We can see that only when *P* is `True`

and *Q* is `False`

the implication operator turns out to be `False`

, but what’s the meaning of it? how can we make sense of it?

One tip is to read implication as an `if ... then`

statement, for example:

```
If the pool is warm, then I'll swim
```

Here `P = "the pool is warm"`

and `Q = "I'll swim"`

, now, let’s start analyzing the case when *P* is `False`

, how is that *Q* being `False`

or `True`

makes the implication to always be `True`

? We seem to ignore what *Q* is, as no matter his truthiness the implication always is `True`

.

Let’s take in our heads what *P* is saying, `"the pool is warm"`

, if we know for a fact that the statement is a lie (that is the pool is **not** warm) then we must assume that whoever said this (for example Batman), is saying the truth and he will swim if the pool is warm, but as is not warm right now we can’t be sure of that, so we must believe it, if we ought to say that he is a liar then we must have a proof for that, and the statement as it is doesn’t give us enough evidence to support that conclusion. It doesn’t matter what *Q* is, if *P* is `False`

then the implication must be `True`

.

But now let’s see when we know for a fact that *P* is `True`

(that is, the pool is indeed warm), if we see that Batman is not going to swim (that is `Q`

is false) then he is a liar, because he said it, `"if the pool is warm, I'll swim"`

and Bruce ain’t swimming! so we have evidence to say that he is a liar, so the whole statement is `False`

, and we know that the water being warm, does not imply the fact that Batman will swim, he might just be bluffing.

On the contrary, if he does swim, then all it’s good, the implication turns out to be `True`

, the water is warm and he is swimming so it is true what he said to us `"if the water is warm, then I'll swim"`

, we know we can trust him.

Now when speaking about code, we see that implication is a function that always yields `True`

, unless *Q* is `False`

and *P* is `True`

, that is:

```
def implies(p, q):
if p:
return q
return True
```

But we can go further, every time an `if`

uses boolean values it means we can get rid of the `if`

:

```
def implies(p, q):
return not p or q
```

And look, an implication is just equivalent to “*!P OR Q*”, who would’ve guessed!

Now, let’s look where the implication pattern arises, take a look at this function:

```
def isEmpty(text):
if text:
return not text.stripe()
return True
```

The function is a little orthodox but you can see the same pattern, if `text`

is empty a `True`

will be returned, otherwise we check if the string doesn’t contain only of spaces and blank characters and return that check instead, we could read this as `"If text has content, then it has only blank characters"`

. In this function we see that when *P* is `True`

the result of the implication is solely determined on *Q*, and when *P* is `False`

we don’t even look the result of *Q* because we must assume that the string *“contains only blank characters… if text has content”*, we can not disprove the implication when we know for a fact that the *text* has no content.

```
def isEmpty(text):
p = text
q = not text.strip()
return not p or q
```

And for worst legibility:

```
def isEmpty(text):
return not text or not text.stripe()
```

It is important to see that in this case the second `not`

forms part of *Q*, but the first doesn’t, of course as good logician we know that due this fact, for this specific case, we could simplify further:

```
def isEmpty(text):
return not (text and text.stripe())
```

Of course this is just an example, since we could just do this instead:

`isEmpty = lambda text: not text.strip()`

But that won’t let us see what an implication implies.

That’s it!