# Chapter 1: The Logic of Compound Statements

## Full text

(1)

### Chapter 1: The Logic of Compound Statements

• Topics covered include

1.1 Logical Form and Logical Equivalence, 1.2 Conditional Statements,

1.3 Valid and Invalid Arguments, • but exclude

1.4 Application: Digital Logic Circuits,

(2)

### Propositional Calculus (Statement Calculus)

This chapter deals with the symbolic analysis of ordinary compound statements, a topic known as propositional calculus (statement calculus). We will discuss

• statements;

• compound statements formed with the logical operators (or connectives) ∼, ∧, ∨, →, ↔;

(3)

### Identifying Logical Form: Example 1

• Argument 1.

If the program is syntactically incorrect or if the program divides by 0, then the system will print an error message. Therefore, if the system does not print an error message, then the program is syntactically correct and the program does not divide by 0.

• The form: If p or q, then r. Therefore, if not r, then not p and not q. p = “The program is syntactically incorrect.”

q = “The program divides by 0.”

(4)

### Identifying Logical Form: Example 2

• Argument 2.

If x is a real number such that x < −2 or x > 2, then x2 > 4. Therefore, if x2 6> 4, then x 6< −2 and x 6> 2.

• The form.

If p or q, then r. Therefore, if not r, then not p and not q. The symbols p, q, r mean:

p = “x is a real number such that x < −2.” q = “x is a real number such that x > 2.”

(5)

### Identifying Logical Form: Observation

We have illustrated that two arguments, completely different in contents, can have an identical form.

(6)

### Definitions are Built on Undefined Terms

• To discuss logic formally, some definitions are needed.

• Some undefined terms, whose meanings are assumed to be already known, are needed before we can start to define anything.

(7)

### Statements

A statement (or proposition), is a declarative sentence that is true or false but not both.

• This quality of a statement, being true or false, is called the truth value of the statement.

• Do not confuse logic statements with imperative programming language statements! The latter are actually instructions.

(8)

### Statements: Examples

• True statements. 1 + 1 = 2.

The programming language C is not object-oriented. • False statements.

Four plus five equals six.

The programming language Java is not object-oriented. • Statements with unknown truth values.

(9)

### Previous (?) Open Problems

• Every planar map is four colorable. (1852–1976) • xn

+ yn

= zn

has no integer solutions for n > 2 and xyz 6= 0. (Fermat’s Last Theorem, 1630?–1994?)

(10)

### Non-Statements: Examples

Non-statements include questions, commands, exclamations, sentences with undefined or ambiguous words:

• How is the lecture? • Stop talking!

• Oh no!

(11)
(12)

### Compound Statements

• Statements can be combined (or composed) with operators (or connectives) into more complicated statements.

• The truth value of the compound (or composition) is determined by the truth values of the component statements and the operators involved. • The truth value of a compound can be described by a truth table which

lists exhaustively the truth value of the compound for each combination of truth values of the component statements.

(13)

### Statement Variables

• We use statement forms (or logical expressions) to express the logical structure (or form) of a compound statement.

• In a statement form, symbols are used to represent statements. These symbols are called statement variables.

You have seen examples in which lower case letters such as p, q, r, s etc were used as statement variables to represent statements.

(14)

### Statement Forms: Recursive Definition

A statement form (or logical expression) is obtained by the following procedure:

• Every statement variable is a statement form. • T and F are statement forms.

• If P is a statement form, then (∼ P ) is a statement form.

• If P and Q are statement forms, then (P ∧ Q), (P ∨ Q), (P → Q), (P ↔ Q) are statement forms.

(15)

### Operator Precedence

• Order of operations is determined by operator precedence when it is not explicitly indicated by parentheses.

• Operator precedence determines which operator owns an operand when the operand is shared by two operators:

· · · O1V O2 · · · =?

(16)

### Operator Precedence Convention

• The convention is

∼ ∧, ∨ →, ↔

• Higher operators precede lower operators. Operators in the same row have the same precedence.

