CISC 1100: Structures of Computer Science Chapter 3 Logic Arthur - - PowerPoint PPT Presentation

cisc 1100 structures of computer science
SMART_READER_LITE
LIVE PREVIEW

CISC 1100: Structures of Computer Science Chapter 3 Logic Arthur - - PowerPoint PPT Presentation

CISC 1100: Structures of Computer Science Chapter 3 Logic Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Summer, 2010 Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3 Logical (or illogical?)


slide-1
SLIDE 1

CISC 1100: Structures of Computer Science

Chapter 3 Logic Arthur G. Werschulz

Fordham University Department of Computer and Information Sciences

Summer, 2010

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-2
SLIDE 2

Logical (or illogical?) reasoning

Is this a valid argument?

All men are mortal. Socrates is a man. Therefore,

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-3
SLIDE 3

Logical (or illogical?) reasoning

Is this a valid argument?

All men are mortal. Socrates is a man. Therefore, Socrates is mortal.

Valid or not?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-4
SLIDE 4

Logical (or illogical?) reasoning

Is this a valid argument?

All men are mortal. Socrates is a man. Therefore, Socrates is mortal.

Valid or not? Yes! Is this a valid argument?

If we finish our homework, then we will go out for ice cream. We are going out for ice cream. Therefore we finished our homework.

Valid or not?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-5
SLIDE 5

Logical (or illogical?) reasoning

Is this a valid argument?

All men are mortal. Socrates is a man. Therefore, Socrates is mortal.

Valid or not? Yes! Is this a valid argument?

If we finish our homework, then we will go out for ice cream. We are going out for ice cream. Therefore we finished our homework.

Valid or not? No!

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-6
SLIDE 6

Logical (or illogical?) reasoning

Is this a valid argument?

All men are mortal. Socrates is a man. Therefore, Socrates is mortal.

Valid or not? Yes! Is this a valid argument?

If we finish our homework, then we will go out for ice cream. We are going out for ice cream. Therefore we finished our homework.

Valid or not? No! How to recognize the difference?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-7
SLIDE 7

Outline

Propositional Logic

Logical operations Propositional forms From English to propositions Propositional equivalence

Predicate logic

Quantifiers Some rules for using predicates

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-8
SLIDE 8

Propositional logic

Proposition: A statement that is either true or false: 2 + 2 = 4.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-9
SLIDE 9

Propositional logic

Proposition: A statement that is either true or false: 2 + 2 = 4. 2 + 2 = 5.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-10
SLIDE 10

Propositional logic

Proposition: A statement that is either true or false: 2 + 2 = 4. 2 + 2 = 5. It rained yesterday in Manhattan.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-11
SLIDE 11

Propositional logic

Proposition: A statement that is either true or false: 2 + 2 = 4. 2 + 2 = 5. It rained yesterday in Manhattan. It will rain tomorrow in Manhattan.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-12
SLIDE 12

Propositional logic

Proposition: A statement that is either true or false: 2 + 2 = 4. 2 + 2 = 5. It rained yesterday in Manhattan. It will rain tomorrow in Manhattan. These are not propositions: x + 2 = 4.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-13
SLIDE 13

Propositional logic

Proposition: A statement that is either true or false: 2 + 2 = 4. 2 + 2 = 5. It rained yesterday in Manhattan. It will rain tomorrow in Manhattan. These are not propositions: x + 2 = 4. Will it rain today in Manhattan?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-14
SLIDE 14

Propositional logic

Proposition: A statement that is either true or false: 2 + 2 = 4. 2 + 2 = 5. It rained yesterday in Manhattan. It will rain tomorrow in Manhattan. These are not propositions: x + 2 = 4. Will it rain today in Manhattan? Colorless green ideas sleep furiously.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-15
SLIDE 15

Propositional logic (cont’d)

Truth value of a proposition (T, F)

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-16
SLIDE 16

Propositional logic (cont’d)

Truth value of a proposition (T, F) Propositional variables: lower case letters (p, q, . . . )

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-17
SLIDE 17

Propositional logic (cont’d)

Truth value of a proposition (T, F) Propositional variables: lower case letters (p, q, . . . ) (Analogous to variables in algebra.)

p=“A New York City subway fare is $2.25.” q=“It will rain today in Manhattan.” r=“All multiples of four are even numbers.”

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-18
SLIDE 18

Logical operations: negation

