Propositional Logic I: Operational propositional logic

Introduction to propositional logic: propositional variables, boolean functions, propositional logic operations

We would like an "algebra" for logical reasoning, as opposed to arithmetic reasoning. Put another way, what algebra does for reasoning about numbers, we want to do for reasoning about true/false values. This is called propositional logic (or boolean logic).

Note: we will typically use {true,false} as the set of boolean values. However, we will freely switch to {T,F} or to {1,0} and you are going to have to be able to roll with it. So true/T/1 are the "true" values, and false/F/0 are the "false" values.

In algebra, a variable stands for a number. In propositional/boolean logic a variable stands for a true/false value.

A propositional variable (also called a boolean variable) is a variable that takes on only the values true or false.

Note: We will purposely use both terms!! The world does!

In algebra, the basic operations are +, -, *, /, and - for negation, as in "$-x$". These are functions, though they might not look like it. When we write "$x*y$", it means "$\text{mult}(x,y)$". We write these as operators for historical reasons and because it's more convenient for human manipulation. (Note: there are, in fact, programming languages that explicitly write these arithmetic operators as functions!) In propositional/boolean logic we have as basic operations "not", "and", "or" and some others. They are functions too, but they are what are called boolean functions, i.e. their inputs are boolen values and their output are boolean values:

A boolean function is a function for which all inputs are boolean-valued and the output is boolean-valued.

Since the boolean operators are functions, we can talk about their domains and ranges. Unlike arithmetic operators for the integers or reals, the domains and ranges of the boolean operators are finite, and that allows us to specify these functions completely by tables. You should be used to looking at tables of function values from high school. They typically gave some values of the function, because with integer or real inputs there are infinitely many possible input values. For boolean functions, however, we can list all input values with their associated outputs in a finite table. For boolean functions, we call these truth tables.

The standard operations in propositional logic (also called boolean operators) are:

not and or implication equivalence exclusive or
Note: A row in a truth table describes an output value (the last entry) for given input value(s) (the other entries). So the last column is for outputs, the other columns are for inputs.

There are different notations for these operations. We will use the standard notation (as shown below), but in circumstances where you are entering expressions using only ASCII values, we have another set of notation.

operator
name
standard
notation
SI242 ASCII
notation
C/C++/Java
notation
not¬~!
and&&&
or|||
implies=>n/a
equivalence<=>==
xorxor^

