CPSC 121: Models of Computation Module 7: Predicate Logic and - - PowerPoint PPT Presentation

cpsc 121 models of computation
SMART_READER_LITE
LIVE PREVIEW

CPSC 121: Models of Computation Module 7: Predicate Logic and - - PowerPoint PPT Presentation

CPSC 121: Models of Computation Module 7: Predicate Logic and Inferences Module 7: Predicate Logic and Inferences By the start of class, you should be able to: Determine the negation of any quantified statement. Given a quantified statement and


slide-1
SLIDE 1

CPSC 121: Models of Computation

Module 7: Predicate Logic and Inferences

slide-2
SLIDE 2

CPSC 121 – 2020W T1 2

Module 7: Predicate Logic and Inferences

By the start of class, you should be able to:

Determine the negation of any quantified statement. Given a quantified statement and an equivalence rule, apply the rule to create an equivalent statement (particularly the De Morgan’s and contrapositive rules). Prove and disprove quantified statements using the “challenge” method (Epp, 4th edition, page 119). Apply universal instantiation, universal modus ponens, and universal modus tollens to predicate logic statements that correspond to the rules’ premises to infer statements implied by the premises.

slide-3
SLIDE 3

CPSC 121 – 2020W T1 3

Module 7: Predicate Logic and Inferences

Quiz 7 feedback:

Once again well done overall. Two questions seemed more difficult (next slides). Not much to say about the open-ended question: most people gave correct strategies. Great!

slide-4
SLIDE 4

CPSC 121 – 2020W T1 4

How many of the following statements are log. equivalent to x B ∀ ∈ y C, ∃ ∈ P(x) → Q(y) ? ∀x B y C, ~Q(y) ∈ ∃ ∈ → ~P(x) ~ ( x B y C, P(x) ∃ ∈ ∀ ∈

^ ~Q(y))

~ ( x B y C, ~P(x) ∃ ∈ ∀ ∈

v Q(y))

∀y B x C, P(y) ∈ ∃ ∈ → Q(x) a) None of them b) One of them c) Two of them d) Three of them e) All four of them

Module 7: Predicate Logic and Inferences

slide-5
SLIDE 5

CPSC 121 – 2020W T1 6

Which of the following could be the result of applying one of the negation equivalence laws to the statement:

∀x D, Q(x)→[( y D, P(x, y)) ~( y D, P(x, y))] ∈ ∃ ∈ ∧ ∀ ∈ a) ∀x D, Q(x) → F ∈ b) F c) None: we can not apply the law to just the right side of the statement. d) None: the law doesn't match the right side of the statement.

Module 7: Predicate Logic and Inferences

slide-6
SLIDE 6

CPSC 121 – 2020W T1 8

Module 7: Predicate Logic and Inferences

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

CPSC 121: the BIG questions:

How can we convince ourselves that an algorithm does what it's supposed to do?

We continue discussing how to prove various types of predicate logic statements that arise when we discuss algorithm correctness.

slide-7
SLIDE 7

CPSC 121 – 2020W T1 9

Module 7: Predicate Logic and Inferences

By the end of this module, you should be able to:

Explore alternate forms of predicate logic statements using the logical equivalences you have already learned plus negation of quantifiers (a generalized form of De Morgan’s Law).

slide-8
SLIDE 8

CPSC 121 – 2020W T1 10

Module 7: Predicate Logic and Inferences

Pre-class quiz #8 is due Monday November 2nd at 19:00.

Assigned reading for the quiz:

Epp, 5th or 4th edition: 4.1, 4.6, 4.7, Theorem 4.4.1 Epp, 3rd edition: 3.1, 3.6, Theorem 3.4.1. Rosen, 6th edition: 1.6, 1.7. 3.4 (theorem 2 only). Rosen 7th edition: 1.7, 1.8, 4.1 (theorem 2 only).

Assignment #3 is due tomorrow at 19:00.

slide-9
SLIDE 9