Negation, the not operation: reverses a truth value. Negation is a unary operation: only depends on one variable. Negation of p is denoted ¬p. (Some books use other notations, such as p or p′.) Can display via a truth table p ¬p T F F T

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-19
SLIDE 19

Logical operations: conjunction, disjunction

The remaining operations we discuss are binary operations: they depend on two variables (also called connectives).

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-20
SLIDE 20

Logical operations: conjunction, disjunction

The remaining operations we discuss are binary operations: they depend on two variables (also called connectives). Conjunction, the and operation: true if both operands are

  • true. Denote by ∧.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-21
SLIDE 21

Logical operations: conjunction, disjunction

The remaining operations we discuss are binary operations: they depend on two variables (also called connectives). Conjunction, the and operation: true if both operands are

  • true. Denote by ∧.

Disjunction, the (inclusive) or operation: true if either

  • perand is true (including both). Denote by ∨.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-22
SLIDE 22

Logical operations: conjunction, disjunction

The remaining operations we discuss are binary operations: they depend on two variables (also called connectives). Conjunction, the and operation: true if both operands are

  • true. Denote by ∧.

Disjunction, the (inclusive) or operation: true if either

  • perand is true (including both). Denote by ∨.

Truth tables: p q p ∧ q T T T T F F F T F F F F p q p ∨ q T T T T F T F T T F F F

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-23
SLIDE 23

Logical operations: exclusive or

The inclusive or ∨ is not the “or” of common language. That role is played by exclusive or (xor), denoted ⊕. Truth table: p q p ⊕ q T T F T F T F T T F F F

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-24
SLIDE 24

Logical operations: exclusive or

The inclusive or ∨ is not the “or” of common language. That role is played by exclusive or (xor), denoted ⊕. Truth table: p q p ⊕ q T T F T F T F T T F F F Be careful to distinguish between or and xor!

  • Arthur G. Werschulz

CISC 1100, Fall 2010 Chapter 3

slide-25
SLIDE 25

Logical operations: conditional

Denoted p ⇒ q.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-26
SLIDE 26

Logical operations: conditional

Denoted p ⇒ q. Captures the meaning of

If p, then q. p implies q. p only if q. p is sufficient for q. q is necessary for p.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-27
SLIDE 27

Logical operations: conditional

Denoted p ⇒ q. Captures the meaning of

If p, then q. p implies q. p only if q. p is sufficient for q. q is necessary for p.

Truth table: p q p ⇒ q T T T T F F F T T F F T

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-28
SLIDE 28

Logical operations: conditional

Denoted p ⇒ q. Captures the meaning of

If p, then q. p implies q. p only if q. p is sufficient for q. q is necessary for p.

Truth table: p q p ⇒ q T T T T F F F T T F F T First two rows are “obvious”.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-29
SLIDE 29

Logical operations: conditional

Denoted p ⇒ q. Captures the meaning of

If p, then q. p implies q. p only if q. p is sufficient for q. q is necessary for p.

Truth table: p q p ⇒ q T T T T F F F T T F F T First two rows are “obvious”. Last two rows are not so obvious:

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-30
SLIDE 30

Logical operations: conditional

Denoted p ⇒ q. Captures the meaning of

If p, then q. p implies q. p only if q. p is sufficient for q. q is necessary for p.

Truth table: p q p ⇒ q T T T T F F F T T F F T First two rows are “obvious”. Last two rows are not so obvious: “One can derive anything from a false hypothesis.”

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-31
SLIDE 31

Logical operations: biconditional

Denoted p ⇔ q

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-32
SLIDE 32

Logical operations: biconditional

Denoted p ⇔ q Captures the meaning of

p if and only if q. p is necessary and sufficient for q. p is logically equivalent to q.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-33
SLIDE 33

Logical operations: biconditional

Denoted p ⇔ q Captures the meaning of

p if and only if q. p is necessary and sufficient for q. p is logically equivalent to q.

Truth table: p q p ⇔ q T T T T F F F T F F F T

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-34
SLIDE 34

Propositional Forms

In arithmetic and algebra, you learned how to build up complicated arithmetic expressions, such as 1 + 2

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-35
SLIDE 35

Propositional Forms

In arithmetic and algebra, you learned how to build up complicated arithmetic expressions, such as 1 + 2 −(1 + 2)

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-36
SLIDE 36

Propositional Forms

In arithmetic and algebra, you learned how to build up complicated arithmetic expressions, such as 1 + 2 −(1 + 2) 3 × 4

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-37
SLIDE 37

