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
CmSc 180 A Discrete Mathematics Sample Final Exam - Solutions 1. Fill in the corresponding truth values (T or F) of the expressions P T T F F Q T F T F expression P Λ ¬Q ¬P V Q P → ¬Q ¬P → Q Value F F T F 2. Logical identities - fill in the right side PΛP= P PVP= P P V ~P = P Λ ~P = T F PVT= T PΛT= P PVF= P PΛF= F De Morgan’s Laws: ~( P V Q) = ~ P Λ ~ Q ~( P Λ Q) = ~ P V ~ Q 3. For the implication ~ P → Q indicate which of the following expressions is its contrapositive, its converse and its inverse (circle the correct one): Contrapositive: P → Q, P → ~Q, ~P → Q, Q → P, Q → ~P , ~Q → P Inverse: P → Q, P → ~Q, ~P → Q, Q → P, Q → ~P , ~Q → ~P Converse: P → Q, P → ~Q, ~P → Q, Q → P, Q → ~P , ~Q → ~P 1 P = “I go to the party” Q = “I catch the 8:05 bus” R = “I am late for work”, represent in propositional logic the statement below and write its negation. 4. Using “If I go to the party I will not catch the 8:05 bus and I will be late for work” Expression: P → (~Q Λ R) Negation: P Λ (Q V ~R) 5. In the next problems, translate the sentences in quantified expressions of predicate logic, write down the negated expression and then translate the negated expression in English. a. No tests are easy test(x), easy(x) expression: negation: x, test(x) → ~ easy(x) x, test(x) Λ easy(x) translation: Some tests are easy b. All lions are dangerous lion(x), dangerous(x) expression: x, lion(x) → dangerous(x) negation: x, lion(x) Λ ~dangerous(x) translation: Some lions are not dangerous c. Some students play soccer. student(x), play_soccer (x) expression: x, student(x) Λ play_soccer (x) negation: x, student(x) → ~ play_soccer (x) translation: No students play soccer 2 6. Determine whether the following arguments are valid or invalid. If valid, state the inference rules. If invalid, determine the type of error(s): a. Premises: Valid Invalid 1. If John is not playing, the team will win. 2. If the team does not win, the trip will be postponed. 3. John is playing. Therefore the trip is not postponed Let P = John is not playing Q = the team wins R = the trip is postponed The argument is as follows: ~P → Q ~Q → R P --------------------R The argument is invalid, because P and ~P → Q do not match any syllogism. The error is “inverse”, because the argument would be valid if “ P → Q” is equivalent to its inverse form “~P → ~Q”, but it is not equivalent. If instead of ~P → Q we had its inverse form P → ~Q then the argument would be valid: From P → ~Q and P we can conclude ~Q by MP, and then from ~Q and ~Q → R we can conclude R by MP b. Premises: Valid Invalid 1. If John is not playing, the team will not win. 2. If the team does not win, the trip will be postponed. 3.. The trip is not postponed Therefore John is playing 3 Let P = John is not playing Q = the team wins R = the trip is postponed The argument is as follows: ~P → ~Q ~Q → R ~R --------------------P This is a valid argument. By the hypothetical syllogism, from ~P → ~Q ~Q → R we obtain ~P → R Then we have: ~P → R ~R Applying MT we obtain the conclusion P c. Premises: Valid Invalid 1. If John is playing, the team will not win. 2. If the team does not win, the trip will be postponed. 3.. The trip is postponed Therefore John is not playing Let P = John is not playing Q = the team wins R = the trip is postponed The argument is as follows: P → ~Q ~Q → R R --------------------~P 4 This is invalid argument. First, by the hypothetical syllogism we obtain: P → ~Q ~Q → R therefore P → R Now the argument is: P→R R therefore ~P This does not match any syllogism. The type of the error in the above line of reasoning does not have a name. 7. Complete the identities A ~A = U Complementation Law A ~A = Ø Exclusion Law A U = A Identity Laws A Ø= A A U = U A Ø= Ø A A = A A A = A ~(~A) = A Domination Laws Idempotent Laws Double Complementation Law ~(A B) = ~A ~B De Morgan's Laws ~(A B) = ~A ~B 8. True or false? {3} {1, 2, 3} true false {3} {1, {2}, 3} true false 1 {1, {2}, 3} true false {1 } {{1} ,{2} , 3} true false 5 {1, 2} {{1, 2}, {3}} true false {1, 2} {{1, 2}, {3}} true false 9. Let A = {a,b}, B = {1,2,3} Write A x B: {(a,1), (a,2), (a,3), (b,1), (b,2), (b,3)} 10. Let A = {1, 2 } Write the power set of A: P(A) = {, {1}, {2}, {1,2}} 11. Let A = {x | 1 x < 4 V x > 7} Let B = {x | x < 3 V 6 x < 8} Find A B= {x| x < 4 V A B= { x| 1 x < 3 V ~A = {x<1V4x 7} 6x} 7<x<8} 12. Let A and B be sets. Write the formal definitions of difference, intersection and compliment: A – B = {x| x A x B} A B = {x| x A x B} ~A = {x| x A } 13. Consider the sets A = {1,2,3,4} and B = {a,b,c,d} with the specified properties 13.1. Construct a bijection from set A to set B {(1,a), (2,b), (3,c), (4,d)} 6 13.2. Construct a not “one-to-one” function from A to B. Is it an “onto” function? {(1,a), (2,a), (3,c), (4,c)}, not ”onto” 13.3. Construct a relation from A to be which is not a function {(1,a), (1,b) } 14. Let N be the set of natural numbers and N x N be its Cartesian product. Consider the relation R defined on N x N in the following way: R = { ((a,b), (c,d)) | a + b = c + d} Determine (without proof) the reflexivity, symmetry and transitivity of R. Is R a relation of equivalence? Reflexive, symmetrical, transitive, equivalence The proof is not required, but here it is provided for completeness of the solution Reflexivity. A relation R on a set A is reflexive, if xA, (x,x) R To show that the relation R given in the problem is reflexive, we need to show that (a,b) N x N, ((a,b),(a,b) R Proof version 1: direct proof Let (a,b) be an arbitrary element in N x N. Since a + b = a + b, by the definition of R we have that ((a,b),(a,b) R Since (a,b) was an arbitrary chosen element, we say that for all elements (a,b) in N x N, ((a,b),(a,b) R Therefore the relation is reflexive. Proof version 2: by contradiction Assume that R is not reflexive. This means that there is an element (a1, b1) in N x N, such that ((a1,b1),(a1,b1)) R. For any pair ((a,b),(c,d)) which is not in R, we have a + b c + d (otherwise it would be in R) Therefore fore the pair ((a1,b1),(a1,b1)) it should be true that a1 + b1 a1 + b1 However, this contradicts an algebraic axiom that says a = a Symmetry. The relation is symmetrical. Here is the direct proof: 7 By the definition of a symmetrical relation, we have to show that the following conditional is true: if ((a,b),(c,d)) R then ((c,d),(a,b) R. Let ((a,b),(c,d)) is an arbitrary element in R. By the definition of R we have: a + b = c + d. (1) By the axioms in algebra we have: if a + b = c + d then c + d = a + b (2) From (1) and (2) by MP we have: c + d = a + b (3) From (3) and by the definition of R we have ((c,d),(a,b) R ((a,b),(c,d)) was an arbitrary element in R. Therefore for all elements we have if ((a,b),(c,d)) R then ((c,d),(a,b) R Therefore R is symmetrical Transitivity R is transitive. Here is the proof by contradiction: By the definition of a transitive relation, we have to show that the following conditional is true: if ((a,b),(c,d)) R and ((c,d),(e,f)) R then ((a,b),(e,f)) R. (4) Assume that (4) is not true, then its negation should be true: ((a1,b1),(c1,d1)) R and ((c1,d1),(e1,f1)) R such that ((a1,b1),(e1,f1)) R (5) From (5) we have ((a1,b1),(c1,d1)) R From (6) and by the definition of R we have a1 + b1 = c1 + d1 From (5) we have ((c1,d1),(e1,f1)) R From (8) and by the definition of R we have c1 + d1 = e1 + f1 From (7),(9) and basic algebra we have a1 + b1 = e1 + f1 From (10) and by the definition of R we have ((a1,b1),(e1,f1)) R (11) contradicts (5) (6) (7) (8) (9) (10) (11) 15. Consider the set A = {1,2,3,4}. Circle the properties of the relations R1, R2 and R3, each defined on A below. R1 = {(1,1), (2,2), (3,3), (4,4), (1,2), (2,1)} Reflexive Irreflexive Symmetrical Anti-symmetrical Transitive neither neither Not transitive R2 = {(1,2), (2,1), (1,3), (3,1)} 8 Reflexive Irreflexive Symmetrical Anti-symmetrical Transitive neither neither Not transitive R3 = {(1,1) , (1,2), (2,1), (1,3), (3,4)} Reflexive Irreflexive Symmetrical Anti-symmetrical Transitive neither neither Not transitive In the counting problems below, whenever the solution is based on combinations and permutations, represent the solution by means of P(n,k) and/or C(n,k) with appropriate values for n and k. 16. A coin is tossed 10 times. In each case the outcome is heads or tails. 16.1. How many possible outcomes of the tossing experiment are there? 2 10 = 1024 16.2. In how many of the possible outcomes are exactly 5 heads obtained? We choose the positions of the heads in the sequence, the order does not matter: C(10,5) = P(10,5) / 5! = 10! / (5! * 5!) = 252 16.3. Which is more probable – to have exactly 5 heads or to have exactly 4 heads? Justify your answer. Exactly 5 heads are more probable Outcomes with exactly 5 heads: C(10,5) = 252 Outcomes with exactly 4 heads: C(10,4) = 210 16.4. In how many of the possible outcomes is at most one head obtained? “at most one head “ consists of two cases: a) no heads: C(10.0) b) exactly 1 head: C(10,1) Thus the possible outcomes are: C(10,0) + C(10,1) = 1 + 10 = 11 9 17. A test contains three groups of questions. The first group contains 5 questions each worth 10 points. The second group contains 8 questions each worth 5 points. The last group contains 5 questions each worth 3 points. To complete the test, students have to answer 2 questions in the first group, 5 questions in the second group and 3 questions in the third group. How many possible choices of test questions are there so that the test is completed? The order of the choices within each group does not matter. The choices in each group are independent on the choices in the other two groups C(5,2)*C(8,5)*C(5,3) = (5 . 4 /2)*(8 . 7.6.5.4 / (2.3.4.5)) * (5.4.3/(2.3)) = =10*56*10 = 5600 18. A chairman, vice-chairman, a treasurer and two assistants have to be chosen among a group of 10 persons. In how many ways can the choice be made? The chairman , the vice-chairman and the treasurer are chosen out of a group of 10 people: P(10,3) The assistants are chosen out of a group of 7 people: C(7,2) The choices are: P(10,3)*C(7,2) = C(10,2) * P(8,3) = 15120 19. Prove that the product of any two odd integers is odd. Let m = 2p – 1, n = 2q – 1 be two odd integers m*n = (2p – 1)*( 2q – 1) = 4pq -2p – 2q + 1 = 2(2pq – p – q) +1 Let s = 2pq – p – q, s is an integer. Therefore m*n = 2s + 1 This is the representation of an odd number, therefore the product of any two odd integers is odd 20. Prove that the intersection of two reflexive relations is reflexive Let R and S be two reflexive relations on a set A. By the def. of a reflexive relation, a A, (a,a) R (1) 10 a A, (a,a) S We have to show that a A, (a,a) R S Direct proof: The definition of intersection is: R S = {(a,b) | (a,b) R (a,b) S (2) (3) From (1), (2) and (3) we have that a A, (a,a) R S Proof by contradiction (this is longer, the direct proof is better): Assume that (3) is not true, therefore its negation is true: a1 A, such that (a1,a1) R S (4) (4) entails the existence of one of the following three cases : a) (a1,a1) is in S but not in R. However, R is reflexive and we have contradiction with (1) b) (a1,a1) is in R but not in S. However, S is reflexive and we have contradiction with (2) c) (a1,a1) is neither in R nor in S. This contradicts both (1) and (2). Thus (4) results in contradiction, there for (4) is not true, therefore the intersection is reflexive 21. Is the union of two transitive relations a transitive relation? Prove your statement We cannot determine whether the union of two transitive relations is transitive. In some cases it may be transitive, for example: A = {1,2,3}, R = {(1,1)}, S = {(2,3)} The union is {(1,1), (2,3)} – transitive. In other cases it is not transitive. Example: A = {1,2,3}, R = {(1,2}, S = {(2,3)} The union is {(1,2), (2,3)} – not transitive. 22. Prove using mathematical induction that for all integer n >0 we have 1 + 3 + 5 + … + (2n – 1) = n2 Let S(n) = 1 + 2 + 3 + … + (2n – 1) Let P(n) be the statement S(n) = n2 We will show that P(n) is true for all positive integer values of n 11 a. Base case Let n = 1 S(1) by the definition of the sum is 1 P(1) states that S(1) = 12 = 1 Therefore P(1) is true b. Inductive step We will show that P(k) → P(k+1) is true P(k) is the statement S(k) = k2 P(k+1) is the statement S(k+1) = (k+1)2 Assume that P(k) is true, i.e. S(k) = k2 S(k+1) = S(k) + (2(k+1) – 1) = k2 + 2k + 2 – 1 = k2 + 2k + 1 = (k+1)2 Therefore the statement S(k+1) = (k+1)2 is true Therefore P(k) → P(k+1) is true Therefore by the principle of mathematical induction for all integer n >0 we have 1 + 2 + 3 + … + (2n – 1) = n2 12