CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Similar documents
CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Math/EECS 1028M: Discrete Mathematics for Engineers Winter Suprakash Datta

Theory of Computation Lecture 1. Dr. Nahla Belal

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 154 Introduction to Automata and Complexity Theory

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Automata Theory, Computability and Complexity

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Mathematical Preliminaries. Sipser pages 1-28

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

COM364 Automata Theory Lecture Note 2 - Nondeterminism

CS 581: Introduction to the Theory of Computation! Lecture 1!

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Computer Sciences Department

Sri vidya college of engineering and technology

CSE 20. Final Review. CSE 20: Final Review

CS 154, Lecture 3: DFA NFA, Regular Expressions

Automata Theory and Formal Grammars: Lecture 1

CSE 105 THEORY OF COMPUTATION

EECS 1028 M: Discrete Mathematics for Engineers

Finite Automata Part Two

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Preliminaries to the Theory of Computation

Introduction to Automata

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

Automata Theory for Presburger Arithmetic Logic

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Finite Automata and Regular languages

Theory of Computation (I) Yijia Chen Fudan University

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CSE 3101: Introduction to the Design and Analysis of Algorithms. Office hours (Las/CSEB 3043): Tue 6-7 pm, Wed 4-6 pm or by appointment.

Fall 2014 CMSC250/250H Midterm II

Models of Computation. by Costas Busch, LSU

EECS 1028 M: Discrete Mathematics for Engineers

CSC173 Workshop: 13 Sept. Notes

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Theory of Computation

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

CSE 105 THEORY OF COMPUTATION

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Introduction. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

CPSC 421: Tutorial #1

CSE 105 Theory of Computation

CS 340: Discrete Structures for Engineers

Computational Models

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

CS6901: review of Theory of Computation and Algorithms

Economics 204 Summer/Fall 2017 Lecture 1 Monday July 17, 2017

Basic Proof Examples

Announcements. Problem Set Four due Thursday at 7:00PM (right before the midterm).

CS 208: Automata Theory and Logic

Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Decidability (What, stuff is unsolvable?)

Sets are one of the basic building blocks for the types of objects considered in discrete mathematics.

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

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

Computational Models - Lecture 5 1

CSE 105 Theory of Computation Professor Jeanne Ferrante

Intro to Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

Computational Models - Lecture 4

CA320 - Computability & Complexity

Chapter 2: The Basics. slides 2017, David Doty ECS 220: Theory of Computation based on The Nature of Computation by Moore and Mertens

MATH 341, Section 001 FALL 2014 Introduction to the Language and Practice of Mathematics

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

MATH 2200 Final LC Review

3515ICT: Theory of Computation. Regular languages

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

Tools for reasoning: Logic. Ch. 1: Introduction to Propositional Logic Truth values, truth tables Boolean logic: Implications:

Discrete Mathematics. (c) Marcin Sydow. Sets. Set operations. Sets. Set identities Number sets. Pair. Power Set. Venn diagrams

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

Final exam study sheet for CS3719 Turing machines and decidability.

Quiz 3 Reminder and Midterm Results

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

CSE 20 DISCRETE MATH. Winter

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

CS3719 Theory of Computation and Algorithms

Today. Proof using contrapositive. Compound Propositions. Manipulating Propositions. Tautology

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Deterministic Finite Automata (DFAs)

1 Computational Problems

Advanced topic: Space complexity

Deterministic Finite Automata (DFAs)

Computational Models - Lecture 1 1

Propositional Logic, Predicates, and Equivalence

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Practice Midterm Exam Solutions

Induction and Recursion

CSE 105 THEORY OF COMPUTATION

Transcription:

CSE 2001: Introduction to Theory of Computation Fall 2012 Suprakash Datta datta@cse.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/2001 9/6/2012 CSE 2001, Fall 2012 1

Administrivia Lectures: Tue, Thu 4-5:30 pm (CLH J) Textbook: Office hours: Tues 5:30-7 pm, Wed 4-6 pm (CSEB 3043), or by appointment. TA: Paria Mehrani, will lead problemsolving sessions. Another grader will only grade some homework, no office hours. http://www.cs.yorku.ca/course/2001 Webpage: All announcements/handouts will be published on the webpage -- check often for updates) Michael Sipser. Introduction to the Theory of Computation, Third Edition. Cengage Learning, 2013. 9/6/2012 CSE 2001, Fall 2012 2