Propositional Forms

In arithmetic and algebra, you learned how to build up complicated arithmetic expressions, such as 1 + 2 −(1 + 2) 3 × 4 −(1 + 2)/(3 × 4)

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-38
SLIDE 38

Propositional Forms

In arithmetic and algebra, you learned how to build up complicated arithmetic expressions, such as 1 + 2 −(1 + 2) 3 × 4 −(1 + 2)/(3 × 4) −(1 + 2)/(3 × 4) + (5 + 6 × 7)/(8 + 9) − 10

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-39
SLIDE 39

Propositional Forms (cont’d)

Use connectives to build complicated expressions from simpler

  • nes, or

break down complicated expressions as being simpler subexpressions, connected by connectives.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-40
SLIDE 40

Propositional Forms (cont’d)

Use connectives to build complicated expressions from simpler

  • nes, or

break down complicated expressions as being simpler subexpressions, connected by connectives. Example: −(1 + 2)/(3 × 4) + (5 + 6 × 7)/(8 + 9) − 10 consists of −(1 + 2)/(3 × 4) and (5 + 6 × 7)/(8 + 9) − 10, connected by +.

Now break down these two subexpressions.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-41
SLIDE 41

Propositional Forms (cont’d)

Use connectives to build complicated expressions from simpler

  • nes, or

break down complicated expressions as being simpler subexpressions, connected by connectives. Example: −(1 + 2)/(3 × 4) + (5 + 6 × 7)/(8 + 9) − 10 consists of −(1 + 2)/(3 × 4) and (5 + 6 × 7)/(8 + 9) − 10, connected by +.

Now break down these two subexpressions. Now break down the four sub-subexpressions.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-42
SLIDE 42

Propositional Forms (cont’d)

Use connectives to build complicated expressions from simpler

  • nes, or

break down complicated expressions as being simpler subexpressions, connected by connectives. Example: −(1 + 2)/(3 × 4) + (5 + 6 × 7)/(8 + 9) − 10 consists of −(1 + 2)/(3 × 4) and (5 + 6 × 7)/(8 + 9) − 10, connected by +.

Now break down these two subexpressions. Now break down the four sub-subexpressions. And so forth.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-43
SLIDE 43

Propositional Forms (cont’d)

Systematize the process via a parse tree. Parse tree for −(1 + 2)/(3 × 4) + (5 + 6 × 7)/(8 + 9) − 10:

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-44
SLIDE 44

Propositional Forms (cont’d)

Systematize the process via a parse tree. Parse tree for −(1 + 2)/(3 × 4) + (5 + 6 × 7)/(8 + 9) − 10: + − 10 / + 9 8 + × 7 6 5 / × 4 3 − + 2 1

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-45
SLIDE 45

Propositional Forms (cont’d)

We’re inherently using the following rules:

1 Parenthesized subexpressions are evaluated first. 2 Operations have a precedence hierarchy: 1

Unary negations (for example, −1) are done first.

2

Multiplicative operations (× and /) are done next.

3

Additive operations (+ and −) are done last.

3 In case of a tie (two additive operations or two multiplicative

  • perations), the remaining operations are done from left to

right.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-46
SLIDE 46

Propositional Forms (cont’d)

We’re inherently using the following rules:

1 Parenthesized subexpressions are evaluated first. 2 Operations have a precedence hierarchy: 1

Unary negations (for example, −1) are done first.

2

Multiplicative operations (× and /) are done next.

3

Additive operations (+ and −) are done last.

3 In case of a tie (two additive operations or two multiplicative

  • perations), the remaining operations are done from left to

right. These guarantee that (e.g.) 2 + 3 × 4 is 10, rather than 14.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-47
SLIDE 47

Propositional Forms (cont’d)

Now jump from numerical algebra to propositional algebra.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-48
SLIDE 48

Propositional Forms (cont’d)

Now jump from numerical algebra to propositional algebra. We can build new (complicated) propositions out of old (simpler) ones.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-49
SLIDE 49

Propositional Forms (cont’d)

Now jump from numerical algebra to propositional algebra. We can build new (complicated) propositions out of old (simpler) ones. Example: [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)] consists of (p ∨ q) ∧ ((¬p) ∨ r) and (p ⇔ q) ∨ (p ∨ r), connected by ⇒.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-50
SLIDE 50

Propositional Forms (cont’d)