(17)

### Statements, Statement Variables, Statement Forms

When there is no risk of confusion, we shall simply use “statement” instead of “statement variable” or “statement form”.

Note that a statement variable becomes a statement when it is substituted with the statement.

Similarly, a statement form becomes a statement when its constituent statement variables are substituted with statements.

This is analogous to the familiar numbers, variables, and arithmetic expressions. For example, it is perfectly all right to say the number, instead of, the expression “x + y”.

(18)

### Negation

The negation of a statment p is written ∼ p. It denotes the statement “not p” or “It is not the case p”. The statements p and ∼ p have opposite truth values.

The truth table for ∼ p is:

p ∼ p T F

(19)

### Conjunction

The conjunction of two statments p and q is written p ∧ q. It denotes the statement “p and q”. The statement p ∧ q is true when both p and q are true; it is false otherwise.

The truth table for p ∧ q is:

p q p ∧ q T T T T F F F T F F F F

(20)

### Remarks

If we let T denote 0 and F denote 1. Then the possible combination of truth values of p and q in the table are enumerated in the order of the binary numbers 00, 01, 10, 11.

(21)

### Disjunction

The disjunction of two statments p and q is written p ∨ q. It denotes the statement “p or q”. The statement p ∨ q is false when both p and q are false; it is true otherwise.

The truth table for p ∨ q is:

p q p ∨ q T T T T F T F T T F F F

(22)

### Remarks

The truth value of p ∨ q is defined as inclusive or: p ∨ q is true when p is true, or q is true, or both are true.

(23)

### Compound Statements: Example 1

Let

p = “It is hot.” q = “It is sunny.”

1. Express “It is not hot but it is sunny” as a logical expression. Answer. ∼ p ∧ q.

Note. In this context, “but” means “and” with the connotation that the “and” part is somewhat unexpected. For example, “He is rich but unhappy”.

(24)

2. Express “It is neither hot nor sunny” as a logical expression. Answer. (∼ p) ∧ (∼ q).

(25)

### Compound Statements: Example 2

Let x be some known real number and p = “0 < x”

q = “x < 3” r = “x = 3”

1. Express “x ≤ 3” as a logical expression. Answer. q ∨ r.

2. Express “0 < x < 3” as a logical expression. Answer. p ∧ q.

(26)

3. Express “0 < x ≤ 3 as a logical expression. Answer. p ∧ (q ∨ r).

(27)

### Compound Statements: Example 3

What does the statement “0 ≤ 0” mean? Let

p = “0 < 0” q = “0 = 0”

The given statement actually means p ∨ q and we have

p q p ∨ q F T T

(28)

Thus “0 ≤ 0” is true, as it should be. Is the statement “0 ≤ 1” true or false?

(29)

### Compound Statements

The truth value of a compound statement is most conveniently given in a truth table that gives the truth value of all constituent compound statements for all possible combinations of truth values of the statement variables involved.

(30)

### Variable Truth Values

As mentioned previously, to systematically list all possible combinations of truth values of n statement variables, we may take T to mean 0 and F to mean 1, or vice versa, and generate the n-bit binary patterns whose values run from 0 to 2n

(31)

p q r 3-Bit Decimal value T T T 0 0 0 0 T T F 0 0 1 1 T F T 0 1 0 2 T F F 0 1 1 3 F T T 1 0 0 4 F T F 1 0 1 5 F F T 1 1 0 6 F F F 1 1 1 7

(32)

### Example 1

“Exclusive or” can be expressed in terms of “∨”, “∧” and “∼” as follows:

(33)

p q p ∨ q p ∧ q ∼ (p ∧ q) (p ∨ q)∧ ∼ (p ∧ q)

T T T T F F

T F T F T T

F T T F T T

F F F F T F

Note that, as expected, the “exclusive or” statement is true if and only if exactly one of p, q is true.

(34)

### Logical Equivalence

Two statement forms are logically equivalent if and only if they evaluate to the same truth value for all possible combinations of truth values of the constituent statement variables. We write P ≡ Q to denotes the statement forms P and Q are logically equivalent.

