180 likes | 309 Views
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) ].
E N D
CSE 2353 – September 8th 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) ]
Foundations • Axioms • Theorems: (x) [T(x)] • (A1 ^ A2 ^ A3 ^ … ^ An ^ P) -> Q
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)]
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) ]
ContrapositiveProof Example Prove: if n^2 is even then n is even
ContrapositiveProof Example Prove: if nm = 100 then n <=10 or m <=10
Induction Proofs • You can get to the first rung of a ladder. • Once you are on a rung, you can climb to the next one. Or • P(1) • P(k) -> p(k+1)
Prove 1 + 3 + 5 + … + (2n-1) = n^2
Prove 1^2 + 2^2 + 3^2 + … + n^2 = n(n+1)(2n+1)/6
Prove 2^(3n) –1 is divisible by 7
Execution Time • How many times will these loops process data? read n; for i = 1 to n { for j = 1 to i { process_data(); } }
Loop Unrolling i = 0 while (i < 12) { process_data(i); i = i + 1; }
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);
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; }
Loop Unrolling read n; i = 0 while i < 4^n -1 { process_data(i); process_data(i+1); process_data(i+2); i = i + 3; } read n; i = 0 while i < 4^n-1 { process_data(i); i = i + 1; }
Loop Unrolling Is 4^n -1 divisible by 3 for all positive integers?