Now jump from numerical algebra to propositional algebra. We can build new (complicated) propositions out of old (simpler) ones. Example: [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)] consists of (p ∨ q) ∧ ((¬p) ∨ r) and (p ⇔ q) ∨ (p ∨ r), connected by ⇒.

Now break down these two subexpressions.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-51
SLIDE 51

Propositional Forms (cont’d)

Now jump from numerical algebra to propositional algebra. We can build new (complicated) propositions out of old (simpler) ones. Example: [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)] consists of (p ∨ q) ∧ ((¬p) ∨ r) and (p ⇔ q) ∨ (p ∨ r), connected by ⇒.

Now break down these two subexpressions. Now break down the four sub-subexpressions.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-52
SLIDE 52

Propositional Forms (cont’d)

Now jump from numerical algebra to propositional algebra. We can build new (complicated) propositions out of old (simpler) ones. Example: [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)] consists of (p ∨ q) ∧ ((¬p) ∨ r) and (p ⇔ q) ∨ (p ∨ r), connected by ⇒.

Now break down these two subexpressions. Now break down the four sub-subexpressions. And so forth.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-53
SLIDE 53

Propositional Forms (cont’d)

Parse tree for [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)]:

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-54
SLIDE 54

Propositional Forms (cont’d)

Parse tree for [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)]: ⇒ ∨ ∨ r p ⇔ q p ∧ ∨ r ¬ p ∨ q p

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-55
SLIDE 55

Propositional Forms (cont’d)

The expression [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)] is completely parenthesized (and hard to read). If we agree upon (standard) precedence rules, can get rid of extraneous parentheses.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-56
SLIDE 56

Propositional Forms (cont’d)

The expression [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)] is completely parenthesized (and hard to read). If we agree upon (standard) precedence rules, can get rid of extraneous parentheses.

1

Parenthesized subexpressions are evaluated first.

2

Operations have a precedence hierarchy:

1

Unary negations (¬) are done first.

2

Multiplicative operations (∧) are done next.

3

Additive operations (∨, ⊕) are done next.

4

The conditional-type operations (⇒ and ⇔) are done last.

3

In case of a tie (two operations at the same level in the hierarchy), operations are done in a left-to-right order, except for the conditional operator ⇒, which is done in a right-to-left

  • rder. That is, p ⇒ q ⇒ r is interpreted as p ⇒ (q ⇒ r).

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-57
SLIDE 57

Propositional Forms (cont’d)

So can replace [(p ∨ q) ∧ ((¬p) ∨ r)] ⇒ [(p ⇔ q) ∨ (p ∨ r)] by [(p ∨ q) ∧ (¬p ∨ r)] ⇒ [(p ⇔ q) ∨ p ∨ r]

  • r even

(p ∨ q) ∧ (¬p ∨ r) ⇒ (p ⇔ q) ∨ p ∨ r.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-58
SLIDE 58

Propositional Forms (cont’d)

Parse tree for (p ∨ q) ∧ (¬p ∨ r) ⇒ (p ⇔ q) ∨ p ∨ r:

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-59
SLIDE 59

Propositional Forms (cont’d)

Parse tree for (p ∨ q) ∧ (¬p ∨ r) ⇒ (p ⇔ q) ∨ p ∨ r: ⇒ ∨ ∨ r p ⇔ q p ∧ ∨ r ¬ p ∨ q p

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-60
SLIDE 60

Propositional Forms (cont’d)

Precedence rules are too hard to remember! Let’s simplify!

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-61
SLIDE 61

Propositional Forms (cont’d)

Precedence rules are too hard to remember! Let’s simplify!

1

Parenthesized subexpressions come first.

2

Multiplicative operation (∧), followed by additive operations (∨, ⊕).

3

Use parentheses if you have any doubt. Always use parentheses if you have multiple conditionals.

4

Evaluate ties left-to-right.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-62
SLIDE 62

From English to Propositions

Can use propositional forms to capture logical arguments in English. Help to expose logical fallacies.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-63
SLIDE 63

From English to Propositions

Can use propositional forms to capture logical arguments in English. Help to expose logical fallacies. Example: Alice will have coffee or Bob will go to the beach.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-64
SLIDE 64

From English to Propositions

Can use propositional forms to capture logical arguments in English. Help to expose logical fallacies. Example: Alice will have coffee or Bob will go to the beach. Let a = “Alice will have coffee” b = “Bob will go to the beach” Solution?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-65
SLIDE 65

From English to Propositions

