Mohamed G. Gouda CS 313K Fall 2012 Midterm 1 1. Let the domains of x and y be the set of all integers. Compute the truth values of the following quantified predicates: All x Exist y (x*y = x) Exist y All x (x*y = x) Exist x All y (x*y != x) All y Exist x (x*y != x) Sol: All x Exist y (x*y = x) = T Exist y All x (x*y = x) = T Exist x All y (x*y != x) = F All y Exist x (x*y != x) = F 2. Give a two-sided inference proof that proves (m < n) <=> (m+n)/2 < n. The domains of m and n are the set of real numbers. Sol: m < n <=> {Add n to both sides of "<"} m+n < 2n <=> {Divide both sides of "<" by 2} (m+n)/2 < n 3. Give a by-contradiction proof to prove (x is integer and y is not integer)=> (x+y = z is not integer). The domains of x, y, and z are the set of all real numbers. Sol: (x is integer and y is not integer and x+y = z is integer) => {(x is integer and z is integer)=>(z-x is integer)} (x is integer and y is not integer and x+y = z is integer and z-x = y is integer) <=> {(y is not integer and y is integer) <=> F} F 4. Give an indirect inference proof to prove: (3n + 2 is odd)=>(n is odd) where the domain of n is the set of all positive numbers. Sol: n is even <=> {Definition of even} n = 2k, for some integer k <=> {Compute 3n + 2} 3n + 2 = 6k + 2, for some integer k <=> {Arithmetics} 3n + 2 = 2(3k + 1), for some integer k => {3k + 1 is integer} 3n + 2 = 2l, for some integer l <=> {Definition of even} 3n + 2 is even 5. Give a by-contradiction proof to prove (a^2 + b^2) >= 2ab where the domains of a and b are the set of all real numbers. Sol: (a^2 + b^2) < 2ab <=> {Arithmetics} (a-b)^2 < 0 <=> {T <=> (a-b)^2 >= 0} (a-b)^2 < 0 and (a-b)^2 >= 0 <=> {P and not P <=> F} F 6. Give an induction proof to prove that, for every non-negative integer n, r^0 + r^1 + ... + r^n = (1 - r^(n+1))/(1-r) where the domain of r is the set of all real numbers excluding 1. Sol: Let P(n) be the predicate r^0 + r^1 + ... + r^n = (1 - r^(n+1))/(1-r) Base Case: n = 0: P(0) <=> r^0 = (1-r)/(1-r) <=> 1 = 1 <=> T Induction Step: for every n >= 0, P(n) => P(n+1) P(n) => r^0 + r^1 + ... + r^n = (1 - r^(n+1))/(1-r) => {Add r^(n+1) to both sides of "="} r^0 + r^1 + ... + r^(n+1) = (1 - r^(n+1))/(1-r) + r^(n+1) => {Arithmetics} r^0 + r^1 + ... + r^(n+1) = ((1 - r^(n+1)) + (1-r)*r^(n+1))/(1-r) => {Arithmetics} r^0 + r^1 + ... + r^(n+1) = (1 - r^(n+1) + r^(n+1) - r^(n+2))/(1-r) => {Arithmetics} r^0 + r^1 + ... + r^(n+1) = (1 - r^(n+2))/(1-r) => {Definition of P(n+1)} P(n+1)