Harvard University, Math 101, Spring 2015 Lecture 1 and 2 : Introduction to propositional logic 1 Logical statements A statement is a sentence that is either true or false, but not both. Some examples: 1. 1 is smaller than 2 2. 7 is an odd number 3. 2 is a rational number 4. x N (1) and (2) are true statements while (3) is a false statement and (4) is not a statement since its validity depends on an unspecified variable x. 2 Logical operators A logical operator or a Boolean operator is a function that takes as entries one or several statements and returns another statement. In propositional logic, we use propositional variables that we will denote by roman letters such as a, b, p, q, and s. A formula consists of propositional variables connected by logical operators. A valuation is a function that attached to each propositional variable either 1 for truth or 0 for falsity. We can define a logical operator by the values it takes for all possible valuations of its entries. Such valuations are organized in a truth table. Two logical operators are equivalent when they have the same truth table. 2.1 The negation: the NOT operator The negation (the NOT operator) is a unary operator 1 that takes a statement and returns its negation. We denote the negation of a statement p by p or p. Given a statement p, p is true if p is false, and p is false if p is true. This is summarized in the following truth table: p p 0 1 1 0 2.2 The conjunction : the AND operator The AND operator is a binary operator 2 that is true if and only if both of its entries are true. It is defined by the following table: 1 A unary operator is an operator with only one entry. 2 A binary operator is an operator with two entries. p q p q 0 1 0 1
2.3 The (inclusive) disjunction: the OR operator The OR operator is a binary operator that is true if and only if at least one of its entries is true. It is false if and only if both of its entries are false. It is defined by the following table: p q p q By comparing tables, we can prove that the OR operator can be expressed in terms of the AND and NOT operator. More precisely, we have the p q p q. To prove this theorem, we need to show that p q has the same truth table as p q. This is indeed the case. To compute the truth table of p q, we starts by enumerating all the possible valuations for p and q, we can then compute those of p and q and finally compute those of p q: p q p q p q 1 1 1 1 0 1 0 0 We can also prove the following dual statement: Proof. : p q p q. p q p q p q p q 1 1 1 0 0 1 The last two columns are the same, which shows that p q p q.. 2.4 The implication: the If...Then... operator The If...Then... operator is a binary operator that is false if and only if the first entry is true while the second entry is false. It is defined by the following table: p q p = q 0 0 1 2
We can show that (p = q) p q. Proof. p q p q p = q p q 1 1 1 0 1 1 0 0 1 The last two columns are the same, which establishes the equivalence. The statement p = q is also called a conditional statement. From that point of vue p is called the hypothesis and q is the conclusion or implication. Given the conditional statement p = q, q = p is called the converse of p = q p = q is called the inverse of p = q q = p is called its contrapositive of p = q We will see that a conditional statement is equivalent to its contrapositive while its converse is equivalent to its inverse. However, the conditional statement is usually not equivalent to its converse. 2.5 Equivalence : the If and Only If operator The equivalence operator is a binary operator that is false if the two entries have different truth values. It is defined by the following truth table: p q p q 0 1 0 0 0 1 We can show that (p q) (p = q) (q = p). or equivalently (p q) (p q) (q p). The equivalence symbol is actually not necessary since it is exactly the same as the operator. 2.6 The Exclusive disjunction: the XOR operator The exclusive disjunction is true if and only if the two entries have different valuation: p q p + q 1 1 0 3
We can show that it is the negation of the equivalence operator: p + q p q. 3 Basic properties of logical operators Summary of the truth tables Negation of logical operators: p q p q p q p = q p q p + q 0 1 0 0 p p p q p q p q p q p = q p q p q (p q) p + q Indempotence Simplifications Distributivity: Associativity: p p p p p p p 1 p p 0 p (1 = p) p (p = 0) p a (b c) (a b) (a c) a (b c) (a b) (a c) Commutativity a (b c) (a b) c a (b c) (a b) c p q q p p q q p p + q q + p p q q p The following theorems are also very handy to replace implications by a combination of NOT, OR, and AND operators: (p = q) p q (p q) (p = q) (q = p) (p q) (p q) 4
4 Tautologies A tautology is a formula that is always true. A contradiction is the negation of a tautology. A simple way to construct a tautology is to start from an equivalence a b and to replace the symbol by the operator. We now review a list of famous tautologies: The law of double negation: p p This is just the statement that the negation is an involutive operator (it squares to the identity). The law of excluded middle: p p The law of excluded middle reflects the fact that a propositional variables always have a well defined truth values, it is either true or false. The law of contraposition: (p = q) (q = p) The law of contraposition is often used in mathematical proof: to prove that p implies q it is sometimes easier to prove that q implies p. Dualities or de Morgan s laws: Syllogism: p q p q p q p q (a = b) (b = c) = (a = c) The syllogism is essentially the statement that the implication operator = is transitive. Proof by cases: (a b) (a = c) (b = c) = c If one of a or b is true and each implies c, then c is necessary true. Reductio ad absurdum: (p = q) (p = q) = p. This is a common procedure in mathematical proofs. To show that p is true, we can show that its negation implies both a proposition q and its negation q. Since q and q cannot be true at the same time, it follows that p has to be false, and therefore p is true. Modus ponens If q is true and p implies q, then q is true. p (p = q) = q 5
5 Boolean algebra We introduce the set Z 2 of integers modulo 2. As a set it is composed of only two elements: Z 2 = {0, 1}. The element 0 represents all the even integers and 1 to all the odd integers. Addition and multiplications are defined by the following tables: + 0 1 0 0 1 1 1 0 0 1 In particular 1 + 1 = 2 but since we are in Z 2 and 2 is even, we have 2 = 0 and therefore 1 + 1 = 0. Since the addition and multiplication are operations that take entries in Z 2 and return an element of Z 2, we can think of them as logical operators. We can write them as truth table and notice that they correspond respectively to XOR and AND: p q p + q 1 1 0 p q p q 0 1 0 When working with Z 2, it is useful to remember the identities: a 2 a, 2a 0. The dictionary between logical and arithmetic operators is simply: a b : a b a : 1 + a a XOR b : a + b a b : a + b + a b a b : 1 + a + b a = b : 1 + a + a b Boolean algebra is very handy for proving theorems of binary propositional logic. For example, let see that p p is a tautology: p p p + p + p p (since a b = a + b + ab) p + (1 + p) + p(1 + p) (since p = 1 + p) p + 1 + p + p 2 (by distributivity) 1 + 2p (since p 2 = p in Z 2 ) 1 (since 2p = 0 in Z 2 ). We will now prove the Modus Ponens p (p = q) = q using the arithmetic of Z 2. The first step is to translate it into an arithmetic expression in Z 2 and the second step is to prove that the expression we find is equal to 1. 6
Since (p = q) 1 + p + pq, and is just multiplication in Z 2, we have (p ) (p = q) = q p(1 + p + pq) = q 1 + p(1 + p + pq) + p(1 + p + pq)q 1 + p + p 2 + p 2 q + pq + p 2 q + p 2 q 1 + p + p + pq + pq + pq + pq (since p 2 = p in Z 2 ) 1 (since 2p = 0 and 4pq = 0 in Z 2 ) Since (a = b) = 1 + a + ab 7