------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Fall 2014 Midterm 3 ------------------------------------------------------------------------------ 1. (5 points) Let A be any set. Use direct inference to prove the predicate: (x in A) => ({x} sub A) ------------------------------------------------------------------------------- 2. (5 points) Let f:A-->B and g:B-->C be two functions. Use direct inference to prove the predicate: ((g.f) is injective) => (f is injective) ------------------------------------------------------------------------------ 3. (5 points) Let A be the set of non-negative integers. Also let f: A -> A be the function (All x in A, f(x) = x+1) Write down an argument that shows function f has no inverse. ----------------------------------------------------------------------------- 4. (5 points) Consider the following predicate: (f(n) is O(g(n))) <=> (f(n) is O(3*g(n))) A two-sided inference proof of this predicate is as follows. (f(n) is O(g(n))) <=> {hint 1} (Exist positive real numbers K and C, (All integer n, n>K, |f(n)| =< C*|g(n)|) ) <=> {hint 2} (Exist positive real numbers K and C, (All integer n, n>K, |f(n)| =< (C/3)*|3*g(n)|) ) <=> {hint 3} (Exist positive real numbers K and C/3, (All integer n, n>K, |f(n)| =< (C/3)*|3*g(n)|) ) <=> {hint 4} (f(n) is O(3*g(n))) Write down the four missing hints in this proof. ---------------------------------------------------------------------------- Solutions ---------------------------------------------------------------------------- 1. y in {x} => {definition of {x}} y = x => {x in A} y in A ---------------------------------------------------------------------------- 2. f(x1) = f(x2) => {g is a function} g(f(x1)) = g(f(x2)) => {definition of "."} (g.f)(x1) = (g.f)(x2) => {g.f is injective} x1 = x2 ---------------------------------------------------------------------------- 3. We show that f is not surjective and so it is not bijective and has no inverse. From definition of f, we have (Exist y in A, y = 0, not(Exist x in A, x+1 = y)) Thus f is not surjective --------------------------------------------------------------------------- 4. hint 1 : defintion of f(n) being O(g(n)) hint 2 : C*|g(n)| = (C/3)*|3*g(n)| hint 3 : (Exist positive reat number C, P(C/3)) <=> (Exist Positive real number C/3, P(C/3)) hint 4 : definition of f(n) being O(3*g(n)) ---------------------------------------------------------------------------