This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: ’0
((0 UNIVERSITY OF TORONTO
4‘96 Faculty of Arts and Science
'94 DECEMBER EXAMINATIONS 2006
$0 030 236H1 F /¢ St. George Campus
Duration — 3 hours Aids allowed: none Student Number: I I I I I I I I I Last Name: First Name: Do not turn this page until you have received the signal to start.
(In the meantime, please ﬁll out the identiﬁcation section above, and read the instructions below.) This examination consists of 9 questions on 12 pages (including this one).
When you receive the signal to start, please make sure that your copy
of the examination is complete. If you need more space for one of your
solutions, use the reverse side of the page and indicate clearly the part of your work that should be marked. For 1 bonus mark: write your student number at the bottom of pages
2—12 of this test. Good Luck! Total Pages = 12 Page 1 #1;
#2:
#3;
#4:
#5;
#6:
#7:
#8:
#9: TOTAL: CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 1. [10 MARKS] Prove that 4”+1 + 52"“1 is a multiple of 21 for all natural numbers n 2 1. Student #2 Page 2 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 2. [12 MARKS] Prove that the following code for converting a binary representation int b to a number is correct: // Precondition: b is of type int .
int x = 0;
int i = 0;
while (i < b.1ength) {
x = 2 * x;
x = x + b[i]; i = i + 1;
}
Postcondition:
b.length—1
:1) = Z 1) [j] . 2b.length—J—1
i=0 Note that the 0th index is being treated as the leftmost bit. Hint: when you ‘weaken’ the Postcondition to make part of your Invariant, you should change two parts
of the Postcondition. Student #: Page 3 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Page 4 of 12 CONT’D. .. Student #: CSC 236H1 F FINAL EXAMINATION December 2006 Question 3. [8 MARKS] Consider the following code: // Precondition: x and y are positive.
int a = x;
int b = y;
while (a != b) {
if (a < b) {
a = a + x;
} else {
b=b+y;
}
} // Postcondition: a is the smallest positive multiple of x and y.
// (in other words, a is a positive multiple of x and y,
// and is no larger than any positive multiple of x and y) Part (a) [5 MARKS] State an appropriate loop invariant. Part (b) [3 MARKS] Assuming the loop terminates, use the invariant to prove the program is correct. Student #: Page 5 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 4. [6 MARKS] Let P, Q and R be Propositional Variables.
Express “exactly two of P, Q and R” are true, with a DNF formula and then with a CNF formula. Question 5. [7 MARKS] Produce a formula in Prenex Normal Form that is logically equivalent to: (3111400731) > V963W 21)) /\ (ﬂow 3!, 2)) Student #1 Page 6 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 6. [7 MARKS] Prove that
(P V Q) A (IP V ﬁQ) LEQV (—‘P /\ Q) V (162 /\ P) using the standard propositional equivalences listed below, without using truth tables or truth assignments. Standard Propositional Equivalences: sﬁP LEQV P
—.(PAQ) LEQV st—1Q
—.(PVQ) LEQV ﬁPA—IQ PAQ LEQV QAP
PVQ LEQV QVP PA(Q/\R) LEQV (PAQ)/\R PV(QVR LEQV (PVQ)VR PA(QVR LEQV (PAQ) PV(Q/\R LEQV (PVQ) PA(QVﬁQ LEQV P PV(Q/\—uQ) LEQV P PAP LEQV P
PVP LEQV P
P—>Q LEQV ﬁPVQ
PHQ LEQV (PAQ)V(—uP/\1Q) VVVV Student #: Page 7 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 7. [10 MARKS] Let EB be a new binary operator of propositional logic representing “exclusive or”:
T*(P) EB 7*(Q) is 1 iff exactly one of T*(P) and T*(Q) is 1. Prove that there is a boolean function from {0,1}2 —) {0,1} that can’t be represented by a Propositional
Formula built from the propositional variables PV = {:r, y} and operators {V, A, 69}. Student #: Page 8 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 8. [10 MARKS] Let L be a ﬁrstorder language with (at least) the variables x and y.
Give a deﬁnition by structural induction of the following function replace: For ﬁrstorder formulas F: replace(F) = F with all free x’s replaced by y. Student #2 Page 9 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 9. [20 MARKS] Part (a) [5 MARKS] For each state in the following DFSA (dead states not shown), give a regular expression corresponding to
the strings that end in that state. Part (b) [5 MARKS] Prove that if a DFSA accepts the language of reversed binary representations of multiples of 3, then the
DFSA requires at least 3 states. Student #2 Page 10 of 12 CONT’D. .. CSCZ36H1F FINAL EXAMINATION December 2006 Part (c) [5 MARKS] Draw an NFSA with at most 3 states that accepts the language described by the regular expression a* b* a*a. Part (d) [5 MARKS] Suppose L1 and L2 are regular languages over the same alphabet A.
Must the language {s E A* : if s 6 L1 then s 6 L2} then also be regular?
Brieﬂy justify your answer. Page 11 of 12 CONT’D... Student #: , , “1"“ 080 236H1 F FINAL EXAMINATION December 2006 Total Marks = 90 Student #2 Page 12 of 12 END OF EXAMINATION ...
View
Full Document
 Spring '10
 FarzanAzadeh

Click to edit the document details