Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Georg Cantor's first set theory article wikipedia , lookup
Line (geometry) wikipedia , lookup
Surreal number wikipedia , lookup
Infinitesimal wikipedia , lookup
Real number wikipedia , lookup
Hyperreal number wikipedia , lookup
Non-standard analysis wikipedia , lookup
Large numbers wikipedia , lookup
Non-standard calculus wikipedia , lookup
Collatz conjecture wikipedia , lookup
CS 40: Examination Department of Computer Science University of California, Santa Barbara Closed-Book, 75 minutes Fall 2006 Instructions • Before you answer any questions, print your name and perm number. • Read each question carefully. Make sure that you clearly understand each question before answering it. • Put your answer to each question on its own page. • You may wish to work out an answer on scratch paper before writing it on your answer page; answers that are difficult to read may lose points for that reason. • You may not leave the room during the examination, even to go to the bathroom. • You may not use any personal devices, such as calculators, PDAs, or cell phones. 1 1. (8 points) (a) Give the tautology that is the basis for the rule of inference called modus ponens. (p ∧ (p → q)) → q. (b) Prove that it is a tautology. p q p → q p ∧ (p → q) F F T F F T T F T F F F T T T T (p ∧ (p → q)) → q T T T T 2 2. (10 points) Let P (x) be the statement “student x know calculus” and let Q(y) be the statement “class y contains a student who knows calculus.” Express each of these a quantifications of P (x) and Q(y): (a) Some student knows calculus. ∃xP (x). (b) Not every student knows calculus. ∃x¬P (x). (c) Every class has a student in it who knows calculus. ∀yQ(y). (d) Every student in every class knows calculus. ∀xP (x). (e) There is at least 1 class with no students who know calculus. ∃y¬Q(y). 3 3. (8 points) What is the power set of {a, b, {a, b}}. {∅, {a}, {b}, {{a, b}}, {a, b}, {a, {a, b}}, {b, {a, b}}, {a, b, {a, b}}} 4 4. (8 points) What is the bit string corresponding to the symmetric difference of 2 sets? The bit string for the symmetric difference is obtained by taking the bitwise exclusive OR of the bit strings for the 2 sets, since we want to include those elements that are in one set or the other, but not both. 5 5. (12 points) Give an explicit formula for a function from the set of integers to the set of positive integers that is: (a) one-to-one, but not onto f (x) = 2x + 2, when x ≥ 0, and f (x) = −2x + 1, when x < 0. We do not need to express it as a 1-part formula, but we can: f (x) = 2|x| + 1 + b2x c/2x . It is one-to-one because nonnegative numbers map to even numbers, starting with 2; negative numbers map to odd numbers, starting with 3. It is not onto since 1 is not the image of any integer. (b) onto, but not one-to-one f (x) = |x| + 1. It is not one-to-one (e.g., f (−1) = f (1)). It is onto since i is the image of i − 1, for i = 1, 2, .... (c) one-to-one and onto f (x) = 2x + 2, when x ≥ 0, and f (x) = −2x − 1, when x < 0. x x We do not need to express it as a 1-part formula, but we can: f (x) = 2|x| − 2 + 4b2 c/2 . It is one-to-one because nonnegative numbers map to even numbers, starting with 2; negative numbers map to odd numbers, starting with 1. It is onto since each even number is the image of some positive number; each odd number is the image of some negative number. (d) neither one-to-one nor onto. f (x) = 1. It is not one-to-one (e.g., f (1) = f (−1)). It is not onto; the range is {1}. 6 6. (15 points) Construct a relation on the set {a, b, c, d} that is: (a) reflexive, symmetric, but not transitive. {(a, a), (b, b), (c, c), (d, d), (a, b), (b, a), (b, c), (c, b)}. (b) irreflexive, symmetric, and transitive. ∅ (c) irreflexive, antisymmetric, and not transitive. {(a, b), (b, c)} (d) reflexive, neither symmetric nor antisymmetric, and transitive. {(a, a), (b, b), (c, c), (d, d), (a, b), (b, c), (c, b), (a, c)} (e) neither reflexive, irreflexive, symmetric, antisymmetric, nor transitive. {(a, a), (a, b), (b, c), (c, b)} 7 7. (15 points) A relation R is called circular when (aRb ∧ bRc) → cRa. Show that if R is reflexive and circular then R is an equivalence relation. Proof: (a) bRb. (R is given to be reflexive.) (b) Let aRb. (c) aRb ∧ bRb → bRa. (R is given to be circular.) (d) bRa. (Steps a, b, and c, and modus ponens.) (e) R is symmetric. (Steps b and d.) (f) Let aRb and bRc. (g) aRb ∧ bRc → cRa. (R is given to be circular.) (h) cRa. (Steps f and g, and modus ponens.) (i) aRc. (Steps e and h.) (j) R is transitive. (Steps f and i.) (k) R is an equivalence relation. (R is given to be reflexive, and steps e, and j.) 8 8. (9 points) Find an ordering of the tasks of a software project if the Hasse diagram for the tasks of the project is as shown. Release test test Develop class A Integrate classes Develop class B Write documentation Develop class C Set up Test sites Develop system requirements Write functional requirements Determine user needs Figure 1: Hasse diagram of project tasks. (a) Determine user needs. (b) Write functional requirements. (c) Develop system requirements. (d) Set up test sites. (e) Write documentation. (f) Develop class A. (g) Develop class B. (h) Develop class C. (i) Integrate classes. (j) α test. (k) β test. (l) Release. 9 9. (15 points) The sequence of Fibonacci numbers is defined by f0 = 0, f1 = 1, and fn = fn−1 + fn−2 , for n = 2, 3, 4, ... The sequence of Lucas numbers is defined by l0 = 2, l1 = 1, and ln = ln−1 + ln−2 , for n = 2, 3, 4, .... Show that fn + fn+2 = ln+1 , whenever n is a positive integer, where fi and li are the ith Fibonacci number and the ith Lucas number, respectively. Proof: Basis n = 1: f1 + f3 = 1 + 2 = l1 + l0 = l2 . Inductive hypothesis: fk + fk+2 = lk+1 , for n ≤ k. Inductive step: fn+1 + fn+3 =fn + fn−1 + fn+2 + fn+1 =ln+1 + ln =ln+2 . (a) The first equality follows from the definition of the sequence of Fibonacci numbers. (b) The second equality follows from 2 applications of the inductive hypothesis: i. fn + fn+2 = ln+1 . ii. fn−1 + fn+1 = ln . (c) The last equality follows from the definition of the sequence of Lucas numbers. 10