CPSC 121 – 2020W T1 11

Module 7: Predicate Logic and Inferences

Pre-class quiz #9 is tentatively due Monday November 9th at 19:00

Epp, 5th or 4th edition: 12.2, pages 791 to 795. Epp, 3rd edition: 12.2, pages 745 to 747, 752 to 754 Rosen, 6th edition: 12.2 pages 796 to 798, 12.3 Rosen, 7th edition: 13.2 pages 858 to 861, 13.3

slide-10
SLIDE 10

CPSC 121 – 2020W T1 12

Module 7: Predicate Logic and Inferences

Summary

Thinking of quantifiers differently. Transformations: allowed or forbidden? The challenge method.

slide-11
SLIDE 11

CPSC 121 – 2020W T1 13

Module 7.1: Thinking of quantifiers differently

Suppose D contains values x1, x2, ..., xn What does x D, P(x) ∀ ∈ really mean? It's the same as P(x1) ^ P(x2) ^ ... ^ P(xn).

Similarly, ∃x D, P(x) ≡ P(x ∈

1) v P(x2) v ... v P(xn)

Thinking of quantifiers this way explains

Generalized De Morgan's laws. Universal instantiation Universal Modus Ponens, Tollens

slide-12
SLIDE 12

CPSC 121 – 2020W T1 14

Module 7.1: Thinking of quantifiers differently

Generalized De Morgan's laws:

~ x D, P(x) ∀ ∈ ≡ ~(P(x1) ^ P(x2) ^ ... ^ P(xn)) ≡ ~P(x1) v ~P(x2) v ... v ~P(xn) ≡ ∃x D, ~P(x) ∈ ~ x D, P(x) ∃ ∈ ≡ ~(P(x1) v P(x2) v ... v P(xn)) ≡ ~P(x1) ^ ~P(x2) ^ ... ^ ~P(xn) ≡ ∀x D, ~P(x) ∈

slide-13
SLIDE 13

CPSC 121 – 2020W T1 15

Module 7.1: Thinking of quantifiers differently

Exercise: rewrite the following definition to eliminate the negation sign:

~ c R ∃ ∈

+ n

∃ N n N, n ∈ ∀ ∈ ≥ n0 → f(n) ≤ cg(n)

slide-14
SLIDE 14

CPSC 121 – 2020W T1 18

Module 7: Predicate Logic and Inferences

Summary

Thinking of quantifiers differently. Transformations: allowed or forbidden? The challenge method.

slide-15
SLIDE 15

CPSC 121 – 2020W T1 19

Module 7.2: Transformations (allowed or forbidden?)

Universal instantiation: ( x D, P(x)) ^ (a D) → P(a) ∀ ∈ ∈ Proving it is a valid inference:

Suppose x D, P(x) ∀ ∈ is true. Hence P(x1) ^ P(x2) ^ ... ^ P(xn) holds. If a = xi is an element of D, then by specialization we have P(xi).

slide-16
SLIDE 16

CPSC 121 – 2020W T1 20

Module 7.2: Transformations (allowed or forbidden?)

Universal modus ponens:

Suppose

∀x D, P(x) → Q(x) ∈ is true. P(xi) holds where xi is an element of D.

Hence (P(x1) → Q(x1)) ^ ... ^ (P(xn)→ Q(xn)). By specialization P(xi) → Q(xi) holds. By modus ponens, we deduce Q(xi).

The same reasoning explains why universal modus tollens is valid.

slide-17
SLIDE 17

CPSC 121 – 2020W T1 21

Module 7.2: Transformations (allowed or forbidden?)

Consider existential instantiation: ∃x D, P(x) ∈ a D ∈ \P(a)

a) This argument is valid: P(a) is true. b) This argument is invalid: P(a) is false. c) This argument is invalid: P(a) might be false. d) This argument is invalid for another reason.

slide-18
SLIDE 18

CPSC 121 – 2020W T1 25

