Data structure chapter-1-proofs

20
Umm-AlQura University College of Computer Science & Information systems Discrete Structures Winter 2014 Dr. Sonia Hashish Chapter 1: Proofs Discrete Structures: Winter 2014. Dr. Sonia Hashish

Transcript of Data structure chapter-1-proofs

Umm-AlQura UniversityCollege of Computer Science & Information systems

Discrete StructuresWinter 2014

Dr. Sonia Hashish

Chapter 1: Proofs

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Theorem: a statement that can be shown to be true (sometimes referred toas facts or results). Less important theorems are often called propositions.

Axiom (or postulates) are statements that we assume to be true.

A conjecture is a statement that is being proposed as a true statement. Iflater proven, it becomes a theorem, but it may be false.

A corollary is a theorem proven as an easy consequence of a theorem.

A lemma is a less important theorem, used as an auxiliary result to prove amore important theorem.

A proof is a valid argument that establishes the truth of a theorem. Thestatements used in a proof include axioms, hypotheses (or premises), andpreviously proven theorems. Rules of inference, together with definition ofterms, are used to draw conclusions.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Many theorems assert that a property holds for all elements ina domain, such as the integers or the real numbers.

Although the precise statement of such theorems needs toinclude a universal quantifier, the standard convention inmathematics is to omit it.