Administrivia contd. Grading: 2 Midterms : 20% + 20% (in class) Final: 40% Assignments (4 sets): 20% Grades will be on epost (linked from the web page) Notes: 1. All assignments are individual. 2. There MAY be 1-2 extra credit quizzes. These will be announced beforehand. 9/6/2012 CSE 2001, Fall 2012 3

Administrivia contd. Plagiarism: Will be dealt with very strictly. Read the detailed policies on the webpage. Handouts (including solutions): in /cs/course/2001 Slides: Will usually be on the web the morning of the class. The slides are for MY convenience and for helping you recollect the material covered. They are not a substitute for, or a comprehensive summary of, the textbook. Resources: We will follow the textbook closely. There are more resources than you can possibly read including books, lecture slides and notes. 9/6/2012 CSE 2001, Fall 2012 4

Recommended strategy This is an applied Mathematics course -- practice instead of reading. Try to get as much as possible from the lectures. If you need help, get in touch with me early. If at all possible, try to come to the class with a fresh mind. Keep the big picture in mind. ALWAYS. 9/6/2012 CSE 2001, Fall 2012 5

Course objectives - 1 Reasoning about computation Different computation models Finite Automata Pushdown Automata Turing Machines What these models can and cannot do 9/6/2012 CSE 2001, Fall 2012 6

Course objectives - 2 What does it mean to say there does not exist an algorithm for this problem? Reason about the hardness of problems Eventually, build up a hierarchy of problems based on their hardness. 9/6/2012 CSE 2001, Fall 2012 7

Course objectives - 3 We are concerned with solvability, NOT efficiency. CSE 3101 (Design and Analysis of Algorithms) efficiency issues. 9/6/2012 CSE 2001, Fall 2012 8

Reasoning about Computation Computational problems may be Solvable, quickly Solvable in principle, but takes an infeasible amount of time (e.g. thousands of years on the fastest computers available) (provably) not solvable 9/6/2012 CSE 2001, Fall 2012 9

Theory of Computation: parts Automata Theory (CSE 2001) Complexity Theory (CSE 3101, 4115) Computability Theory (CSE 2001, 4101) 9/6/2012 CSE 2001, Fall 2012 10

Reasoning about Computation - 2 Need formal reasoning to make credible conclusions Mathematics is the language developed for formal reasoning As far as possible, we want our reasoning to be intuitive 9/6/2012 CSE 2001, Fall 2012 11