Can use propositional forms to capture logical arguments in English. Help to expose logical fallacies. Example: Alice will have coffee or Bob will go to the beach. Let a = “Alice will have coffee” b = “Bob will go to the beach” Solution? a ∨ b.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-66
SLIDE 66

From English to Propositions

Can use propositional forms to capture logical arguments in English. Help to expose logical fallacies. Example: Alice will have coffee or Bob will go to the beach. Let a = “Alice will have coffee” b = “Bob will go to the beach” Solution? a ∨ b. Example: If I make peanut butter sandwiches for lunch, then Carol will be disappointed.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-67
SLIDE 67

From English to Propositions

Can use propositional forms to capture logical arguments in English. Help to expose logical fallacies. Example: Alice will have coffee or Bob will go to the beach. Let a = “Alice will have coffee” b = “Bob will go to the beach” Solution? a ∨ b. Example: If I make peanut butter sandwiches for lunch, then Carol will be disappointed. Let p = “I will make peanut butter sandwiches” c = “Carol will be disappointed” Solution?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-68
SLIDE 68

From English to Propositions

Can use propositional forms to capture logical arguments in English. Help to expose logical fallacies. Example: Alice will have coffee or Bob will go to the beach. Let a = “Alice will have coffee” b = “Bob will go to the beach” Solution? a ∨ b. Example: If I make peanut butter sandwiches for lunch, then Carol will be disappointed. Let p = “I will make peanut butter sandwiches” c = “Carol will be disappointed” Solution? p ⇒ c.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-69
SLIDE 69

From English to Propositions (cont’d)

Example: If Alice will have coffee and Bob will go to the beach, then either Carol will be disappointed or I will make peanut butter sandwiches. Solution?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-70
SLIDE 70

From English to Propositions (cont’d)

Example: If Alice will have coffee and Bob will go to the beach, then either Carol will be disappointed or I will make peanut butter sandwiches. Solution? a ∧ b ⇒ c ∨ p

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-71
SLIDE 71

From English to Propositions (cont’d)

Example: If Alice will have coffee and Bob will go to the beach, then either Carol will be disappointed or I will make peanut butter sandwiches. Solution? a ∧ b ⇒ c ∨ p Example: Alice will have coffee and Bob will not go to the beach if and only if Carol will be disappointed and I will not make peanut butter sandwiches. Solution?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-72
SLIDE 72

From English to Propositions (cont’d)

Example: If Alice will have coffee and Bob will go to the beach, then either Carol will be disappointed or I will make peanut butter sandwiches. Solution? a ∧ b ⇒ c ∨ p Example: Alice will have coffee and Bob will not go to the beach if and only if Carol will be disappointed and I will not make peanut butter sandwiches. Solution? (a ∧ ¬b) ⇔ (c ∧ ¬p)

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-73
SLIDE 73

Propositional Equivalence

High school algebra: establishes many useful rules, such as a + b = b + a, a × (b + c) = a × b + a × c, −(a + b) = (−a) + (−b), Anything analogous for propositions?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-74
SLIDE 74

Propositional Equivalence

High school algebra: establishes many useful rules, such as a + b = b + a, a × (b + c) = a × b + a × c, −(a + b) = (−a) + (−b), Anything analogous for propositions? How to state them? (No equal sign.) How to prove correct rules? How to disprove incorrect “rules”?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-75
SLIDE 75

Propositional Equivalence (cont’d)

Logical equivalence: p ≡ q means p is true if and only if q is true

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-76
SLIDE 76

Propositional Equivalence (cont’d)

Logical equivalence: p ≡ q means p is true if and only if q is true Beware!

  • p ≡ q is not a proposition; it’s a statement about propositions.

p ≡ q is a statement in a metalanguage about propositions. ≡ is a metasymbol in this language.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-77
SLIDE 77

Propositional Equivalence (cont’d)

Logical equivalence: p ≡ q means p is true if and only if q is true Beware!

  • p ≡ q is not a proposition; it’s a statement about propositions.

p ≡ q is a statement in a metalanguage about propositions. ≡ is a metasymbol in this language.

Analogous to a + b = b + a, a × (b + c) = a × b + a × c, −(a + b) = (−a) + (−b), we might conjecture that

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-78
SLIDE 78

Propositional Equivalence (cont’d)

Logical equivalence: p ≡ q means p is true if and only if q is true Beware!

  • p ≡ q is not a proposition; it’s a statement about propositions.