Module 7.2: Transformations (allowed or forbidden?)

Applying logical equivalences to predicate logic:

Suppose we have

∀x D, P(x) → Q(x) ∈

We know that

P(x) → Q(x) ≡ ~P(x) v Q(x)

We might want to write

∀x D, ~P(x) v Q(x) ∈

Is this valid?

slide-19
SLIDE 19

CPSC 121 – 2020W T1 26

Module 7.2: Transformations (allowed or forbidden?)

Which propositional logic equivalences apply to predicate logic?

a) Double negative, Identity, and De Morgan's (not all equivalences!) b) ~(P(x) → Q(x)) ≡ P(x) ~Q(x) ∧ c) Commutative, Associative, and the “definition of conditional” d) All propositional logic equivalences apply to predicate logic. e) None of the above.

slide-20
SLIDE 20

CPSC 121 – 2020W T1 28

Module 7.2: Transformations (allowed or forbidden?)

Applying rules of inference to predicate logic:

Suppose we have

∀x D, P(x) → Q(x) ∈

We know that

∀x D, P(x) ∈

We might want to write

∀x D, Q(x) ∈

Is this valid?

slide-21
SLIDE 21

CPSC 121 – 2020W T1 29

Module 7.2: Transformations (allowed or forbidden?)

Which rules of inference apply to predicate logic (without the need for careful considerations) ?

a) Modus ponens, modus tollens and elimination only. b) All rules apply, but only if they follow universal quantifiers, not existential quantifiers. c) All rules apply, but only if they follow existential quantifiers, not universal quantifiers. d) All rules apply, no matter what quantifiers are used. e) None of the above.

slide-22
SLIDE 22

CPSC 121 – 2020W T1 31

Module 7.2: Transformations (allowed or forbidden?)

The only rules we really need: Universal Instantiation: for any a in D ∀x D, P(x) ∈ P(a) Universal Generalization: P(x) for an arbitrary element x of D ∀x D, P(x) ∈

slide-23
SLIDE 23

CPSC 121 – 2020W T1 32

Module 7.2: Transformations (allowed or forbidden?)

The only rules we really need (continued) Existential Instantiation: ∃x D, P(x) ∈ P(w) for an unspecified (new) witness w in D Existential Generalization: P(a) for a given element a of D ∃x D, P(x) ∈

slide-24
SLIDE 24

CPSC 121 – 2020W T1 33

Module 7: Predicate Logic and Inferences

Summary

Thinking of quantifiers differently. Transformations: allowed or forbidden? The challenge method.

slide-25
SLIDE 25

CPSC 121 – 2020W T1 34

Module 7.3: The challenge method

The Challenge method:

A predicate logic statement is like a game with two players.

you (trying to prove the statement true) your adversary (trying to prove it false).

The two of you pick values for the quantified variables working from the left to right (i.e. inwards).

You pick the values of existentially quantified variables. Your adversary picks the values of universally quantified variables

slide-26
SLIDE 26

CPSC 121 – 2020W T1 35

Module 7.3: The challenge method

The Challenge method (continued):

If there is a strategy that allows you to always win, then the statement is true. If there is a strategy for your adversary that allows him/her to always win, then the statement is false.

What does it mean to have a winning strategy at Nim?

slide-27
SLIDE 27

CPSC 121 – 2020W T1 36

Module 7.3: The challenge method

Example 1: x Z, ∃ ∈

n

Z ∀ ∈

+, 2x < n

How would we say this in English? How would we prove this theorem?

Example 2: n N, x N, n < 2 ∀ ∈ ∃ ∈

x

How would we say this in English? How would we prove this theorem?

slide-28
SLIDE 28

CPSC 121 – 2020W T1 37

Module 7.3: The challenge method

Example 3: x N, ∃ ∈

n

N, n < 2 ∀ ∈

x

How would we say this in English? How would we prove this theorem?

How do we prove a statement is false?