• Tidak ada hasil yang ditemukan

Discrete Mathematics for Computer Science I

N/A
N/A
Tri AB

Academic year: 2024

Membagikan "Discrete Mathematics for Computer Science I "

Copied!
27
0
0

Teks penuh

(1)

University of Hawaii

ICS141:

Discrete Mathematics for Computer Science I

Dept. Information & Computer Sci., University of Hawaii

Jan Stelovsky

based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross

Provided by McGraw-Hill

(2)

University of Hawaii

Lecture 6

Chapter 1. The Foundations

1.5 Rules of Inference

(3)

University of Hawaii

Previously…

n  Rules of inference

n  Modus ponens

n  Modus tollens

n  Hypothetical syllogism

n  Disjunctive syllogism

n  Resolution

n  Addition

n  Simplification

n  Conjunction Table 1 in pp.66

(4)

University of Hawaii

Resolution

n  p q Rule of Resolution

¬p r Tautology:

q r [(p q) ∧ (¬p r)] → (qr)

n  When q = r:

[(pq) ∧ (¬pq)] q

n  When r = F:

[(pq) ∧ (¬p)] q (Disjunctive syllogism)

(5)

University of Hawaii

Resolution: Example

n  Example: Use resolution to show that the hypotheses “Jasmine is skiing or it is not

snowing” and “It is snowing or Bart is playing hockey” imply that “Jasmine is skiing or Bart is playing hockey

p

¬p r

q

r q

p q

¬p r

q r

(6)

University of Hawaii

Formal Proofs

n  A formal proof of a conclusion C, given premises p1, p2,…, pn consists of a sequence of steps,

each of which applies some inference rule to premises or previously-proven statements to yield a new true statement (the conclusion).

n  A proof demonstrates that if the premises are true, then the conclusion is true.

(7)

University of Hawaii

Formal Proof Example

n  Suppose we have the following premises:

“It is not sunny and it is cold.”

“We will swim only if it is sunny.”

“If we do not swim, then we will canoe.”

“If we canoe, then we will be home by sunset.”

n  Given these premises, prove the conclusion

“We will be home by sunset” using inference rules.

(8)

University of Hawaii

Proof Example cont.

n  Step 1: Identify the propositions (Let us adopt the following abbreviations)

n  sunny = “It is sunny”; cold = “It is cold”;

swim = “We will swim”; canoe = “We will canoe”; sunset = “We will be home by sunset”.

n  Step 2: Identify the argument. (Build the argument form)

¬sunny cold swim sunny ¬swim canoe

canoe sunset sunset

It is not sunny and it is cold.

We will swim only if it is sunny.

If we do not swim, then we will canoe.

If we canoe, then we will be home by sunset.

We will be home by sunset.

(9)

University of Hawaii

Proof Example cont.

n  Step 3: Verify the reasoning using the rules of inference

Step Proved by

1. ¬sunny cold Premise #1.

2. ¬sunny Simplification of 1.

3. swim sunny Premise #2.

4. ¬swim Modus tollens on 2 and 3.

5. ¬swim canoe Premise #3.

6. canoe Modus ponens on 4 and 5.

7. canoe sunset Premise #4.

¬sunny cold swim sunny ¬swim canoe canoe sunset

sunset

(10)

University of Hawaii

Common Fallacies

n  A fallacy is an inference rule or other proof method that is not logically valid.

n  A fallacy may yield a false conclusion!

n  Fallacy of affirming the conclusion:

n p q is true, and q is true, so p must be true.” (No, because F T is true.)

n  Example

n  If David Cameron (DC) is president of the US, then he is at least 40 years old. (p q)

n  DC is at least 40 years old. (q)

n  Therefore, DC is president of the US. (p)

(11)

University of Hawaii

Common Fallacies (contd)

n  Fallacy of denying the hypothesis:

n p q is true, and p is false, so q must be false.” (No, again because F T is true.)

n  Example

n  If a person does arithmetic well then his/her checkbook will balance. (p q)

n  I cannot do arithmetic well. (¬p)

n  Therefore my checkbook does not balance.

q)

(12)

University of Hawaii

n  x P(x)

P(c) (substitute any specific member c in the domain)

n  P(c) (for an arbitrary element c of the domain)

∴∀x P(x)

n  x P(x)

P(c) (substitute an element c for which P(c) is true)

n  P(c) (for some element c in the domain)

∴∃x P(x)

Inference Rules for Quantifiers

(13)

University of Hawaii

Example

n  Every man has two legs. John Smith is a man.

Therefore, John Smith has two legs.

n  Proof

n  Define the predicates:

n  M(x): x is a man

n  L(x): x has two legs

n  J: John Smith, a member of the universe

n  The argument becomes 1. x [M(x) → L(x)]

2. M(J)

(14)

University of Hawaii

Example cont.

n  The proof is

1. ∀x [M(x) → L(x)]

2. M(J) → L(J)

3. M(J)

4. L(J)

n  Note: Using the rules of inference requires lots of practice.

n  Try example problems in the textbook.

Premise 2

U. I. from (1) Premise 1

Modus Ponens from (2) and (3)

x (M(x) L(x)) M(J)

L(J)

(15)

University of Hawaii

Another example

n  Correct or incorrect: “At least one of the 20 students in the class is intelligent. John is a student of this class. Therefore, John is

intelligent.”

n  First: Separate premises from conclusion