[In Computer Architecture you will have a different notation (+ for "or", an overline bar for "not", and variables/parethisized-expressions sitting next to one another, like we do with multiplication in algebra, for "and"). You'll have to be flexible enough to adapt!]

If the idea that $a \Rightarrow b$ is true when $a=false$, regardless of what b is, seems strange, here's one way to think about it. Suppose you promise your friend "if Navy beats Army, then I will treat you to dinner". In other words NavyBeatsArmy => DinnerOnMe. Suppose Navy loses. To keep your word, do you have to treat them to dinner? Would you fail to keep your word if you did? Clearly the answer is no in both cases. If Navy loses, you keep your word no matter what you do. In fact, the only way to fail to keep your word is for Navy to win and you to not treat your friend to dinner. So the implication is satisfied in all cases, except when the left hand side is true, and the right hand side is false.

Important: A truth table is nothing more than a table that lists the values of a boolean function for every possible combination of values for the inputs. The convention in this class will be to list the rows in lexicographic order, i.e. dictionary order. So false comes before true. When there are multiple arguments, you find the left-most position in which two inputs differ to make your decision. This order is particularly nice because, if you use 0 for false and 1 for true, the input values for each row list the binary numbers in increasing order starting from zero.

To find the value of an application of a propositioinal logic operator, you just look it up in the table. So, for example, to determine the value of "false⇔false", I look at the row in the ⇔-table where a and b are both false (first row), and see that the final column has "true", which means the the value of the expression is "true".

ACTIVITY (worksheet)
What is the value of ...

  1. false∧true is ...
  2. true⊕false is ...
  3. false⇒false is ...
  4. Consider the following truth table for mystery operator X: What is the value of "true X false"? How about "true X true"?
  5. Important: an operator is called a unary operator if it takes only one argument (like $\neg$) and a binary operator if it takes two (like ∧, ⊕, etc).
    Problem:
    1. How many different unary operators are there? (Regardless of whether we've given them names!) Prove it! (i.e. convince me).
    2. How many different binary operators are there? (Regardless of whether we've given them names!) Prove it! (i.e. convince me).

    A note on proof
    "Proof" is going to be an important topic of this course; one that runs as a thread through everything we do. Perhaps the most basic form of proof is what we might call "Proof by calculation". You've been doing this in algebra for years already. If someone asks you to prove that 15% of 88.30 is greater than 12.50, you would simply show them the calculation .15*88.30 = 13.2450 > 12.50. The point is that this kind of caclulation is so basic, that we all consider it to be self-explanatory. I could do it myself if I didn't want to take your word for it. It will be the same for propositional logic. Each of these calculations like "false⇔false evaluates to true" is a proof of a result. A boring proof, but there you go. It's "boring" because it is a one step proof with the justification always being "because that's what the table in the definition says". It's important to recognize what's going on here, though, because the idea that we always bottom out with "because that's what the definition says" is important. When we get an proof down to that level, there is no arguing and no room for disagreement ... unless you can't agree on what the definition actually is. In mathematics, this shouldn't happen often. In life, however, this happens very often.

Propositional formulas

In algebra we distinguish between expressions, like $3x^2 - x^2 - 1$, and equations, like $3x^2 - x^2 - 1 = 0$. The difference is in their types. An expression like $3x^2 - x^2 - 1$, when evaluated at a particular $x$ value, results in a number. An equation like $3x^2 - x^2 - 1 = 0$, when evaluated at a particular $x$ value, results in a true/false value.

In propositional logic, there is no such distinction, and no need for the equals sign. A propositional formula like $a \wedge (\neg b \vee c)$ evalutes to a true/false value already, so there is no need for equals signs, and no need to distinguish between expressions and equations!

Propositional logic gets interesting when we combine multiple logical operators to produce something more more complicated. Such combinations are called formulas. This really works exactly like you'd expect given your experience in algebra with combining arithmetic operators in expressions like $x \cdot (-y + 2)$. For example, you probobly have an intuitive understanding of what the formula $a \wedge (\neg b \vee c)$ means, in the sense that you could evaluate it if I told you what values to give $a$, $b$ and $c$. [If $a,b,c$ are true,true,false, what would the formula evaluate to?]

However, we are going to want to prove things about formulas (and maybe even give algorithms to compute with formulas) and that requires formally defining the term. Our previous definitions (boolean variable, boolean function and propositional logic operators) hopefully just plain made sense. They are very simple definitions. Formulas are more difficult to define, because formulas are made up of formulas, which are in turn made up of formulas, etc. To define this sort of thing we need a recursive definition. We'll state it here, and hopefully it'll make sense.

A propositional formula is defined by the following rules:
  1. Propositional variables are propositional formulas
  2. If $A$ is a propositional formula, $\neg(A)$ is a propositional formula.
  3. If $A$ and $B$ are propositional formulas and $\mbox{op}$ is a binary propositional operator, then $(A)\mbox{op}(B)$ is a propositional formula.
  4. Nothing else is a propositional formula.
Note: This definition does not allow for the constants true/false. In practice, we will sometimes allow them.

With this definition, we can prove that, for example, $(a)\wedge((\neg(b))\vee (c))$ is a propositional formula. Let's see how that works.

$F := (a)\wedge\left((\neg(b))\vee (c)\right)$ is a propositional formula.
Since this is our first "real" proof, we will make the steps explicit by putting them in a bulleted list.
  • Since $\wedge$ is a propositional operator, and $F$ is $(a)\wedge\left((\neg(b))\vee (c)\right)$, by Point 3 of the definition, we can deduce that $F$ is a propositional formula if we can show that $a$ and $(\neg(b))\vee (c)$ are propositional formulas, which we do below.
  • By Point 1 of the definition, $a$ is a propositional formula.
  • Since $\vee$ is a propositional operator, we can deduce that $(\neg(b))\vee (c)$ is a propositional formula by Point 3 of the definition if we can show that $\neg(b)$ and $c$ are propositional formulas, which we do below.
  • By Point 2 of the definition, we can deduce that $\neg(b)$ is a propositional formula if we can show that $b$ is a propositional formula, which we do below.
  • By Point 1 of the definition, $b$ is a propositional formula.
  • By Point 1 of the definition, $c$ is a propositional formula.
That completes the proof, which we usually mark with ...

Note: If you want to prove that something "is an X", the typical approach is to got back to the definitions of "X" and show, point by point, that the "something" you have meets those requirements. That's precisely what we've done with the above proof.

Importantly, to prove that $F$ is a propositional formula required us to turn around and prove that smaller pieces are propositional formulas. This is the essence of a recursive definition: $F$ is a propositional formula because something smaller is a propositional formula, which is because something even smaller is a propositional formula ... it looks like it's turtles all the way down. However, if you look closely, you see that this process always bottoms out at Point 1 of the definition (variables are propositional formulas) which is not "recursive". This is called the "base case" of the definition. We will have more to say about recursive definitions in the future!

Expression Trees

Obviously, the proof from the previous section is ultra painful. Let's never do that again. If you look at the structure of the proof, you'll see that there's an obvious hierarchy to it. At the top level is proving that $F$ is a propositional formula. At the next level is proving $a$ is a formula, and proving $(\neg(b))\vee (c)$ is a propositional formula, and so on. We can represent this visually in what's called an expression tree. You should be able to match the six bullets in the proof with the six nodes in the expression tree (top-to-bottom, left-to-right). So, in essence an expression tree is a concise representation of the proof that a given sequence of characters is a propositional formula. The parentheses in the sequence of characters show you how to write it as an expression tree. Therefore, from now on we can prove that a given sequence of characters is indeed a propositional formula simply by drawing the expression tree.

Important: Remember, an expression tree is a concise representation of the proof that a sequence of characters is a propositional formula. So if you are asked to prove that something like $\neg((a)\Rightarrow (b))$ is a propositional formula ... just draw its expression tree.

ACTIVITY

  1. Draw the expression tree for $((\neg(a))\Rightarrow (b)) \Leftrightarrow ((a)\vee (b))$
  2. Write down the formula represented by the expression tree:
  3. Prove that $\neg(\neg((\neg(a))\vee (b)))$ is a propositional formula.
  4. Why is $(a)\neg(b)$ not a propositional formula?
  5. Why is $(\wedge)\vee(a)$ not a propositional formula?
  6. Is $x_1$ a propositional formula? Justify!

Note: For every propositional formula there is a unique expression tree, and for every expression tree a unique propositional formula.

Order of operations: enough of the parentheses already!

Would you write (36+(2*x))-(7*y)? No! You write 36 + 2*x - 7*y. What allows us to do that and still be unambiguous? Order of operations! We'll do the same thing with propositional logic. This is the *language of propositional logic*, just like we have a well-understood lanugage for algebra. The order of operations and leaving out parentheses is just a convenient short-hand, so we don't all go nuts! It is just like arithmetic and algebra. It is also just a like a programming language! So we will define precedence and associativity just as we would for a programming language, with table! Here are the precedence and associativity levels from highest to lowest:

level operator(s) associativity
1$\neg$N/A
2$\wedge$left-to-right
3$\vee,\Rightarrow,\oplus$left-to-right
4$\Leftrightarrow$left-to-right

Of course we use ( )s to get around the precedence/associativity rules or even if we just want to be clearer. The goal here is that we can write a formula without tons of parentheses and still have a unique associated expression tree.

ACTIVITY

  1. Draw the expression tree for $a \Rightarrow b \Rightarrow c$. Note: you might want to put in the parentheses first!
  2. Draw the expression tree for $a \Rightarrow b \wedge c \Rightarrow d$. Note: you might want to put in the parentheses first!
  3. Draw the expression tree for $\neg a \Rightarrow b \Leftrightarrow a \vee b$
  4. Write down the formula represented by the expression tree below without any unnecessary ( )s:


Christopher W Brown