CSE 2353 – September 8 th 2003

18
CSE 2353 – September 8 th 2003 Logic and Mathematical Proofs

description

CSE 2353 – September 8 th 2003. Logic and Mathematical Proofs. Negation, Specification, and Generalization. ~( x)[F(x)] = ~(x)[G(x)] =. Negation, etc. Which statement is incorrect? ~( x)[F(x)]  (x)[~F(x)] ~(x)[G(x)]  ( x)[~G(x)] (x)(y) [ P(x,y) ]  (y) (x) [ P(x,y) ]. - PowerPoint PPT Presentation

Transcript of CSE 2353 – September 8 th 2003

Page 1: CSE 2353 – September 8 th  2003

CSE 2353 – September 8th 2003

Logic and Mathematical Proofs

Page 2: CSE 2353 – September 8 th  2003

Negation, Specification, and Generalization

• ~(x)[F(x)] =

• ~(x)[G(x)] =

Page 3: CSE 2353 – September 8 th  2003

Negation, etc.

• Which statement is incorrect?

• ~(x)[F(x)] (x)[~F(x)]

• ~(x)[G(x)] (x)[~G(x)]

• (x)(y) [ P(x,y) ] (y) (x) [ P(x,y) ]

Page 4: CSE 2353 – September 8 th  2003

Foundations

• Axioms

• Theorems: (x) [T(x)]

• (A1 ^ A2 ^ A3 ^ … ^ An ^ P) -> Q

Page 5: CSE 2353 – September 8 th  2003

Proof Example

Prove: if n is even then n^2 is even– E(x) x is even– S(x) x^2 is even– (x) [E(x) -> S(x)]

Page 6: CSE 2353 – September 8 th  2003

Proof Example

Prove: if n and m are integers divisible by 3

Then nx+my is divisible by 3

– T(x) x is divisible by 3– Q(n,m) any number of the form nx+my is divisible by 3– (n) (m) [ (T(n) ^ T(m) ) -> Q(n,m) ]

Page 7: CSE 2353 – September 8 th  2003

ContrapositiveProof Example

Prove: if n^2 is even then n is even

Page 8: CSE 2353 – September 8 th  2003

ContrapositiveProof Example

Prove: if nm = 100 then n <=10 or m <=10

Page 9: CSE 2353 – September 8 th  2003

Induction Proofs

1. You can get to the first rung of a ladder.

2. Once you are on a rung, you can climb to the next one.

Or

1. P(1)

2. P(k) -> p(k+1)

Page 10: CSE 2353 – September 8 th  2003

Prove

1 + 3 + 5 + … + (2n-1) = n^2

Page 11: CSE 2353 – September 8 th  2003

Prove

1^2 + 2^2 + 3^2 + … + n^2 = n(n+1)(2n+1)/6

Page 12: CSE 2353 – September 8 th  2003

Prove

2^(3n) –1 is divisible by 7

Page 13: CSE 2353 – September 8 th  2003

Execution Time

• How many times will these loops process data?

read n;for i = 1 to n { for j = 1 to i { process_data(); }}

Page 14: CSE 2353 – September 8 th  2003

Loop Unrolling

i = 0

while (i < 12) {

process_data(i);

i = i + 1;

}

Page 15: CSE 2353 – September 8 th  2003

Loop Unrolling

i = 0

while (i < 12) {

process_data(i);

i = i + 1;

}

process_data(0); process_data(1); process_data(2); process_data(3); … process_data(12);

Page 16: CSE 2353 – September 8 th  2003

Loop Unrolling

i = 0

while (i < 12) {

process_data(i);

i = i + 1;

}

i = 0 while (i < 12) { process_data(i); process_data(i+1); process_data(i+2); i = i + 3;}

Page 17: CSE 2353 – September 8 th  2003

Loop Unrolling

read n;i = 0 while i < 4^n-1 { process_data(i); i = i + 1;}

read n; i = 0 while i < 4^n -1 { process_data(i); process_data(i+1); process_data(i+2); i = i + 3;}

Page 18: CSE 2353 – September 8 th  2003

Loop Unrolling

Is 4^n -1 divisible by 3 for all positive integers?