n  Premises:

1. At least one of the 20 students in the class is intelligent.

2. John is a student of this class.

n  Conclusion: John is intelligent.

(16)

University of Hawaii

Answer

n  Next, translate the example in logic notation.

n  Premise 1: At least one of the 20 students in the class is intelligent.

Let the domain = all people C(x) = “x is in the class”

I(x) = “x is intelligent”

Then Premise 1 says: x(C(x) I(x))

n  Premise 2: John is a student of this class.

Then Premise 2 says: C(John)

n  And the Conclusion says: I(John)

x (C(x) I(x)) C(John)

I(John)

(17)

University of Hawaii

Answer (contd)

n  No, the argument is invalid; we can disprove it with a counter-example, as follows:

n  Consider a case where there is only one intelligent student A in the class, and A John.

n  Then by existential instantiation of the premise

x (C(x) I(x)), C(A) I(A) is true,

n  But the conclusion I(John) is false, since A is the only intelligent student in the class, and John A.

n  Therefore, the premises do not imply the conclusion.

x (C(x) I(x)) C(John)

I(John)

(18)

University of Hawaii

More Proof Examples

n  Is this argument correct or incorrect?

n  “All TAs compose easy quizzes.

Mike is a TA.

Therefore, Mike composes easy quizzes.”

n  First, separate the premises from conclusion:

n  Premise 1: All TAs compose easy quizzes.

n  Premise 2: Mike is a TA.

n  Conclusion: Mike composes easy quizzes.

(19)

University of Hawaii

Answer

n  Next, re-render the example in logic notation.

n  Premise 1: All TAs compose easy quizzes.

n  Let the domain = all people

n  Let T(x) = “x is a TA”

n  Let E(x) = “x composes easy quizzes”

n  Then Premise 1 says: x(T(x) → E(x))

n  Premise 2: Mike is a TA.

n  Let M = Mike

n  Then Premise 2 says: T(M) And the Conclusion says: E(M)

x (T(x) E(x))

T(M) E(M)

(20)

University of Hawaii

The Proof in Gory Detail

n  The argument is correct, because it can be reduced to a sequence of applications of valid inference

rules, as follows:

n  Statement How obtained 1. ∀x(T(x) → E(x)) (Premise #1)

2. T(M) → E(M) (Universal Instantiation)

3. T(M) (Premise #2)

4. E(M) (Modus Ponens from #2 and #3)

x (T(x) E(x))

T(M)

E(M)

(21)

University of Hawaii

Another Example

n  Prove that the sum of a rational number and an irrational number is always irrational.

n  First, you have to understand exactly what the question is asking you to prove:

n  “For all real numbers x,y,

if x is rational and y is irrational, then x+y is irrational.”

n x,y: Rational(x) ∧ Irrational(y) → Irrational(x+y)

(22)

University of Hawaii

Answer

n  Next, think back to the definitions of the terms used in the statement of the theorem:

n  ∀ reals r : Rational(r) ↔

∃ Integer(i) ∧ Integer(j with ≠ 0): r = i/j.

n  ∀ reals r : Irrational(r) ↔ ¬Rational(r)

n  You almost always need the definitions of the terms in order to prove the theorem!

n  Next, let’s go through one valid proof:

(23)

University of Hawaii

What you might write

n  Theorem:

x,y : Rational(x) ∧ Irrational(y) Irrational(x+y)

n  Proof: Let x, y be any rational and irrational numbers, respectively. … (universal generalization)

n  Now, just from this, what do we know about x and y?

Think back to the definition of a rational number:

n  Since x is rational, we know (from the very definition of rational) that there must be some integers i and j

such that x = i /j. So, let ix,jx be such integers

n  Notice that gave them the unique names ix and jx so we can refer to them later.

(24)

University of Hawaii

What next?

n  What do we know about y? Only that y is irrational: ¬∃ integers i,j: y = i/j.

n  But, it’s difficult to see how to use a direct

proof in this case. So let’s try to use proof by contradiction.

n  So, what are we trying to show?

Just that x+y is irrational.

That is, ¬∃i,j: (x + y) = i/j.

n  Now we need to hypothesize the negation of this statement!

(25)

University of Hawaii

More writing…

n  Suppose that x+y were not irrational.

Then x + y would be rational, so ∃ integers i,j: x + y = i /j. So, let is and js be any such

integers where x + y = is / js.

n  Now, with all these things named, we can see what happens when we put them together.

n  So, we have that (ix/jx) + y = (is/js).

n  Notice: We have enough information now to conclude something useful about y, by solving this equation for it!

(26)

University of Hawaii

Finishing the Proof

n  Solving that equation for y, we have:

y = (is/js) – (ix/jx) = (isjxixjs)/(jsjx)

n  Now, since the numerator and denominator of this expression are both integers, y is rational

(by definition of a rational number).

n  This contradicts the assumption that y is irrational.

Therefore, our hypothesis that x+y is rational must be false, and so the theorem is proved.

(27)

University of Hawaii

Example of a Wrong Answer

n  1 is rational. √2 is irrational. 1+√2 is irrational.

Therefore, the sum of a rational number and an irrational number is irrational.

(Attempting a direct proof.)

n  Why does this answer deserve no credit?

n  We attempted to use an example to prove a universal statement.

This is always invalid!

n  Even as an example, it’s incomplete, because

Referensi

Dokumen terkait