p ≡ q is a statement in a metalanguage about propositions. ≡ is a metasymbol in this language.

Analogous to a + b = b + a, a × (b + c) = a × b + a × c, −(a + b) = (−a) + (−b), we might conjecture that p ∨ q ≡ q ∨ p, p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r), ¬(p ∨ q) ≡ ¬p ∨ ¬q.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-79
SLIDE 79

Propositional Equivalence (cont’d)

Want to prove (or disprove) conjectured identites such as p ∨ q ≡ q ∨ p, p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r), ¬(p ∨ q) ≡ ¬p ∨ ¬q.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-80
SLIDE 80

Propositional Equivalence (cont’d)

Want to prove (or disprove) conjectured identites such as p ∨ q ≡ q ∨ p, p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r), ¬(p ∨ q) ≡ ¬p ∨ ¬q. How? Use a truth table.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-81
SLIDE 81

Propositional Equivalence (cont’d)

Want to prove (or disprove) conjectured identites such as p ∨ q ≡ q ∨ p, p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r), ¬(p ∨ q) ≡ ¬p ∨ ¬q. How? Use a truth table. Suppose that p and q are propositional formulas. The equivalence p ≡ q is true iff the truth tables for p and q are identical.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-82
SLIDE 82

Propositional Equivalence (cont’d)

Example: Is it true that p ∨ q ≡ q ∨ p?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-83
SLIDE 83

Propositional Equivalence (cont’d)

Example: Is it true that p ∨ q ≡ q ∨ p? p q p ∨ q T T T T F T F T T F F F

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-84
SLIDE 84

Propositional Equivalence (cont’d)

Example: Is it true that p ∨ q ≡ q ∨ p? p q p ∨ q T T T T F T F T T F F F p q q ∨ p T T T T F T F T T F F F

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-85
SLIDE 85

Propositional Equivalence (cont’d)

Example: Is it true that p ∨ q ≡ q ∨ p? p q p ∨ q T T T T F T F T T F F F p q q ∨ p T T T T F T F T T F F F They match! So p ∨ q ≡ q ∨ p. More compact form: p q p ∨ q q ∨ p T T T T T F T T F T T T F F F F

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-86
SLIDE 86

Propositional Equivalence (cont’d)

Example: Is it true that p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-87
SLIDE 87

Propositional Equivalence (cont’d)

Example: Is it true that p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)? p q r q ∨ r p ∧ (q ∨ r) p ∧ q p ∧ r (p ∧ q) ∨ (p ∧ r) T T T T T T T T T T F T T T F T T F T T T F T T T F F F F F F F F T T T F F F F F T F T F F F F F F T T F F F F F F F F F F F F

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-88
SLIDE 88

Propositional Equivalence (cont’d)

Example: Is it true that p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)? p q r q ∨ r p ∧ (q ∨ r) p ∧ q p ∧ r (p ∧ q) ∨ (p ∧ r) T T T T T T T T T T F T T T F T T F T T T F T T T F F F F F F F F T T T F F F F F T F T F F F F F F T T F F F F F F F F F F F F So p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r).

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-89
SLIDE 89

Propositional Equivalence (cont’d)

How to organize the table?

Two variables: TT, TF, FT, FF Three variables: TTT, TTF, TFT, TFF, FTT, FTF, FFT, FFF. General pattern?

Rightmost variable alternates: TFTFTFTF . . . Next alternates in pairs: TTFFTTFF . . . Next alternates in quadruples: TTTTFFFFTTTTFFFF . . .

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-90
SLIDE 90

Propositional Equivalence (cont’d)

How to organize the table?

Two variables: TT, TF, FT, FF Three variables: TTT, TTF, TFT, TFF, FTT, FTF, FFT, FFF. General pattern?

Rightmost variable alternates: TFTFTFTF . . . Next alternates in pairs: TTFFTTFF . . . Next alternates in quadruples: TTTTFFFFTTTTFFFF . . .

Size of table?

Two variables? 4 rows. Three variables? 8 rows. n variables?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-91
SLIDE 91

Propositional Equivalence (cont’d)

How to organize the table?

Two variables: TT, TF, FT, FF Three variables: TTT, TTF, TFT, TFF, FTT, FTF, FFT, FFF. General pattern?

Rightmost variable alternates: TFTFTFTF . . . Next alternates in pairs: TTFFTTFF . . . Next alternates in quadruples: TTTTFFFFTTTTFFFF . . .