(35)

### Logical Equivalence: Examples

p ∧ q ≡ q ∧ p p q p ∧ q q ∧ p T T T T T F F F F T F F F F F F p ∨ q ≡ q ∨ p

(36)

p q p ∨ q q ∨ p

T T T T

T F T T

F T T T

(37)

### Tautologies

A tautology is a statement form that always evaluates to true.

For example, the statement form p∨ ∼ p is a tautology.

p ∼ p p∨ ∼ p

T F T

(38)

A contradiction is a statement form that always evaluates to false.

For example, the statement form p∧ ∼ p is a contradiction.

p ∼ p p∧ ∼ p

T F F

(39)

### Theorem 1.1.1 Logical Equivalences

Given any statement variables p, q, and r, a tautology t and a contradiction c, the following logical equivalences hold:

• Commutative laws:

p ∧ q ≡ q ∧ p p ∨ q ≡ q ∨ p

• Associative laws:

(40)

• Distributive laws: p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) • Identity laws: p ∧ t ≡ p p ∨ c ≡ p • Negation laws:

(41)

• Double negative laws:

∼ (∼ p) ≡ p

• Idempotent laws:

p ∧ p ≡ p p ∨ p ≡ p

• Universal bound laws:

(42)

• De Morgan’s laws: ∼ (p ∧ q) ≡∼ p∨ ∼ q ∼ (p ∨ q) ≡∼ p∧ ∼ q • Absorption laws: p ∧ (p ∨ q) ≡ p p ∨ (p ∧ q) ≡ p • Negations of t and c:

(43)

### Conditional Statements

Let p and q be statements. The conditional of q by p, denoted p → q, is the statement “if p then q”, or “q, if p”, or “p implies q”. It is false if p is true and q is false; it is true otherwise.

The truth table for p → q is

p q p → q T T T T F F F T T F F T

(44)

### Notes on Conditional Statements

• In p → q, the statement p is called hypothesis (or antecedent) and the statement q is called conclusion (or consequent).

• The assignment of truth values to p → q fits the intuitive logic: if the hypothesis is true, for the conditional to be true, the conclusion ought to be true; but if the hypothesis is false, it does not matter what the conclusion is, so the conditional is “automatically” true.

• The truth of p → q due to the falsity of p, regardless of the truth value of q, is called vacuously true or true by default.

(45)

### More Notes

• Some authors dislike the description “p implies q” for “p → q” because p and q may have no relevance at all.

• Some authors prefer to say “q if p” because this makes “if” look like a binary operator like ∧ and ∨. But the cost of doing this is that the order of p and q are not the same as that in “if p then q”.

(46)

### Expressing “if-then” as “or” and “not”

The “if-then” construct can be expressed in terms of negation and disjunction.

The logical equivalence

p → q ≡∼ p ∨ q

can be proved using the following truth table:

p q ∼ p p → q ∼ p ∨ q

T T F T T

(47)

### Negating “if-then”

We have ∼ (p → q) ≡ p∧ ∼ q Proof 1. ∼ (p → q) ≡ ∼ (∼ p ∨ q) ≡ ∼∼ p∧ ∼ q ≡ p∧ ∼ q

(48)

Proof 2. p q ∼ q p → q ∼ (p → q) p∧ ∼ q T T F T F F T F T F T T F T F T F F F F T T F F

(49)

### Contrapositive

The contrapositive of the statement “If p then q” is

“If not q then not p”.

That is, the contrapositive of p → q is ∼ q →∼ p.

(50)

Using a truth table, we can easily show that p → q ≡∼ q →∼ p.

(51)

### Its Converse

The converse of the statement “If p then q” is

“If q then p”.

That is, the converse of p → q is q → p.

(52)

Using a truth table, we can easily show that p → q 6≡ q → p.

(53)

### Its Inverse

The inverse of the statement “If p then q” is “If not p then not q”.

