Propositional Logic
$\renewcommand{\implies}{\rightarrow}$ $\renewcommand{\iff}{\leftrightarrow}$
Introduction
Logic is the study of reasoning. Loosely, it is a language and set of rules that allows us to reason about what is true and what is not. For example, suppose we are told that
All men are greedy, and
Sam is a man.
From these sentences[1], using intuition and an implicit framework inside our heads, we conclude that
Therefore, Sam is greedy.
Most would agree that this is a reasonable conclusion, despite nothing about what we have written so far being mathematically precise.
The game of logic is to formalise the ability to draw such conclusions using mathematically precise rules. Now we wrote down the above sentences in English, a natural language. It turns out that natural languages are not so great for doing formal mathematics. So we need a new language, which we will call propositional logic, in which we can rewrite the above sentences. This gives us the idea of syntax. A compiler rejects malformed programs. Propositional logic is also a language, so it has its own syntax. Syntax is usually given by a set[2] of legal symbols known as the alphabet.
Syntax
Syntax tells us which sentences are legal and which are not. In programming language lingo, we often refer to legal as well formed. Natural languages also have syntax[3]. People well versed in the English language will tell you that “The dog at the” is not a well formed sentence, but the sentence “The dog ate the cat” is in fact well formed. Programming languages also have syntax. Syntax is defined by a set of symbols called the alphabet $\Sigma$, and a set of rules that tell us how to stick symbols together to make valid strings, called the grammar.
The alphabet is given by an infinite list of atomic propositions $P:=\{p_i\}_{i \in \Naturals}$, logical connectives $L:=\{\lor, \land, \neg, \implies, \iff\}$, and punctuation $\{(, )\}$.
Propositions are statements that are either true or false. Atomic propositions are meant to represent the English sentences above. The sentence “All men are greedy” can be one of the $p_i$’s in $P$. They are referred to as atomic, as we cannot further decompose the sentence into smaller propositions via the connectives (we will see what we mean by this shortly). Note that $p_i$ does not tell us whether the sentence is true or not. Truth values are a function of semantics, which we have not yet defined.
The connectives are operators that work on formulae. Their meaning will be divulged in the section on semantics, but for now you might read them as just some symbols we allow.
- The unary connective symbol $\neg$
- The binary connective symbols $\land, \lor, \implies$ and $\iff$
Punctuation is given by the parentheses symbols $($ and $)$.
Thus, the alphabet of propositional logic is given by $$ \Sigma := P \cup L \cup \{(,)\} $$
Notation: We refer to $\Sigma^* := \cup_{n\ge 1}\Sigma^n$ where $\Sigma^n$ refers to the set of strings over the alphabet of length $n$.
The grammar tells us how to stitch together symbols in the alphabet. We will write the grammar in two ways, which are equivalent. The first way is the definition we find in complexity theory textbooks, and the second is the one we see in programming languages. We start with a complexity theoretic definition of syntax $L \subseteq \Sigma^*$.
The above definition is simply giving an inductive definition. We start with the atomic propositions. Then we can apply any of the logical connectives to the propositions to get new sentences. Then we can apply logical connectives to the new sentences, and the process goes on. This exact same idea is often described in programming languages using recursive notation.
$|$ is read as or. So a formula $F$ is either an atomic proposition, or another valid formula with the logical connectives applied to it. Both definitions say the exact same things.
Remark: In these notes we will often use the words sentences and formulae interchangeably. They always refer to a string that is well formed according to the alphabet and grammar.
Example
Here are some examples of well formed sentences.
- $p, p_1 \lor p_2$
- $\neg p_1$
Some examples of malformed sentences are
- $p_1 \land$,
- $(p_1$
Semantics
Now we know how to write well formed sentences in propositional logic. So someone gives us a well formed sentence $F := ((p_1 \land p_2) \implies p_3) \iff p_4$. This is a well formed sentence, but this on its own has very little value. This is where semantics come in. Semantics give formulae or sentences meaning. Meaning in the world of propositional logic is the knowledge of whether a formula is true or false. Note we will often refer to true and false with $\top$ and $\bot$, respectively.
So how does one evaluate whether a formula $F$ is true or false?
Notice that every formula is made up of atomic propositions.
This is best understood by expressing the well formed formula $F$ with a parse tree as shown below.
All well formed formulae have unique parse trees. This is a theorem one can look up, but we skip the proof in the interest of time. The leaves of the tree are always atomic propositions. So the first step in assigning meaning to formulae is to assign meaning to the leaves. This step is often referred to as truth assignment, and is denoted with a function $$v : P \rightarrow \{\top, \bot\}$$ That is to say, give each of the leaves an assignment of either $\top$ or $\bot$, according to some truth assignment function $v$. $v$ is up to the user. Going back to our original example, whether the statement “All men are greedy” is true or not is decided by $v$. One function $v$ might set it to be true, while another $v’$ might set it to false.
Now the aim is to propagate meaning upwards. To do this, we will have to define how each logical connective assigns meaning. Before we do, we remark that the phrases assignment, interpretation, meaning all refer to the same act of assigning meaning and are used interchangeably in many books. Now, the way we define the semantics of logical connectives is via a truth table. A truth table merely lists what the output should be for every kind of input.
Not
$$ \begin{array}{c|c} F & \neg F \\ \hline \top & \bot \\ \bot & \top \end{array} $$
And
$$ \begin{array}{cc|c} F & G & F \land G \\ \hline \top & \top & \top \\ \top & \bot & \bot \\ \bot & \top & \bot \\ \bot & \bot & \bot \end{array} $$
Or
$$ \begin{array}{cc|c} F & G & F \lor G \\ \hline \top & \top & \top \\ \top & \bot & \top \\ \bot & \top & \top \\ \bot & \bot & \bot \end{array} $$
Implies
$$ \begin{array}{cc|c} F & G & F \implies G \\ \hline \top & \top & \top \\ \top & \bot & \bot \\ \bot & \top & \top \\ \bot & \bot & \top \end{array} $$
Iff
$$ \begin{array}{cc|c} F & G & F \iff G \\ \hline \top & \top & \top \\ \top & \bot & \bot \\ \bot & \top & \bot \\ \bot & \bot & \top \end{array} $$
Given any assignment of the leaves, we can just propagate the meaning using the truth tables above. These truth tables give us the complete semantics of propositional logic.
Some Common Definitions
Having defined syntax and semantics of our language, we will give some common definitions, which will make life easier as we go into more complex forms of logic. When we write a formula $F(p_1, \ldots, p_m)$, we mean $F$ is a well formed formula with atomic propositions $p_1, \ldots, p_m$ as leaves of the parse tree.
Many books also refer to tautologies as valid formulae.
Logical consequence is denoted with $\Gamma \models F$, and in many books is referred to as entailment. The phrase $\Gamma$ entails $F$ means the same thing as $F$ is a logical consequence of $\Gamma$.
For example, $p_1 \implies p_2$ is equivalent to $\neg p_1 \lor p_2$.
Formal Proofs And Deduction Rules
At this point we have a way to check if a formula over $n$ atomic propositions is true or not. Try all $2^n$ truth assignments; if the formula evaluates to true all the time, it is valid, else not. This is disappointing in two ways.
- We have to try all $2^n$ truth assignments, and this is expensive (at least computationally).
- When something is true, we do not have a good way of saying why it is true. Logic is about understanding and reasoning. So this is very unsatisfactory.
As a remedy, we come up with the idea of a formal proof system. In a formal proof system, we do not refer to any truth tables. Instead, we define a number of deduction rules. And we say that a set $\Gamma$ implies the conclusion $F$, written symbolically as $\Gamma \vdash F$.
Note that this means the definition of theorem itself carries the rules of the proof system with it. So a formula may be a theorem in one proof system, but not in another. We will discuss when this can happen when we discuss soundness and completeness. Now we describe the rules of our proof system.
Deduction Rules Of Propositional Logic
Remember that when defining semantics, we described truth tables for every logical connective. We will now write down rules for every connective, along with some additional elementary rules. For now, we will not focus on how we came up with these rules, just that these are rules someone came up with.
Mentally you can think of a proof as something you write down on paper on different lines. Each line has 3 things:
- A line number.
- A well formed formula.
- A justification.
The justification will refer to the rules, that is, I used so-and-so rule to get this formula on this line. We will do a complete example later to nail this point home.
Elementary Rules
Here $n \in \Naturals$ is the line number, $F$ is any formula in $\Gamma$, and $\mathsf{PR}$ is the justification, which here means premise. So put simply, if $F$ appears in the set of premises we can use it on any line.
Conjunction Rules
The rule $\land I$ can be read as conjunction introduction.
We can write either $F$ or $G$ or both on different lines. The rule $\land E$ can be read as conjunction elimination.
Disjunction Rules
The rule $\lor I$ is read as disjunction introduction.
Disjunction elimination is a little bit more involved. To fully describe it we need to understand what a subproof is.
So the idea is that if someone wanted to use a subproof, they have to use it as one entity as a whole. One may write down the subproof like a normal proof, and inside it we must use the same deduction rules. This is still somewhat vague, and so we introduce the example of disjunction elimination to make things more concrete.
This looks complicated, but really isn’t. What this is really saying is: suppose you have, on line $i$, the statement $F$ or $G$. Then here is what you can do: imagine you had two subproofs that both conclude $H$, and have the same assumptions, except that one includes $F$ in its assumption list, and the other uses $G$. Then, and only then, can you conclude $H$ on line $n$. The rule says that one needs both subproofs to draw that conclusion. The subproofs themselves can use any line above them, except lines inside a subproof that has already ended.
Negation And Contradiction Rules
This is the famous saying, “if my grandma had wheels, then she would be a bike”. From a false statement, we may conclude anything.
That is, we have derived a contradiction. Using the same set of premises, we have derived both $F$ and $\neg F$, which is not possible.
If we derive a contradiction assuming $F$, then we can conclude that $F$ is false, or rather that not $F$ is true.
This is nearly the same as negation introduction with the assumption flipped, and a Latin name I do not understand.
Conditional Rules
In English, if someone tells us if $F$ then $G$, and $F$ is true, we can conclude $G$.
If there is a subproof assuming $F$ and concluding $G$, then we can conclude $F \implies G$.
Bi-conditional Rules
The last set of rules is self-explanatory, given how we already understand what if and only if means.
And that is it. Those are all the deduction rules of propositional logic. Now we have two things to discuss.
- How do we use them to write a real proof?
- Why these rules? How do we know these are enough? How do we know we could do with no fewer?
We will first show a few examples next.
Example Proof
We start with a singleton premise $\Gamma := \{(p_1 \land (p_2 \lor p_3))\}$ and we want to show that it implies $((p_1 \land p_2) \lor (p_1 \land p_3))$.
This looks like a proof we would see in a maths textbook. Indeed, Eric Blais goes over the exact proof in English in his notes on formal proofs.
Soundness and Completeness
Finally, we get to trying to understand: why these rules? Actually, even before we ask why these, we could ask, what should we look for in a proof system? Now if you have any complexity theory background whatsoever, the first thing that pops out is that a proof system must be sound and complete.
We say that a proof system (its deduction rules) is complete if
This is saying if $F$ is really a logical consequence of $\Gamma$, then using our proof system we can derive $F$ from $\Gamma$.
We say a proof system (its deduction rules) is sound if
This is saying, whenever we derive $F$ from $\Gamma$, $F$ really is a logical consequence of $\Gamma$. Note that logical consequence is about the truth table (semantics). That is our definition of the truth. So for any proof system to be any good, it must reflect the truth. It can be shown that the above proof system is both sound and complete.
-
Sentences that are given to us as true are referred to as premises. So we have two premises. ↩
-
In these notes, we do not necessarily mean that a set is defined according to the ZFC axioms. It suffices to just think of it as a collection of items, as described in Chapter 1 of Naive Set Theory, by Halmos. ↩
-
Although it is not clear to me that there is one book or resource that lists all the rules. ↩