discrete structures of computer science theorems...

31
Outline Theorems Inference Rules Proof Methods Discrete Structures of Computer Science Theorems and Proofs Gazihan Alanku¸ s (Based on original slides by Brahim Hnich et al.) August 2, 2012 Gazihan Alanku¸ s (Based on original slides by Brahim Hnich et al.) Discrete Structures of Computer Science Theorems and Proof

Upload: haphuc

Post on 17-May-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

OutlineTheorems

Inference RulesProof Methods

Discrete Structures of Computer ScienceTheorems and Proofs

Gazihan Alankus(Based on original slides by Brahim Hnich et al.)

August 2, 2012

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Theorems

Inference Rules

Proof Methods

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

What is a theorem?

A theorem is a mathematical statement of certain importance

TheoremA quadratic equation ax2 + bx + c = 0 has at most 2 distinctsolutions.

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proving Theorems

I We know the rules of inference about propositionalstatements. What about quantified statements?

I The simplest method is the method of exhaustion:

I To prove that ∀x p(x), just verify that p(a) is true for allvalues a from the universe

I To prove that ∃x p(x), by checking all the values in theuniverse and finding a value a such that p(a) is true

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Rule of Universal Specification

I Reconsider the argumentEvery human is mortalSocrates is a human

∴ Socrates is mortal

I In symbolic form it looks like∀x (p(x)→ q(x))p(Socrates)

∴ q(Socrates)where p(x) stands for ’x is a human’q(x) stands for ’x is a mortal’

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Rule of Universal Specification

I Reconsider the argumentEvery human is mortalSocrates is a human

∴ Socrates is mortal

I In symbolic form it looks like∀x (p(x)→ q(x))p(Socrates)

∴ q(Socrates)where p(x) stands for ’x is a human’q(x) stands for ’x is a mortal’

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Rule of Universal Specification (cntd)

Rule of Universal Specification: If an open statement becomes truefor all values of the universe, then it is true for eachspecific individual value from that universe∀x p(x)

∴ p(c)

I ExamplePremises: ∀x (p(x)→ q(x)), p(Socrates)Conclusion: q(Socrates)

Step Reason

1. ∀x (p(x)→ q(x)) premise2. p(Socrates)→ q(Socrates) Rule of universal specification3. p(Socrates) premise4. q(Socrates) modus ponens

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Rule of Universal Generalization

Rule of Universal Generalization: If an open statement p(x) isproved to be true when x is assigned any arbitraryvalue from the universe, then the statement ∀x p(x)is also true

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Rule of Universal Generalization: Example

Premises: ∀x (p(x)→ q(x)), ∀x (q(x)→ r(x))Conclusion: ∀x (p(x)→ r(x))

Step Reason

1. ∀x (p(x)→ q(x)) premise2. p(c)→ q(c) (1), universal specification3. ∀x (q(x)→ r(x)) premise4. q(c)→ r(c) (3), universal specification5. p(c)→ r(c) (2), (4), law of syllogism6. ∀x (p(x)→ r(x)) (5), universal generalization

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Existential Rules

Rule of Existential Specification: If ∃x p(x) is true in a givenuniverse, then there is a value a in this universe withp(a) true

Rule of Existential Generalization: If p(a) is true for some value ain a given universe , then ∃x p(x) is true in theuniverse

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Direct Proofs

I Direct proofs are used when we need to prove statements like∀x (p(x)→ q(x))

I Main StepsOur goal is to prove that p(a)→ q(a) is a tautology for ageneric value a

1. Assume that p(a) is true2. Using axioms, previous theorems and laws, prove that q(a) is

true3. Conclude that p(a)→ q(a) is a tautology4. Use the rule of universal generalization to infer∀x (p(x)→ q(x))

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

Definitionn is even if and only if there is integer k such that n = 2k

TheoremIf n is even, then n2 is even

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

e(a): a is even

Theorem∀x (e(x)→ e(x2))

Step Reason

1. e(a) Assume the premise2. ∀x (e(x)↔ ∃y (x = 2y)) definition3. e(a)↔ ∃y (a = 2y) rule of universal specification4. ∃y (a = 2y) (1), (3), modus ponens5. a = 2k rule of existential specification6. a2 = 2(2k2) arithmetic7. ∃y (a2 = 2y) rule of existential generalization8. e(a2)↔ ∃y (a2 = 2y) (2), rule of universal specification9. e(a2) (7), (8), modus ponens

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition

I Sometimes direct proofs do not work

I Prove that if 3n + 2 is even, then n is also evenThat is ∀x(e(3x + 2)→ e(x))

I Let us try the direct approach:As for the generic value n the number 3n + 2 is even, for somek we have 3n + 2 = 2k. Therefore 3n = 2(k − 1). Now what?

I What if instead of ∀x (e(3x + 2)→ e(x)), we prove thecontrapositive:∀x (¬e(x)→ ¬e(3x + 2))?

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition

I Sometimes direct proofs do not work

I Prove that if 3n + 2 is even, then n is also evenThat is ∀x(e(3x + 2)→ e(x))

I Let us try the direct approach:As for the generic value n the number 3n + 2 is even, for somek we have 3n + 2 = 2k. Therefore 3n = 2(k − 1). Now what?

I What if instead of ∀x (e(3x + 2)→ e(x)), we prove thecontrapositive:∀x (¬e(x)→ ¬e(3x + 2))?

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition

I Sometimes direct proofs do not work

I Prove that if 3n + 2 is even, then n is also evenThat is ∀x(e(3x + 2)→ e(x))

I Let us try the direct approach:As for the generic value n the number 3n + 2 is even, for somek we have 3n + 2 = 2k. Therefore 3n = 2(k − 1). Now what?

I What if instead of ∀x (e(3x + 2)→ e(x)), we prove thecontrapositive:∀x (¬e(x)→ ¬e(3x + 2))?

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition

I Sometimes direct proofs do not work

I Prove that if 3n + 2 is even, then n is also evenThat is ∀x(e(3x + 2)→ e(x))

I Let us try the direct approach:As for the generic value n the number 3n + 2 is even, for somek we have 3n + 2 = 2k. Therefore 3n = 2(k − 1). Now what?

I What if instead of ∀x (e(3x + 2)→ e(x)), we prove thecontrapositive:∀x (¬e(x)→ ¬e(3x + 2))?

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition (cntd)

I So assume that n is odd

I Then, 3n is odd

I Then, 3n + 2 is odd.

I We have proved ¬e(3n + 2) is true, and therefore thecontraposition ¬e(n)→ ¬e(3n + 2) is true.

I Finally, we conclude that ∀x (e(3x + 2)→ e(x))(universal generalization)

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition (cntd)

I So assume that n is odd

I Then, 3n is odd

I Then, 3n + 2 is odd.

I We have proved ¬e(3n + 2) is true, and therefore thecontraposition ¬e(n)→ ¬e(3n + 2) is true.

I Finally, we conclude that ∀x (e(3x + 2)→ e(x))(universal generalization)

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition (cntd)

I So assume that n is odd

I Then, 3n is odd

I Then, 3n + 2 is odd.

I We have proved ¬e(3n + 2) is true, and therefore thecontraposition ¬e(n)→ ¬e(3n + 2) is true.

I Finally, we conclude that ∀x (e(3x + 2)→ e(x))(universal generalization)

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition (cntd)

I So assume that n is odd

I Then, 3n is odd

I Then, 3n + 2 is odd.

I We have proved ¬e(3n + 2) is true, and therefore thecontraposition ¬e(n)→ ¬e(3n + 2) is true.

I Finally, we conclude that ∀x (e(3x + 2)→ e(x))(universal generalization)

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition (cntd)

I So assume that n is odd

I Then, 3n is odd

I Then, 3n + 2 is odd.

I We have proved ¬e(3n + 2) is true, and therefore thecontraposition ¬e(n)→ ¬e(3n + 2) is true.

I Finally, we conclude that ∀x (e(3x + 2)→ e(x))(universal generalization)

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contraposition (cntd)

I Main StepsOur goal is to prove that p(a)→ q(a) is a tautology for ageneric value aInstead we prove that contrapositive ¬q(a)→ ¬p(a) is atautology for a generic value a

1. Assume that ¬q(a) is true2. Using axioms, previous theorems and laws, prove that ¬p(a) is

true3. Conclude that ¬q(a)→ ¬p(a) is a tautology4. Conclude that p(a)→ q(a) is a tautology5. Use the rule of universal generalization to infer∀x (p(x)→ q(x))

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proof by Contradiction

