Propositional Logic
(Content adapted from Critchlow & Eck)
Propositions
A proposition is a statement which is either true or false. In propositional logic, we take propositions as basic and see what we can do with them. Since this is mathematics, we need to be able to talk about propositions without saying which particular propositions we are talking about, so we use symbolic names to represent them. We will always use lowercase letters such as , , and to represent propositions. A letter used in this way is called a propositional variable. Remember that when I say something like "Let be a proposition," I mean "For the rest of this discussion, let the symbol stand for some particular statement, which is either true or false (although I am not at the moment making any assumption about which it is)." The discussion has mathematical generality in that can represent any statement, and the discussion will be valid no matter which statement it represents.
Operators: And, Or, Not
What we do with propositions is combine them with logical operators. A logical operator can be applied to one or more propositions to produce a new proposition. The truth value of the new proposition is completely determined by the operator and by the truth values of the propositions to which it is applied.1 In English, logical operators are represented by words such as "and," "or," and "not." For example, the proposition "I wanted to leave and I left" is formed from two simpler propositions joined by the word "and." Adding the word "not" to the proposition "I left" gives "I did not leave" (after a bit of necessary grammatical adjustment).
But English is a little too rich for mathematical logic. When you read the sentence "I wanted to leave and I left," you probably see a connotation of causality: I left because I wanted to leave. This implication does not follow from the logical combination of the truth values of the two propositions "I wanted to leave" and "I left." Or consider the proposition "I wanted to leave but I did not leave." Here, the word "but" has the same logical meaning as the word "and," but the connotation is very different. So, in mathematical logic, we use symbols to represent logical operators. These symbols do not carry any connotation beyond their defined logical meaning. The logical operators corresponding to the English words "and," "or," and "not" are , , and .
Let and be propositions. Then , , and are propositions, whose truth values are given by the rules:
- is true when both is true and is true, and in no other case.
- is true when either is true, or is true, or both and are true, and in no other case.
- is true when is false, and in no other case.
The operators , , and are referred to as conjunction, disjunction, and negation, respectively. (Note that is read as " and ," is read as " or ," and is read as "not .")
Precedence and Associativity
These operators can be used in more complicated expressions, such as or . A proposition made up of simpler propositions and logical operators is called a compound proposition. Parentheses can be used in compound expressions to indicate the order in which the operators are to be evaluated. In the absence of parentheses, the order of evaluation is determined by precedence rules. For the logical operators defined above, the rules are that has higher precedence than , and has precedence over . This means that in the absence of parentheses, any operators are evaluated first, followed by any operators, followed by any operators.
For example, the expression is equivalent to the expression , while is equivalent to . As a practical matter, when you make up your own expressions, it is usually better to put in parentheses to make your meaning clear. Remember that even if you leave out parentheses, your expression has an unambiguous meaning. If you say "" when what you meant was "," you've got it wrong!
This still leaves open the question of which of the operators in the expression is evaluated first. This is settled by the following rule: When several operators of equal precedence occur in the absence of parentheses, they are evaluated from left to right. Thus, the expression is equivalent to rather than to . In this particular case, as a matter of fact, it doesn't really matter which operator is evaluated first, since the two compound propositions and always have the same value, no matter what logical values the component propositions , , and have. We say that is an associative operation. We'll see more about associativity and other properties of operations in the next section.
Truth Tables
Suppose we want to verify that, in fact, and do always have the same value. To do so, we have to consider all possible combinations of values of , , and , and check that for all such combinations, the two compound expressions do indeed have the same value. It is convenient to organize this computation into a truth table. A truth table is a table that shows the value of one or more compound propositions for each possible combination of values of the propositional variables that they contain. Shown below is a truth table that compares the value of to the value of for all possible values of , , and . There are eight rows in the table because there are exactly eight different ways in which truth values can be assigned to , , and .2 In this table, we see that the last two columns, representing the values of and , are identical.
false | false | false | false | false | false | false |
false | false | true | false | false | false | false |
false | true | false | false | false | false | false |
false | true | true | false | true | false | false |
true | false | false | false | false | false | false |
true | false | true | false | false | false | false |
true | true | false | true | false | false | false |
true | true | true | true | true | true | true |
More generally, we say that two compound propositions are logically equivalent if they always have the same value, no matter what truth values are assigned to the propositional variables that they contain. If the number of propositional variables is small, it is easy to use a truth table to check whether or not two propositions are logically equivalent.
Other Operators
There are other logical operators besides , , and . We will consider the conditional operator, , the biconditional operator, , and the exclusive or operator, .3 These operators can be completely defined by a truth table that shows their values for the four possible combinations of truth values of and .
For any propositions and , we define the propositions , , and according to the truth table:
false false true true false false true true false true true false false false true true true true true false When these operators are used in expressions, in the absence of parentheses to indicate order of evaluation, we use the following precedence rules: The exclusive or operator, , has the same precedence as . The conditional operator, , has lower precedence than , , , and , and is therefore evaluated after them. Finally, the biconditional operator, , has the lowest precedence and is therefore evaluated last. For example, the expression "" is evaluated as if it were written "."
In order to work effectively with the logical operators, you need to know more about their meaning and how they relate to ordinary English expressions.
Implication
The proposition is called an implication or a conditional. It is usually read as " implies ." In English, is often expressed as "if then ." For example, if represents the proposition "Bill Gates is poor" and represents "the moon is made of green cheese," then could be expressed in English as "If Bill Gates is poor, then the moon is made of green cheese." In this example, is false and is also false. Checking the definition of , we see that is a true statement. Most people would agree with this. It's worth looking at a similar example in more detail. Suppose that I assert that "If the Mets are a great team, then I'm the king of France." This statement has the form where is the proposition "the Mets are a great team" and is the proposition "I'm the king of France." Now, demonstrably I am not the king of France, so is false. Since is false, the only way for to be true is for to be false as well. (Check the definition of in the table!) So, by asserting , I am really asserting that the Mets are not a great team.
Or consider the statement, "If the party is on Tuesday, then I'll be there." What am I trying to say if I assert this statement? I am asserting that is true, where represents "The party is on Tuesday" and represents "I will be at the party." Suppose that is true, that is, the party does in fact take place on Tuesday. Checking the definition of , we see that in the only case where is true and is true, is also true. So from the truth of "If the party is on Tuesday, then I will be at the party" and "The party is in fact on Tuesday," you can deduce that "I will be at the party" is also true. But suppose, on the other hand, that the party is actually on Wednesday. Then is false. When is false and is true, the definition of allows to be either true or false. So, in this case, you can't make any deduction about whether or not I will be at the party. The statement "If the party is on Tuesday, then I'll be there" doesn't assert anything about what will happen if the party is on some other day than Tuesday.
The implication is called the contrapositive of . An implication is logically equivalent to its contrapositive. The contrapositive of "If this is Tuesday, then we are in Belgium" is "If we aren't in Belgium, then this isn't Tuesday." These two sentences assert exactly the same thing.
Note that is not logically equivalent to . The implication is called the converse of . The converse of "If this is Tuesday, then we are in Belgium" is "If we are in Belgium, then this is Tuesday." Note that it is possible for either one of these statements to be true while the other is false. In English, I might express the fact that both statements are true by saying "If this is Tuesday, then we are in Belgium, and conversely." In logic, this would be expressed with a proposition of the form .
Biconditional
The biconditional operator is closely related to the conditional operator. In fact, is logically equivalent to . The proposition is usually read as " if and only if ." (The " if " part represents , while " only if " is another way of asserting that .) It could also be expressed as "if then , and conversely." Occasionally in English, "if ... then" is used when what is really meant is "if and only if." For example, if a parent tells a child, "If you are good, then Santa will bring you toys," the parent probably really means to say "Santa will bring you toys if and only if you are good." (The parent would probably not respond well to the child's perfectly logical plea "But you never said what would happen if I wasn't good!")
Exclusive Or
Finally, we turn to the exclusive or operator. The English word "or" is actually somewhat ambiguous. The two operators and express the two possible meanings of this word. The proposition can be expressed unambiguously as " or , or both," while stands for " or , but not both." If a menu says that you can choose soup or salad, it doesn't mean that you can have both. In this case, "or" is an exclusive or. On the other hand, in "You are at risk of heart disease if you smoke or drink," the or is inclusive since you certainly don't get off the hook if you both smoke and drink. In mathematics, the word "or" is always taken in the inclusive sense of .
Functional Completeness of And, Or, Not
Now, any compound proposition that uses any of the operators , , and can be rewritten as a logically equivalent proposition that uses only , , and . It is easy to check that is logically equivalent to . (Just make a truth table for .) Similarly, can be expressed as , while is the same as . So, in a strict logical sense, , , and are unnecessary. (Nevertheless, they are useful and important, and we won't give them up.)
Even more is true: In a strict logical sense, we could do without the conjunction operator . It's easy to check that is logically equivalent to , so any expression that uses can be rewritten as one that uses only and . Alternatively, we could do without and write everything in terms of and .
Tautologies and Contradictions
Certain types of proposition will play a special role in our further work with logic. In particular, we define tautologies and contradictions as follows:
A compound proposition is said to be a tautology if and only if it is true for all possible combinations of truth values of the propositional variables which it contains. A compound proposition is said to be a contradiction if and only if it is false for all possible combinations of truth values of the propositional variables which it contains.
For example, the proposition is a tautology. This can be checked with a truth table:
false | false | false | true | false | true |
false | true | true | false | false | true |
true | false | true | true | true | true |
true | true | true | false | false | true |
The fact that all entries in the last column are true tells us that this expression is a tautology. Note that for any compound proposition , is a tautology if and only if is a contradiction. (Here and in the future, I use uppercase letters to represent compound propositions. stands for any formula made up of simple propositions, propositional variables, and logical operators.) Logical equivalence can be defined in terms of tautology:
Two compound propositions, and , are said to be logically equivalent if and only if the proposition is a tautology.
The assertion that is logically equivalent to will be expressed symbolically as "." For example, , and .
Exercises
Give the three truth tables that define the logical operators , , and .
Answer
false false false false true false true false false true true true false false false false true true true false true true true true false true true false Insert parentheses into the following compound propositions to show the order in which the operators are evaluated:
Answer
Answer
Answer
Answer
List the 16 possible combinations of truth values for the four propositional variables , , , . Try to find a systematic way to list the values. (Hint: Start with the eight combinations of values for , , and , as given in the truth table above.) Now, explain why there are 32 possible combinations of values for five variables, and describe how they could be listed systematically.
Answer
false false false false false false false true false false true false false false true true false true false false false true false true false true true false false true true true true false false false true false false true true false true false true false true true true true false false true true false true true true true false true true true true The first eight combinations are the eight for , , and , with false; the other eight are the same with true.
To list the 32 combinations for five variables systematically, first list the 16 above combinations with an additional first variable being false, and then list them again with that additional variable being true.
Some of the following compound propositions are tautologies, some are contradictions, and some are neither. In each case, use a truth table to decide to which of these categories the proposition belongs:
Answer
Tautology
Answer
Tautology
Answer
Contradiction
Answer
Neither: false when true and false, or when false and true (so this is equivalent to )
Answer
Tautology
Answer
Tautology
Use truth tables to show that each of the following propositions is logically equivalent to .
Is an associative operation? That is, is logically equivalent to ? Is associative?
Answer
To show that two expressions are equivalent we need to handle every case (by making a truth table). However, to show that they are not equivalent we only need to come up with one counter-example. Suppose that is false: then is true, regardless of and . However, if and are both false, then is false (because is true while is false). Therefore, is not associative.
For the case of , it is not possible to find such a counter-example, because all of the rows are the same. In fact, a little reflection shows that, for both and , they are true when either all three of , , and are true, or when exactly one of them is true. (There is a similar property for , which is true when exactly zero or two of the variables are true. These properties extend to any number of variables all combined with or ; for one operator the combination will be true exactly when an even number of variables are true, and for the other when an odd number are true, so these operations give a way to compute the even or odd "parity" of a set of inputs.)
Let represent the proposition "You leave" and let represent the proposition "I leave." Express the following sentences as compound propositions using and , and show that they are logically equivalent:
- Either you leave or I do. (Or both!)
- If you don't leave, I will.
Answer
The first sentence is , while the second is . We can show that they are equivalent by making truth tables and showing that they have the same truth value in every case. The only case where is false is if both and are false; the only case where is false is if is true but is false—that is, when and are both false. Therefore, the truth tables will be the same and they are equivalent.
Suppose that represents the proposition "The Earth moves," represents "The Earth is the center of the universe," and represents "Galileo was railroaded." Translate each of the following compound propositions into English:
Answer
Galileo was not railroaded and the Earth is the center of the universe.
Answer
If the Earth moves then the Earth is not the center of the universe.
Answer
The Earth moves if and only if the Earth is not the center of the universe.
Answer
If the Earth moves then Galileo was railroaded, and if the Earth is the center of the universe then Galileo was not railroaded.
Give the converse and the contrapositive of each of the following English sentences:
- If you are good, Santa brings you toys.
Answer
Converse: If Santa brings you toys, then you are good.
Contrapositive: If Santa does not bring you toys, then you are not good.
- If the package weighs more than one ounce, then you need extra postage.
Answer
Converse: If you need extra postage, then the package weighs more than one ounce.
Contrapositive: If you do not need extra postage, then the package weighs no more than one ounce.
- If I have a choice, I don't eat eggplant.
Answer
Converse: If I don't eat eggplant, then I have a choice.
Contrapositive: If I eat eggplant, then I don't have a choice.
- If you are good, Santa brings you toys.
In an ordinary deck of fifty-two playing cards, for how many cards is it true
- that "This card is a ten and this card is a heart"?
Answer
Only one card: the ten of hearts
- that "This card is a ten or this card is a heart"?
Answer
The 13 heart cards (including the 10 of hearts) plus the other three tens satisfy this, for a total of 16
- that "If this card is a ten, then this card is a heart"?
Answer
It is true for the 10 of hearts, but it is also true for the 48 cards that are not tens, for a total of 49
- that "This card is a ten if and only if this card is a heart"?
Answer
This is true for the 10 of hearts, as well as for all of the non-tens that are also not hearts; there are 36 cards that are neither tens nor hearts, for a total of 37 cards making this true
- that "This card is a ten and this card is a heart"?
Define a logical operator so that is logically equivalent to . (This operator, known as the Peirce Arrow,4 is usually referred to as "NOR," short for "not or"). Show that each of the propositions , , , , , and can be rewritten as a logically equivalent proposition that uses as its only operator; we say that is a functionally complete operator, since it may be used to express all of the other operations.
Answer
Notice that . Since , this means that is equivalent to , which in turn can be expressed as . Since we saw above that , we may also express in terms of (although it isn't pretty…). As observed before, , , and are functionally complete, so we can also express , , and using .
Show that the Sheffer Stroke operator , defined so that is logically equivalent to , is also functionally complete.5 This operator is also known as "NAND," short for "not and."
Answer
Since and , and is a functionally complete set, we are done.
- It is not always true that the truth value of a sentence can be determined from the truth values of its component parts. For example, if is a proposition, then "Sarah Palin believes " is also a proposition, so "Sarah Palin believes" is some kind of operator. However, it does not count as a logical operator because just from knowing whether or not is true, we get no information at all about whether "Sarah Palin believes " is true.↩
- In general, if there are variables, then there are different ways to assign truth values to the variables. This might become clear to you if you try to come up with a scheme for systematically listing all possible sets of values. If not, you'll find a rigorous proof of the fact later in this chapter.↩
- Note that the symbols used in this book for the logical operators are not universal. While , , and are fairly standard, is often replaced by and is sometimes represented by or . There is even less standardization of the exclusive or operator, but that operator is generally not so important as the others.↩
- Wikipedia helpfully points out that this is not to be confused with the Pierce-Arrow automobile; Google, as I was writing this, repeatedly insisted on correcting Peirce to Pierce…. Charles Sanders Peirce, pronounced "Purse" (1839–1914), was an American scientist and philosopher who wrote many influential papers, and many more that would have been influential if they had been published during his lifetime. In addition to the functional completeness result mentioned here, he helped develop and promote modern logical notation and the use of truth tables, and he worked out the foundations of what became relational database theory a century later. Arthur Burks, a 1936 DePauw graduate who went on to help build ENIAC, credited Peirce with having the idea of building an electrical computing machine, based on wiring up switches to perform logical operations, fifty years before such a machine was built!↩
- Functional completeness is not merely an academic curiosity. The NAND and NOR gates are particularly simple to implement in silicon (each needs essentially one transistor per input), and building an entire circuit out of identical building blocks makes both design and fabrication easier. Indeed, the very first computer built from integrated circuits was the Apollo Guidance Computer, which used about 5600 three-input NOR gates to help Apollo 11 land on the moon.↩