That is, the inverse of p → q is ∼ p →∼ q.

Using a truth table, we can easily show that p → q 6≡∼ p →∼ q.

(54)

### are Logically Equivalent

Using a truth table, we can easily show that q → p ≡∼ p →∼ q

(55)

### The Biconditional

The biconditional of the statements p and q is

“p if, and only if, q”. It is denoted as

p ↔ q.

It is true when p and q have the same truth values and is false when p and q have opposite truth values.

(56)

The truth table of the biconditional is p q p ↔ q T T T T F F F T F F F T

(57)

### if and only if

In mathematics, the phrase “if and only if” occurs frequently. In English, we expect that

p if and only if q to mean

p if q, and p only if q

Recall that “p only if q” means “if p then q”. So we expect p ↔ q ≡ (q → p) ∧ (p → q)

(58)
(59)

### Necessary and Sufficient Conditions

In English, the conidtional p → q can also be stated as p is a sufficient condition for q

or equivalently,

(60)

### Revision: Logical Operator Precedence

The order of precedence, listed in decreasing order from top to bottom, is

1 ∼

2 ∧, ∨ 3 →, ↔

Note that ∧ and ∨ are of the same order of precedence, → and ↔ are of the same order of precedence.

(61)

### Argument Forms

An argument form is a sequence of statements p1, p2,· · · , pn, c.

All statements except the last,

p1, p2,· · · , pn

are called premises, or assumptions, or hypotheses. The last statment, c

(62)

### Valid and Invalid Arguments

• An argument form is valid when all premises are true, the conclusion is also true.

• A valid argument form is also known as a rule of inference. • To highlight the conclusion we precede it with the ∴ symbol.

(63)

### Affirming)

p → q p

∴ q

Is this a valid argument form?

(64)

p q p → q p q T T T T T ∗ T F F T F F T T F T F F T F F premises conclusion

(65)

### Denying)

p → q ∼ q ∴ ∼ p

Is this a valid argument form?

(66)

p q p → q ∼ q ∼ p T T T F F T F F T F F T T F T F F T T T ∗ premises conclusion

(67)

p ∧ q ∴ p

p ∧ q ∴ q

(68)

### Valid Argument Forms: Elimination

p ∨ q ∼ p ∴ q p ∨ q ∼ q ∴ p

(69)

### Valid Argument Forms: Transitivity

p → q q → r ∴ p → r

(70)

### Valid Argument Forms: Proof by Cases

p ∨ q p → r q → r ∴ r

In words, if at least one of two (or several) possibilities is true and each possibility leads to the same conclusion, then the conclusion must also be true.

(71)

### Valid Argument Forms: Proof by Contradiction

p → F ∴∼ p

In words, if the truth of p leads to a falsity, then ∼ p has to be true. (The text states this rule slightly differently.)

(72)

### Example: Knights and Knaves (Smullyan)

• Knights always tell the truth, knaves always lie.

• Can we tell what A and B are, from what they say below? A: “B is a knight.”

B: “A and I are of opposite type.” • To analyze, let

(73)

p = “What A says is true.” q = “What B says is true.”

(74)

### Example: Knights and Knaves (Smullyan)

a → p by the definitions of a, p p → b by the definitions of p, b

∴ a → b transitivity

b → q by the definitions of b, q q → (a∧ ∼ b) ∨ (∼ a ∧ b) by the definitions of q, a, b ∴ a → (a∧ ∼ b) ∨ (∼ a ∧ b) transitivity

a → a ∧ b ∧ ((a∧ ∼ b) ∨ (∼ a ∧ b)) a valid argument (∗)

∴∼ a by contradiction

∼ a →∼ p by the definitions of a, p ∼ p →∼ b by the definitions of p, b

(75)

### Example: Knights and Knaves (Smullyan)

• Both A and B are knaves. This can be checked to be consistent with the given facts.

• The following valid argument form (∗) is used to arrive at a contradiction. x → y, x → z, ∴ x → x ∧ y ∧ z

Updating...

Updating...