Size of table?

Two variables? 4 rows. Three variables? 8 rows. n variables? 2n rows. Since 210 = 1024, you don’t want to do a 10-variable table.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-92
SLIDE 92

Propositional Equivalence (cont’d)

Example: Is it true that ¬(p ∨ q) ≡ ¬p ∨ ¬q?

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-93
SLIDE 93

Propositional Equivalence (cont’d)

Example: Is it true that ¬(p ∨ q) ≡ ¬p ∨ ¬q? p q p ∨ q ¬(p ∨ q) ¬p ¬q ¬p ∨ ¬q T T T F F F F T F T F F T T F T T F T F T F F F T T T T

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-94
SLIDE 94

Propositional Equivalence (cont’d)

Example: Is it true that ¬(p ∨ q) ≡ ¬p ∨ ¬q? p q p ∨ q ¬(p ∨ q) ¬p ¬q ¬p ∨ ¬q T T T F F F F T F T F F T T F T T F T F T F F F T T T T So it is not true that ¬(p ∨ q) ≡ ¬p ∨ ¬q!

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-95
SLIDE 95

Propositional Equivalence (cont’d)

Example: Rather than ¬(p ∨ q) ≡ ¬p ∨ ¬q, the correct formula is ¬(p ∨ q) ≡ ¬p ∧ ¬q

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-96
SLIDE 96

Propositional Equivalence (cont’d)

Example: Rather than ¬(p ∨ q) ≡ ¬p ∨ ¬q, the correct formula is ¬(p ∨ q) ≡ ¬p ∧ ¬q p q p ∨ q ¬(p ∨ q) ¬p ¬q ¬p ∧ ¬q T T T F F F F T F T F F T F F T T F T F F F F F T T T T The formula ¬(p ∧ q) ≡ ¬p ∨ ¬q is also correct. These formulas ¬(p ∨ q) ≡ ¬p ∧ ¬q ¬(p ∧ q) ≡ ¬p ∨ ¬q are called deMorgan’s laws.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-97
SLIDE 97

Propositional Equivalence (cont’d)

Some well-known propositional laws (we haven’t proved them all): Double Negation ¬¬p ≡ p Idempotent p ∧ p ≡ p Idempotent p ∨ p ≡ p Commutative p ∧ q ≡ q ∧ p Commutative p ∨ q ≡ q ∨ p Associative (p ∧ q) ∧ r ≡ p ∧ (q ∧ r) Associative (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) Distributive p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) Distributive p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) DeMorgan ¬(p ∧ q) ≡ (¬p) ∨ (¬q) DeMorgan ¬(p ∨ q) ≡ (¬p) ∧ (¬q) Modus Ponens [(p ⇒ q) ∧ p] ⇒ q Modus Tollens [(p ⇒ q) ∧ ¬q] ⇒ ¬p Contrapositive (p ⇒ q) ≡ (¬q ⇒ ¬p) Implication (p ⇒ q) ≡ (¬p ∨ q)

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-98
SLIDE 98

Propositional Equivalence (cont’d)

Once we’ve proved a given propositional law, we can use it to help prove new ones. Example: Let’s prove the exportation identity [(p ∧ q) ⇒ r] ≡ [p ⇒ (q ⇒ r)]. We have (p ∧ q) ⇒ r ≡ ¬(p ∧ q) ∨ r implication

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-99
SLIDE 99

Propositional Equivalence (cont’d)

Once we’ve proved a given propositional law, we can use it to help prove new ones. Example: Let’s prove the exportation identity [(p ∧ q) ⇒ r] ≡ [p ⇒ (q ⇒ r)]. We have (p ∧ q) ⇒ r ≡ ¬(p ∧ q) ∨ r implication ≡ (¬p ∨ ¬q) ∨ r DeMorgan

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-100
SLIDE 100

Propositional Equivalence (cont’d)

Once we’ve proved a given propositional law, we can use it to help prove new ones. Example: Let’s prove the exportation identity [(p ∧ q) ⇒ r] ≡ [p ⇒ (q ⇒ r)]. We have (p ∧ q) ⇒ r ≡ ¬(p ∧ q) ∨ r implication ≡ (¬p ∨ ¬q) ∨ r DeMorgan ≡ ¬p ∨ (¬q ∨ r) associative

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-101
SLIDE 101

Propositional Equivalence (cont’d)