Next: Ch. 0:Set notation and languages Sets and sequences Tuples Functions and relations Graphs Boolean logic: Review of proof techniques Construction, Contradiction, Induction Some of these slides are adapted from Wim van Dam s slides (www.cs.berkeley.edu/~vandam/cs172/) and from Nathaly Verwaal (http://cpsc.ucalgary.ca/~verwaal/313/f2005) 9/6/2012 CSE 2001, Fall 2012 12

Topics you should know: Elementary set theory Elementary logic Functions Graphs 9/6/2012 CSE 2001, Fall 2012 13

Set Theory review Definition Notation: A = { x x N, x mod 3 = 1} N = {1,2,3, } Union: A B Intersection: A B Complement: A Cardinality: A Cartesian Product: A B = { (x,y) x A and y B} 9/6/2012 CSE 2001, Fall 2012 14

Some Examples L <6 = { x x N, x<6 } L prime = {x x N, x is prime} L <6 L prime = {2,3,5} = {0,1} = {(0,0), (0,1), (1,0), (1,1)} Formal: A B = { x x A and x B} 9/6/2012 CSE 2001, Fall 2012 15

Power set Set of all subsets Formal: P (A) = { S S A} Example: A = {x,y} P (A) = { {}, {x}, {y}, {x,y} } Note the different sizes: for finite sets P (A) = 2 A A A = A 2 9/6/2012 CSE 2001, Fall 2012 16

Graphs: review Nodes, edges, weights Undirected, directed Cycles, trees Connected 9/6/2012 CSE 2001, Fall 2012 17

Logic: review Boolean logic: Quantifiers:, statement: Suppose x N, y N. Then x y y > x for any integer, there exists a larger integer : a b is the same as (is logically equivalent to) a b : a b is logically equivalent to (a b) (b a) 9/6/2012 CSE 2001, Fall 2012 18

Logic: review - 2 Contrapositive and converse: the converse of a b is b a the contrapositive of a b is b a Any statement is logically equivalent to its contrapositive, but not to its converse. 9/6/2012 CSE 2001, Fall 2012 19

Logic: review - 3 Negation of statements ( x y y > x) = x y y x (LHS: negation of for any integer, there exists a larger integer, RHS: there exists a largest integer) TRY: (a b) =? 9/6/2012 CSE 2001, Fall 2012 20

Logic: review - 4 Understand quantifiers x y P(y, x) is not the same as y x P(y, x) Consider P(y,x ): x y. x y x y is TRUE over N (set y = x + 1) y x x y is FALSE over N (there is no largest number in N) 9/6/2012 CSE 2001, Fall 2012 21

f: A C f: A x B C Functions: review Examples: f: N N, f(x) = 2x f: N x N N, f(x,y) = x + y f: A x B A, A = {a,b}, B = {0,1} 0 1 a a b b b a 9/6/2012 CSE 2001, Fall 2012 22

Functions: an alternate view Functions as lists of pairs or k-tuples E.g. f(x) = 2x {(1,2), (2,4), (3,6),.} For the function below: {(a,0,a),(a,1,b),(b,0,b),(b,1,a)} 0 1 a a b b b a 9/6/2012 CSE 2001, Fall 2012 23

Next: Terminology Alphabets Strings Languages Problems, decision problems 9/6/2012 CSE 2001, Fall 2012 24

Alphabets An alphabet is a finite non-empty set. An alphabet is generally denoted by the symbols Σ,. Elements of Σ, called symbols, are often denoted by lowercase letters, e.g., a,b,x,y,.. 9/6/2012 CSE 2001, Fall 2012 25

Strings (or words) Defined over an alphabet Σ Is a finite sequence of symbols from Σ Length of string w ( w ) length of sequence ε the empty string is the unique string with zero length. Concatenation of w 1 and w 2 copy of w 1 followed by copy of w 2 x k = x x x x x x( k times) w R - reversed string; e.g. if w = abcd then w R = dcba. Lexicographic ordering : definition 9/6/2012 CSE 2001, Fall 2012 26

Languages A language over Σ is a set of strings over Σ Σ * is the set of all strings over Σ A language L over Σ is a subset of Σ * (L Σ * ) Typical examples: - ={0,1}, the possible words over are the finite bit strings. - L = { x x is a bit string with two zeros } -L = {a n b n n N } -L = {1 n n is prime} 9/6/2012 CSE 2001, Fall 2012 27

Concatenation of languages Concatenation of two langauges: A B = { xy x A and y B } Caveat: Do not confuse the concatenation of languages with the Cartesian product of sets. For example, let A = {0,00} then A A = { 00, 000, 0000 } with A A =3, A A = { (0,0), (0,00), (00,0), (00,00) } with A A =4 9/6/2012 CSE 2001, Fall 2012 28

Problems and Languages Problem: defined using input and output compute the shortest path in a graph sorting a list of numbers finding the mean of a set of numbers. Decision Problem: output is yes/no (or 1/0) Language: set of all inputs where output is yes 9/6/2012 CSE 2001, Fall 2012 29

Historical perspective Many models of computation from different fields Mathematical logic Linguistics Theory of Computation Formal language theory 9/6/2012 CSE 2001, Fall 2012 30

Input/output vs decision problems Input/output problem: find the mean of n integers Decision Problem: output is either yes or no Is the mean of the n numbers equal to k? You can solve the decision problem if and only if you can solve the input/output problem. 9/6/2012 CSE 2001, Fall 2012 31

Example Code Reachability Code Reachability Problem: Input: Java computer code Output: Lines of unreachable code. Code Reachability Decision Problem: Input: Java computer code and line number Output: Yes, if the line is reachable for some input, no otherwise. Code Reachability Language: Set of strings that denote Java code and reachable line. 9/6/2012 CSE 2001, Fall 2012 32

Example String Length Decision Problem: Input: String w Output: Yes, if w is even Language: Set of all strings of even length. 9/6/2012 CSE 2001, Fall 2012 33

Relationship to functions Use the set of k-tuples view of functions from before. A function is a set of k-tuples (words) and therefore a language. Shortest paths in graphs the set of shortest paths is a set of paths (words) and therefore a language. 9/6/2012 CSE 2001, Fall 2012 34

Recognizing languages Automata/Machines accept languages. Also called recognizing languages. The power of a computing model is related to, and described by, the languages it accepts/recognizes. Tool for studying different models 9/6/2012 CSE 2001, Fall 2012 35

Recognizing Languages - 2 Let L be a language S a machine M recognizes L if x S M accept reject if and only if x L if and only if x L 9/6/2012 CSE 2001, Fall 2012 36

Recognizing languages - 3 Minimal spanning tree problem solver cost tree Yes/no 9/6/2012 CSE 2001, Fall 2012 37

Recognizing languages - 4 Tools from language theory Expressibility of languages Fascinating relationship between the complexity of problems and power of languages 9/6/2012 CSE 2001, Fall 2012 38

Proofs What is a proof? Does a proof need mathematical symbols? What makes a proof incorrect? How does one come up with a proof? 9/6/2012 CSE 2001, Fall 2012 39

Proof techniques (Sipser 0.4) Proof by cases. Proof by contrapositive Proof by contradiction Proof by construction Proof by induction Others.. 9/6/2012 CSE 2001, Fall 2012 40

Proof by cases If n is an integer, then n(n+1)/2 is an integer Case 1: n is even. or n = 2a, for some integer a So n(n+1)/2 = 2a*(n+1)/2 = a*(n+1), which is an integer. Case 2: n is odd. n+1 is even, or n+1 = 2a, for an integer a So n(n+1)/2 = n*2a/2 = n*a, which is an integer. 9/6/2012 CSE 2001, Fall 2012 41

Proof by contrapositive - 1 If x 2 is even, then x is even Proof 1 (DIRECT): x 2 = x*x = 2a So 2 divides x. Proof 2: prove the contrapositive! if x is odd, then x 2 is odd. x = 2b + 1. So x 2 = 4b 2 + 4b + 1 (odd) 9/6/2012 CSE 2001, Fall 2012 42

Proof by contrapositive - 2 If (pq) (p+q)/2, then p q Proof 1: By squaring and transposing (p+q) 2 4pq, or p 2 +q 2 +2pq 4pq, or p 2 +q 2-2pq 0, or (p-q) 2 0, or p-q 0, or p q. Proof 2: prove the contrapositive! If p = q, then (pq) = (p+q)/2 Easy: (pq) = (pp) = (p 2 ) = p = (p+p)/2 = (p+q)/2. 9/6/2012 CSE 2001, Fall 2012 43

Proof by contradiction 2 is irrational Suppose 2 is rational. Then 2 = p/q, such that p, q have no common factors. Squaring and transposing, p 2 = 2q 2 (even number) So, p is even (previous slide) Or p = 2x for some integer x So 4x 2 = 2q 2 or q 2 = 2x 2 So, q is even (previous slide) So, p,q are both even they have a common factor of 2. CONTRADICTION. So 2 is NOT rational. Q.E.D. 9/6/2012 CSE 2001, Fall 2012 44

Proof by construction There exists irrational b,c, such that b c is rational Consider 2 2. Two cases are possible: Case 1: 2 2 is rational DONE (b = c = 2). Case 2: 2 2 is irrational Let b = 2 2, c = 2. Then b c = ( 2 2 ) 2 = ( 2) 2* 2 = ( 2) 2 = 2 9/6/2012 CSE 2001, Fall 2012 45

Debug this proof For each positive real number a, there exists a real number x such that x 2 >a Proof: We know that 2a > a So (2a) 2 = 4a 2 > a So use x = 2a. 9/6/2012 CSE 2001, Fall 2012 46

Proof by induction Format: Inductive hypothesis, Base case, Inductive step. 9/6/2012 CSE 2001, Fall 2012 47

Proof by induction Prove: For any n N, n 3 -n is divisible by 3. IH: P(n): For any n N, f(n)=n 3 -n is divisible by 3. Base case: P(1) is true, because f(1)=0. Inductive step: Assume P(n) is true. Show P(n+1) is true. Observe that f(n+1) f (n) = 3(n 2 + n) So f(n+1) f (n) is divisible by 3. Since P(n) is true, f(n) is divisible by 3. So f(n+1) is divisible by 3. Therefore, P(n+1) is true. Exercise: give a direct proof. 9/6/2012 CSE 2001, Fall 2012 48

Next: Finite automata Ch. 1: Deterministic finite automata (DFA) Look ahead: We will study languages recognized by finite automata. 9/6/2012 CSE 2001, Fall 2012 49