For example, the statement “If x > y, where x and y arepositive real numbers, then x2 > y2 ” is the same as “For allpositive real numbers x and y, if x >y, then x2 > y2 ” whichformally can be written as ∀x ∀y (((x ≥ 0) ∧ (y ≥ 0) ∧ (x > y )→ (x2 > y2)).

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Discrete Structures: Winter 2014.Dr. Sonia Hashish

To prove a theorem of the form ∀x(P(x) → Q(x)), we start byproving that the implication: P(c) → Q(c) is true for an arbitraryelement c.

We can use any of the following methods to show thatpropositions based on the conditional statement p → q are true.

Direct proofs: Assume p is true; the last step establishes q is true. Proof by Contraposition: Uses a direct proof of the contrapositive

¬q →¬p. That is, assume ¬q is true; the last step establishes is ¬ptrue.

Proof by Contradiction: To prove that P is true, we assume ¬p istrue and reach a contradiction, that is (r ^ ¬ r) is true for someproposition r. In particular, to prove p → q ,we assume p → q isfalse, and get as a consequence a contradiction. Assuming that p→ q is false ≡ (p ^ ¬ q) is true.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

A formal direct proof of a conditional statement p → q:assume p is true, build steps using inference rules, with thefinal step showing that q is true.

Examples

Def.The integer n is even if there exists an integer k such that n =2k, and n is odd if there exists an integer k such that n = 2k + 1.

Def.The integer n is even if there exists an integer k such that n =2k, and n is odd if there exists an integer k such that n = 2k + 1.

Give a direct proof of the theorem“If n is an odd integer, then n2 is odd.”.

Give a direct proof of the theorem“If n is an odd integer, then n2 is odd.”.

Give a direct proof of the theorem“If n is an even integer, then n2 is even.”.

Give a direct proof of the theorem“If n is an even integer, then n2 is even.”.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

This theorem states ∀n (P (n) → Q(n)), where P(n) is “n is an oddinteger” and Q(n) is “n2 is odd.”

We start by showing that P(n) implies Q(n), we assume that thehypothesis of this conditional statement is true, that is “n is odd”.So n = 2k + 1(by def.), where k is some integer.

Then we find that n2= (2k + 1)2= 4k2+ 4k + 1 = 2(2k2+ 2k) + 1.By the definition of an odd integer, we can conclude that n2 is anodd integer (it is one more than twice an integer).

Consequently, we have proved that if n is an odd integer, then n2

is an odd integer. ▲

Give a direct proof of the theorem“If n is an odd integer, then n2 is odd.”.

Give a direct proof of the theorem“If n is an odd integer, then n2 is odd.”.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Proof: Let p=a/b for some integers a and b and let q =c/d for

some integers c and d then p+ q= a/b + c/d= (ad + bc)/bd (ad + bc) and bd are integers and bd ≠0 so p + q is

rational.

Give a direct proof of the theorem“The sum of two rational numbers is rational”.

“if p and q are rational numbers then p+q is rational”

Give a direct proof of the theorem“The sum of two rational numbers is rational”.

“if p and q are rational numbers then p+q is rational”

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Proof by contraposition make use of the fact that theconditional statement p → q is equivalent to its contrapositive,¬q →¬p.

This means that the conditional statement p → q can beproved by showing that its contrapositive, ¬q →¬p, is true.

In a proof by contraposition of p → q, we take ¬q as apremise, and using axioms, definitions, and previously proventheorems, together with rules of inference, we show that ¬pmust follow.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Assume that the conclusion of the conditional statement isfalse; namely, assume that n is even.

Then, n = 2k for some integer k. We then find that 3n + 2 = 3(2k) + 2 = 6k + 2 = 2(3k + 1).

So 3n + 2 is even and therefore not odd. This is the negation of the premise of the theorem. Because

the negation of the conclusion of the conditional statementimplies that the hypothesis is false, the original conditionalstatement is true.

Prove that if n is an integer and 3n + 2 is odd, then n is odd.Prove that if n is an integer and 3n + 2 is odd, then n is odd.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

We can use contrapositive of the theorem i.e.we prove that

Prove that “the square root of irrational number is irrational”.Prove that “the square root of irrational number is irrational”.

if r is irrational number then √r is also irrational.if r is irrational number then √r is also irrational.

if √r rational number then r is rational.if √r rational number then r is rational.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Proof: let √r= x/y where x and y are integers.Squaring both sides we get r=x2/y2 where x2 and y2 are integers,hence r is also rational.

if √r rational number then r is rational.if √r rational number then r is rational.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Proof by contradiction is another type of indirectproof.

We prove the proposition is true by showing that theproposition's being false would imply a contradiction.

This means that ¬p → q where q is a contradiction. Because the statement r ∧¬r is a contradiction

whenever r is a proposition, we can prove that p istrue if we can show that ¬p → (r ∧¬r) is true forsome proposition r.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Let p be “n is even” and q be “n2 is even.” To construct aproof by contradiction,

assume that both p and ¬q are true. That is, assume that n iseven and that n2 is odd.

So we have n2 = 2k+1 n2 -1=2k, (n-1)(n+1)=2k, both multiplicands are even or odd. They have to be to be even to provide “2k” This means n

must be odd which contradicts our assumption that n iseven.

Prove that if n is an even number then n2 is also even.Prove that if n is an even number then n2 is also even.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Assume that ¬p is true. Note that ¬p is the statement “It is not the case that √2 isirrational,” which says that √2 is rational. We will show that assuming that ¬p istrue leads to a contradiction.

If √2 is rational, there exist integers a and b with √2 = a/b, where b≠0 and a and bhave no common factors (so that the fraction a/b is in lowest terms.)

So 2 = a2 / b2 and 2b2 =a2

So a is an even number (We use the fact that “if the square of an integer is even theinteger is even), a can be written as a=2c

so 2b2 =4c2 and b2 =2c2

Both a and b are even which implies that 2 divides both of them.

Prove that √2 is irrational by giving a proof by contradiction.Prove that √2 is irrational by giving a proof by contradiction.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Let p be “3n + 2 is odd” and q be “n is odd.” To construct aproof by contradiction,

assume that both p and ¬q are true. That is, assume that 3n + 2is odd and that n is even.

Because n is even, there is an integer k such that n = 2k. Thisimplies that 3n + 2 = 3(2k) + 2 = 6k + 2 = 2(3k + 1). Because3n + 2 is 2t , where t = 3k + 1, 3n + 2 is even. This isequivalent to the statement ¬p, because an integer is even ifand only if it is not odd. Because both p and ¬p are true, wehave a contradiction. ▲

Give a proof by contradiction of the theorem “If 3n + 2 is odd,then n is odd.”Give a proof by contradiction of the theorem “If 3n + 2 is odd,then n is odd.”

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Split the proof into cases and prove each caseseparately

Must cover all possible cases When only finite instances are considered it turns to be

exhaustive proof.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Since n is not divisible by 5, it leaves a remainder of 1, 2, 3, or 4 when it isdivided by 5. These four cases exhaust all the possibilities {n=5k+1,n=5k+2, n=5k+3, n=5k+4}

For n=5k+1, n2 = (5k+1)2 =25k2+10k+1=5(5k2+2k)+1 which is divisible by5 with reminder 1.

For n=5k+2, n2 = (5k+2)2 =25k2+20k+4=5(5k2+4k)+4 which is divisible by5 with reminder 4.

For n=5k+3, (5k+3)2 =25k2+30k+9=5(5k2+6k+1)+4 which is divisible by 5with reminder 4.

For n=5k+4, (5k+4)2 =25k2+40k+16=5(5k2+8k+3)+1 which is divisible by5 with reminder 1.

Prove that if n is any integer which is not divisible by 5, then n2

leaves a remainder of 1 or 4 when it is divided by 5.Prove that if n is any integer which is not divisible by 5, then n2

leaves a remainder of 1 or 4 when it is divided by 5.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

Case 1. n is even, n=2k Case 2. n is odd, n=2k+1 For both cases, substitute into 3n2 + n+14 and reformat

so that we have it in the form 2(k’) to prove that it isan even.

Prove that if n is an integer, then 3n2 + n+14 is evenProve that if n is an integer, then 3n2 + n+14 is even

Discrete Structures: Winter 2014.Dr. Sonia Hashish

We use a proof by exhaustion, by examining the cases n= 1, 2.

for n=1 then 22 ≥31

for n=2 then 32 ≥32

Prove that (n + 1)2 ≥3n if n is a positiveinteger with n ≤ 2.Prove that (n + 1)2 ≥3n if n is a positiveinteger with n ≤ 2.

Discrete Structures: Winter 2014.Dr. Sonia Hashish

“Proof:" We use these steps, where a and b are two equal positive integers. Step Reason 1. a = b Given

2. a2= ab Multiply both sides of (1) by a

3. a2 - b2 = ab - b2 Subtract b2 from both sides of (2)

4. (a - b)(a + b) = b(a - b) Factor both sides of (3)

5. a + b = b Divide both sides of (4) by a - b

6. 2b = b Replace a by b in (5) as a = b and simplify

7. 2 = 1 Divide both sides of (6) by b

What is wrong with this famous supposed “proof”that 1 = 2?What is wrong with this famous supposed “proof”that 1 = 2?