Propositional Logic

Part Two

Dane Hillard
Easy as Python

--

Last time you heard from me I was talking a heck of a lot about propositional logic. If you missed it, propositional logic is something I consider to be an essential building block on the way to excellent software development. It helps us understand how conditions come together into conclusions, which is the heart of what software really does under the hood. There are a few remaining pieces to this (simplified) story, which will now be fed to your brain through your eyeballs.

You likely learned about the distributive property in your middle school algebra class. The distributive rule says that a term multiplied by two or more terms in parentheses is applied to each of those terms individually. For instance:

2(3 + 4) = (2)3 + (2)4 = 6 + 8 = 14.

In propositional logic, the distributive property is similar but with one key difference — logical connectives between terms must be flipped when the distribution takes place. In other words, each term is negated and any ands become ors and vice versa. More formally:

¬(P and Q) → ¬P or ¬Q

¬(P or Q) → ¬P and ¬Q

These rules are so important to propositional logic that the name of the long-dead British man that formalized them, Augustus De Morgan, was slapped on them. De Morgan’s Laws are often useful in rearranging statements or simplifying them for ease of understanding.

There are a number of other laws dictating how grouped terms distribute, associate, and commute – other laws you learned in algebra – as well as some common patterns you can learn to recognize over time. These rules are, again, useful for simplifying complex statements and checking facts. Familiarize yourself with these.

The ultimate goal in writing about propositional logic is to give you, the reader, just enough knowledge on the subject to be able to dip your toes into programming. I think we may just be ready.

Where the possible and impossible meet.

Please follow Dane Hillard and Easy As Python to get the next installment as early as possible! More as I have it.

--

--

Publishing Python Packages 🐍📦 ⬆️ Practices of the Python Pro 🐍📘 Technical architect at ITHAKA