University of Toronto Scarborough. Aids allowed: None... Duration: 3 hours.

Similar documents
University of Toronto Scarborough. Aids allowed: None... Duration: 3 hours.

Math 10850, fall 2017, University of Notre Dame

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions

CSE 355 Test 2, Fall 2016

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)

Preparing for the CS 173 (A) Fall 2018 Midterm 1

6.042/18.062J Mathematics for Computer Science March 9, 2005 Srini Devadas and Eric Lehman. Quiz 1. Ishan Christos Grant

CS154 Final Examination

Mid-Semester Quiz Second Semester, 2012

Discrete Mathematics Fall 2018 Midterm Exam Prof. Callahan. Section: NetID: Multiple Choice Question (30 questions in total, 4 points each)

CS103 Handout 12 Winter February 4, 2013 Practice Midterm Exam

CS154 Final Examination

Johns Hopkins Math Tournament Proof Round: Automata

Name: Mathematics 1C03

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600/COMP6260 (Formal Methods for Software Engineering)

Practice Midterm Exam Solutions

CSE 311: Foundations of Computing I Autumn 2014 Practice Final: Section X. Closed book, closed notes, no cell phones, no calculators.

Algorithms, Probability, and Computing Fall 08 Exam

Discrete Event Systems Exam

Computer Science Foundation Exam

University of California, San Diego Department of Computer Science and Engineering CSE 20. Solutions to Midterm Exam Winter 2018

3130CIT Theory of Computation

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination II (Fall 2007)

Midterm Exam Solution

UNIVERSITY OF VICTORIA DECEMBER EXAMINATIONS MATH 122: Logic and Foundations

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

PLEASE HAND IN PLEASE HAND IN. Solutions Sample

CS375: Logic and Theory of Computing

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

Introduction to Kleene Algebras

Examiners: R. Grinnell Date: April 19, 2013 E. Moore Time: 9:00 am Duration: 3 hours. Read these instructions:

(Note that these points are to give a relative sense of the weights on the final exam and have no bearing on extra credit points)

Problem 1: Suppose A, B, C and D are finite sets such that A B = C D and C = D. Prove or disprove: A = B.

CS 514, Mathematics for Computer Science Mid-semester Exam, Autumn 2017 Department of Computer Science and Engineering IIT Guwahati

CS 151 Complexity Theory Spring Solution Set 5

Calculus with the Graphing Calculator

b) Write the contrapositive of this given statement: If I finish ALEKS, then I get points.

Approximation Algorithms

Automata Theory, Computability and Complexity

Packet #1: Logic & Proofs. Applied Discrete Mathematics

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Discrete Mathematics (CS503)

CpSc 421 Final Exam December 15, 2006

CS173 Lecture B, September 10, 2015

10. The GNFA method is used to show that

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering)

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

THE LOGIC OF QUANTIFIED STATEMENTS. Predicates and Quantified Statements I. Predicates and Quantified Statements I CHAPTER 3 SECTION 3.

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

University of Ottawa CSI 2101 Midterm Test Instructor: Lucia Moura. February 9, :30 pm Duration: 1:50 hs. Closed book, no calculators

Intro to Theory of Computation

CS375 Midterm Exam Solution Set (Fall 2017)

Equational Logic. Chapter Syntax Terms and Term Algebras

Comp487/587 - Boolean Formulas

Topics in Logic and Proofs

Math 230 Final Exam, Spring 2008

Propositional and Predicate Logic - II

Sample Examination VI 203

Regular Expressions and Language Properties

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

FIRST ORDER SENTENCES ON G(n, p), ZERO-ONE LAWS, ALMOST SURE AND COMPLETE THEORIES ON SPARSE RANDOM GRAPHS

Part V. Intractable Problems

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

2018 Pascal Contest (Grade 9)

PUSHDOWN AUTOMATA (PDA)

MA 125 CALCULUS I FALL 2006 December 08, 2006 FINAL EXAM. Name (Print last name first):... Instructor:... Section:... PART I

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms

Context-Free Languages

Definition 2. Conjunction of p and q

*EXAM 1* EECS 203 Spring 2016

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSCE 551 Final Exam, Spring 2004 Answer Key

Tecniche di Verifica. Introduction to Propositional Logic

Context-free grammars and languages

Fall 2014 CMSC250/250H Midterm II

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M004: Blue) 6 December Points Possible

Regular Languages and Finite Automata

CIS 375 Intro to Discrete Mathematics Exam 1 (Section M004: Blue) 6 October Points Possible


The Pumping Lemma and Closure Properties

CS156: The Calculus of Computation Zohar Manna Autumn 2008

3 The language of proof

452 FINAL- VERSION E Do not open this exam until you are told. Read these instructions:

Your Name: UVa Id:

Math 230 Final Exam, Spring 2009

a. See the textbook for examples of proving logical equivalence using truth tables. b. There is a real number x for which f (x) < 0. (x 1) 2 > 0.

Test Bank Questions. (a) Is there an integer n such that n has? (b) Does there exist such that if n is divided by 4 the remainder is 1 and if?

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M001: Green) 6 December Points Possible