Once we’ve proved a given propositional law, we can use it to help prove new ones. Example: Let’s prove the exportation identity [(p ∧ q) ⇒ r] ≡ [p ⇒ (q ⇒ r)]. We have (p ∧ q) ⇒ r ≡ ¬(p ∧ q) ∨ r implication ≡ (¬p ∨ ¬q) ∨ r DeMorgan ≡ ¬p ∨ (¬q ∨ r) associative ≡ ¬p ∨ (q ⇒ r) implication

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-102
SLIDE 102

Propositional Equivalence (cont’d)

Once we’ve proved a given propositional law, we can use it to help prove new ones. Example: Let’s prove the exportation identity [(p ∧ q) ⇒ r] ≡ [p ⇒ (q ⇒ r)]. We have (p ∧ q) ⇒ r ≡ ¬(p ∧ q) ∨ r implication ≡ (¬p ∨ ¬q) ∨ r DeMorgan ≡ ¬p ∨ (¬q ∨ r) associative ≡ ¬p ∨ (q ⇒ r) implication ≡ p ⇒ (q ⇒ r) implication as required.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-103
SLIDE 103

Propositional Equivalence (cont’d)

Duality: If p is a proposition that only uses the operations ¬, ∧, and ∨. If we replace all instances of ∧, ∨, T, and F in p by ∨, ∧, F, and T, respectively, we get a new proposition p∗, which is called the dual of p.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-104
SLIDE 104

Propositional Equivalence (cont’d)

Duality: If p is a proposition that only uses the operations ¬, ∧, and ∨. If we replace all instances of ∧, ∨, T, and F in p by ∨, ∧, F, and T, respectively, we get a new proposition p∗, which is called the dual of p. Example: The duals of p ∧ (q ∨ r) and (p ∨ q) ∧ (p ∨ r) are p ∨ (q ∧ r) and (p ∧ q) ∨ (p ∧ r).

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-105
SLIDE 105

Propositional Equivalence (cont’d)

Duality: If p is a proposition that only uses the operations ¬, ∧, and ∨. If we replace all instances of ∧, ∨, T, and F in p by ∨, ∧, F, and T, respectively, we get a new proposition p∗, which is called the dual of p. Example: The duals of p ∧ (q ∨ r) and (p ∨ q) ∧ (p ∨ r) are p ∨ (q ∧ r) and (p ∧ q) ∨ (p ∧ r). Duality Principle: If two propositions (which only use the

  • perations ¬, ∧, and ∨) are equivalent, then their duals are
  • equivalent. (Be lazy—save half the work!)

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-106
SLIDE 106

Propositional Equivalence (cont’d)

Example: Since the duals p ∧ (q ∨ r) and (p ∨ q) ∧ (p ∨ r) are p ∨ (q ∧ r) and (p ∧ q) ∨ (p ∧ r).

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-107
SLIDE 107

Propositional Equivalence (cont’d)

Example: Since the duals p ∧ (q ∨ r) and (p ∨ q) ∧ (p ∨ r) are p ∨ (q ∧ r) and (p ∧ q) ∨ (p ∧ r). and we had earlier proved that p ∧ (q ∨ r) ≡ (p ∨ q) ∧ (p ∨ r)

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-108
SLIDE 108

Propositional Equivalence (cont’d)

Example: Since the duals p ∧ (q ∨ r) and (p ∨ q) ∧ (p ∨ r) are p ∨ (q ∧ r) and (p ∧ q) ∨ (p ∧ r). and we had earlier proved that p ∧ (q ∨ r) ≡ (p ∨ q) ∧ (p ∨ r) we now know that p ∨ (q ∧ r) ≡ (p ∧ q) ∨ (p ∧ r). “for free”.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-109
SLIDE 109

Propositional Equivalence (cont’d)

Example: Since the duals of ¬(p ∨ q) and ¬p ∧ ¬q are ¬(p ∧ q) and ¬p ∨ ¬q and we had earlier proved that ¬(p ∨ q) ≡ ¬p ∧ ¬q,

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3

slide-110
SLIDE 110

Propositional Equivalence (cont’d)

Example: Since the duals of ¬(p ∨ q) and ¬p ∧ ¬q are ¬(p ∧ q) and ¬p ∨ ¬q and we had earlier proved that ¬(p ∨ q) ≡ ¬p ∧ ¬q, we now know that ¬(p ∧ q) ≡ ¬p ∨ ¬q “for free”.

Arthur G. Werschulz CISC 1100, Fall 2010 Chapter 3