I Proofs by contradiction use the Rule of Contradiction¬p → F

∴ p

I Can be used to prove statements of any formI Main steps

1. Assume ¬p2. Using axioms, previous theorems and laws, infer a contradiction3. Conclude p

I Usually the contradiction has the form ∃x (p(x) ∧ ¬p(x))

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

Definitiona real number is said to be rational if it can be represented asfraction a

b where a and b are integers with no common factor

I Prove that√

2 is irrational

I Proof

I Suppose that√

2 is rational, that is there are integers a, bsuch that

√2 = a

b and a and b have no common factorI Squaring we obtain a2 = 2b2. Since a2 is even, a is also even,

hence a = 2c for some c .I Therefore 2b2 = 4c2, and so b2 = 2c2. Since a2 is even, a is

also even, hence a = 2c for some c .I Hence b is even.I We get that a and b have a common factor 2 which is a

contradiction.

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

Definitiona real number is said to be rational if it can be represented asfraction a

b where a and b are integers with no common factor

I Prove that√

2 is irrationalI Proof

I Suppose that√

2 is rational, that is there are integers a, bsuch that

√2 = a

b and a and b have no common factor

I Squaring we obtain a2 = 2b2. Since a2 is even, a is also even,hence a = 2c for some c .

I Therefore 2b2 = 4c2, and so b2 = 2c2. Since a2 is even, a isalso even, hence a = 2c for some c .

I Hence b is even.I We get that a and b have a common factor 2 which is a

contradiction.

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

Definitiona real number is said to be rational if it can be represented asfraction a

b where a and b are integers with no common factor

I Prove that√

2 is irrationalI Proof

I Suppose that√

2 is rational, that is there are integers a, bsuch that

√2 = a

b and a and b have no common factorI Squaring we obtain a2 = 2b2. Since a2 is even, a is also even,

hence a = 2c for some c .

I Therefore 2b2 = 4c2, and so b2 = 2c2. Since a2 is even, a isalso even, hence a = 2c for some c .

I Hence b is even.I We get that a and b have a common factor 2 which is a

contradiction.

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

Definitiona real number is said to be rational if it can be represented asfraction a

b where a and b are integers with no common factor

I Prove that√

2 is irrationalI Proof

I Suppose that√

2 is rational, that is there are integers a, bsuch that

√2 = a

b and a and b have no common factorI Squaring we obtain a2 = 2b2. Since a2 is even, a is also even,

hence a = 2c for some c .I Therefore 2b2 = 4c2, and so b2 = 2c2. Since a2 is even, a is

also even, hence a = 2c for some c .

I Hence b is even.I We get that a and b have a common factor 2 which is a

contradiction.

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

Definitiona real number is said to be rational if it can be represented asfraction a

b where a and b are integers with no common factor

I Prove that√

2 is irrationalI Proof

I Suppose that√

2 is rational, that is there are integers a, bsuch that

√2 = a

b and a and b have no common factorI Squaring we obtain a2 = 2b2. Since a2 is even, a is also even,

hence a = 2c for some c .I Therefore 2b2 = 4c2, and so b2 = 2c2. Since a2 is even, a is

also even, hence a = 2c for some c .I Hence b is even.

I We get that a and b have a common factor 2 which is acontradiction.

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Example

Definitiona real number is said to be rational if it can be represented asfraction a

b where a and b are integers with no common factor

I Prove that√

2 is irrationalI Proof

I Suppose that√

2 is rational, that is there are integers a, bsuch that

√2 = a

b and a and b have no common factorI Squaring we obtain a2 = 2b2. Since a2 is even, a is also even,

hence a = 2c for some c .I Therefore 2b2 = 4c2, and so b2 = 2c2. Since a2 is even, a is

also even, hence a = 2c for some c .I Hence b is even.I We get that a and b have a common factor 2 which is a

contradiction.

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs

OutlineTheorems

Inference RulesProof Methods

Proving Existential Statements

I How to prove ∃x p(x)

I Constructive proofs: find or construct a value a such thatp(a) is true

I Pure proofs of existence (by contradiction):

1. Assume that ∀x ¬p(x)2. Using axioms, previous theorems and laws, infer a contradiction3. Conclude ∃x p(x)

Gazihan Alankus (Based on original slides by Brahim Hnich et al.)Discrete Structures of Computer Science Theorems and Proofs