Name: Student ID: Instructions:

CSE 20 DISCRETE MATH WINTER

Solutions to Sample Problems for Midterm

Automata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles

Discrete Mathematics and Probability Theory Summer 2014 James Cook Midterm 1 (Version B)

Regular Resolution Lower Bounds for the Weak Pigeonhole Principle

Readings: Conjecture. Theorem. Rosen Section 1.5

Transcription:

University of Toronto Scarborough CSC B36 Final Examination 12 December 2017 NAME: (circle your last name) STUDENT NUMBER: Do not begin until you are told to do so. In the meantime, put your name and student number on this cover page and read the rest of this page. Aids allowed: None.... Duration: 3 hours. There are 9 pages and each is numbered at the bottom. Make sure you have all of them. Write legibly in the space provided. Use the backs of pages for rough work; they will not be graded. 1. / 10 2. / 20 3. / 12 4. / 8 5. / 15 6. / 5 7. / 10 Total / 80 Fall 2017 cscb36 Final Exam Page 1 of 9

1. [10 marks total; 5 for each part] For the purpose of this question, we define a real number x to be positive rational if and only if there exist positive integers p,q such that x = p q. Let PR be the smallest set such that Basis: 2017 PR. Induction Step: If x,y PR, then (i) 1 x PR and (ii) x+y PR. (a) Use structural induction to prove that every number in PR is positive rational. Remember to use proper proof structure when proving that a number is positive rational. (b) Let p and q be arbitrary positive integers. Informally explain why p q PR. Fall 2017 cscb36 Final Exam Page 2 of 9

2. [20 marks] Given a list L of integers, we define E(L) to be the number of even integers in L. For example, if L is [4,8,8,9,6,3,4], then E(L[: 3]) is 3 and E(L[3 :]) is 2. Loosely speaking, the program below takes a list L and returns the number of even integers in the second half of L minus the number of even integers in the first half of L. Furthermore, the variables n and h do not change values after they are initialized. So you may treat them as constants. They are there mainly to save you from having to repeatedly write len(l) and len(l). Use methods from class to prove the program below correct with respect to its given specification. Precondition: L is a list of integers. Postcondition: Return E(L[h :]) E(L[: h]), where h = len(l) 2. For example, if L is [4,8,8,9,6,3,4], then h is 3 and 2 3 = 1 is returned. DiffNumEvens(L) 1 n = len(l); h = n 2 ; 2 while i < n: j = h; i = 0; s = 1; t = 0 3 if L[j] is even: 4 t = t+s 5 i = i+1; s = s; j = j +s i 6 return t 2 [more space available on next page...] Fall 2017 cscb36 Final Exam Page 3 of 9

[... additional space for question 2] Fall 2017 cscb36 Final Exam Page 4 of 9

3. [12 marks total; 6 for each part] For each of the following implications, state whether it holds for arbitrary regular expressions R, S and T. Justify your answers. You will receive no credit without correct justification. (a) If R S S R, then RS SR. (b) If R ST, T SR and SRT STR, then RT TR. Fall 2017 cscb36 Final Exam Page 5 of 9

4. [8 marks] Let L = {1 i 0 j : i,j N and j < i < 2j}. Use the Pumping Lemma to prove that L is not regular. Fall 2017 cscb36 Final Exam Page 6 of 9

5. [15 marks total] Let L = {1 i 0 j : i,j N and j < i < 2j}. This is the same language as in question 4. (a) [1 mark] Give the shortest string in L. No justification is required. (b) [7 marks] Using as few productions as possible, give a CFG for L and explain why it is correct. (c) [7 marks] Give a PDA that accepts L and explain why it is correct. Fall 2017 cscb36 Final Exam Page 7 of 9

6. [5 marks] We define a ternary boolean function called AdjacentOnes by the following truth table. x y z AdjacentOnes(x, y, z) 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Use the given truth table to write a DNF formula and a CNF formula that represent AdjacentOnes. No justification is required. Your DNF formula: Your CNF formula: Fall 2017 cscb36 Final Exam Page 8 of 9

7. [10 marks total] Consider a first-order language with binary predicate B and equality predicate =. Recall from class that a binary predicate B on a domain D can be represented by a directed graph, where each node in the graph represents an element in D and an arrow from node x to node y is used to indicate B(x,y) = 1. Put another way, node x pointing to node y means B(x,y) is true. Here are 3 formulas along with the statements they express. F 1 x y B(x,y) Every node points to some node. F 2 x y B(y,x) Every node is pointed to by some node. F 3 x y (B(x,y) B(y,x)) No node points to a node that points back to it. (a) [4 marks] Write formulas F 4 and F 5 to express the following statements. F 4 : Some node points to more than one node. F 5 : Some node is pointed to by more than one node. (b) [3 marks] For this part we let our domain be D = {i : 0 < i n, where i,n N}. I.e., D = {1,2,,n}. Use the pigeonhole principle to explain why when restricted to domain D, (F 1 F 4 ) logically implies F 5. (c) [3 marks] Prove that (F 1 F 2 F 3 F 4 ) does not logically imply F 5. Fall 2017 cscb36 Final Exam Page 9 of 9