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

Similar documents
Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

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

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

Nondeterministic Finite Automata

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Theory of Computation Lecture 1. Dr. Nahla Belal

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture 3: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata

CS243, Logic and Computation Nondeterministic finite automata

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

CS 154 Introduction to Automata and Complexity Theory

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 455/555: Finite automata

Inf2A: Converting from NFAs to DFAs and Closure Properties

Chapter 6: NFA Applications

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Course 4 Finite Automata/Finite State Machines

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Computational Models Lecture 2 1

Computational Models Lecture 2 1

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Turing Machines Part III

Deterministic Finite Automata (DFAs)

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Deterministic Finite Automata (DFAs)

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Algorithms for NLP

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,

UNIT-III REGULAR LANGUAGES

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Theory of Computation

What we have done so far

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Nondeterministic finite automata

CMSC 330: Organization of Programming Languages

Classes and conversions

September 7, Formal Definition of a Nondeterministic Finite Automaton

Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

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

Computational Models #1

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

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Finite Automata Part Two

Theory of Languages and Automata

Lecture Notes on Inductive Definitions

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Homework 02 Solution updated

Deterministic Finite Automata (DFAs)

Finite Automata and Regular languages

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

Fooling Sets and. Lecture 5

Introduction to Theory of Computing

Computational Models - Lecture 1 1

Computational Models - Lecture 4

Computational Models: Class 3

Nondeterminism. September 7, Nondeterminism

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

Theory of Computation (I) Yijia Chen Fudan University

Computer Sciences Department

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Sri vidya college of engineering and technology

CSC173 Workshop: 13 Sept. Notes

Assignment #2 COMP 3200 Spring 2012 Prof. Stucki

Lecture 1: Finite State Automaton

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

Lecture 3: Finite Automata

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

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

Automata and Languages

Non-deterministic Finite Automata (NFAs)

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions

Java II Finite Automata I

CS21 Decidability and Tractability

Deterministic Finite Automata (DFAs)

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Introduction to Languages and Computation

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

10. The GNFA method is used to show that

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

Johns Hopkins Math Tournament Proof Round: Automata

CS375 Midterm Exam Solution Set (Fall 2017)

2017/08/29 Chapter 1.2 in Sipser Ø Announcement:

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

Lecture Notes on Inductive Definitions

Decision, Computation and Language

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

Theory of Computation

Transcription:

CS 581: Introduction to the Theory of Computation! Lecture 1! James Hook! Portland State University! hook@cs.pdx.edu! http://www.cs.pdx.edu/~hook/cs581f10/!

Welcome!!

Contact Information! Jim Hook! Office: FAB 120-05! Phone: 503 725 5540! Email: hook@cs.pdx.edu! Office hours: Tuesdays, 2-4pm (no arrivals after 3:30 please) or by appointment! TA: TBA!

Assumptions:! 1. Students have been exposed to the concepts of! 1. regular expressions,! 2. context free grammars, and! 3. programming in a general purpose language.! 2. They have applied these concepts to solve problems such as lexical analysis, parsing, and code generation.! 3. Students are familiar with discrete mathematics, including sets, sequences, induction and elementary graph theory.!

Course Objectives! Introduce students to the classic results in theoretical computer science that classify problems according to the machines that can solve them and the resources required by those machines. This includes basic results relating to computable functions, decidability, and complexity theory.! Master basic proof techniques used in these results including induction, diagonalization, and reduction.! Illuminate the relationship between logic and computation.!

Collaboration Policy! Unless explicitly instructed otherwise, please hand in solutions that you prepared individually without directly consulting other sources or notes.! Never represent the work of others as your own work.!

Collaboration Policy (cont)! You may meet with other students to discuss homework problems, but please discard all notes from these sessions.! Do not consult notes from discussions with other students or other solutions when preparing your solution.! Do not provide other students with access to your solution.!

Collaboration Policy (cont)! If you require resources other than the book to solve a problem please identify those resources with proper citations (but, as for collaborations, set the source aside and do not consult it directly when preparing your solution).! When selecting other resources, give priority to original sources, texts, and lecture notes.! Do not consult sample solutions specific to the problems assigned.!

Collaboration Policy (cont)! No exam problems are to be discussed until all students have handed in their exams.! Students are responsible to keep their exam answers to themselves. Allowing a solution to be copied is as serious a breach of academic integrity as copying.!

Academic Integrity! Violations of academic integrity will be taken seriously! There will be an in-class penalty! I will invoke the appropriate university mechanism!

Exams! There will be two exams:! Mid-term, October 27, 2010, in-class! Final,! Monday, December 6, 2010,! 5:30-7:20pm,! in-class, comprehensive!

Grading! All grading will be on a curve! After applying the curve to normalize the scales, grades will be combined as follows:! 30% Homework! 30% Midterm! 40% Final!

Grading! Assigning letter grades! First cut! Greater than mean plus standard deviation is an A! Less than mean minus standard deviation is a C! Refinement! Look for clusters; if grades differ by an insignificant amount, round to the higher grade! Assign A-, B, B- based on clusters! B- and C are functionally equivalent; neither can be applied towards graduation! Discretion! I will use my judgment to make minor adjustments!

End of Course Mechanics!

How hard is a problem?! Does oo occur in Hook?! Is 17 prime?! Is there a winning strategy for tictac-toe?! Will foo.c ever dereference a null pointer?!

Static (finite) problems are uniformative! All these have yes or no answers that I can build into a program! Does oo occur in Hook?! Is 17 prime?! Is there a winning strategy for tic-tac-toe?! Will foo.c ever dereference a null pointer?! How do we generalize these to problems too big to just memorize?!

Problems to Languages 1! Does oo occur in Hook?! { x oo occurs in x }! Is 17 prime?! {n n is prime}! Is there a winning strategy for tic-tac-toe?! No obvious generalization; problem too specific! Will foo.c ever dereference a null pointer?! {p.c p.c does not dereference a null pointer}!

Problems to Languages:! Solving problem = language membership! Does oo occur in Hook?! Is Hook in the language! { x oo occurs in x }! Is 17 prime?! Is 17 in the set {n n is prime}?! Will foo.c ever dereference a null pointer?! Is foo.c in the set of C programs that do not dereference a null pointer?!

More Languages! Binary numbers congruent to 2 mod 3! {10,101,1000,1011, }! Correct sums in decimal! {<x,y,z> x+y = z}! {<1,1,2>, <2,3,5>, }! Syntactically Correct C programs! Balanced parenthesis! {(), ()(), (()), (()()), }!

Classifying Problems! Map of the world! Define classes of problems! Machines recognize! Grammars generate! Develop techniques to classify problems by machines! 2 mod 3 substring

First Model: Finite Automata! Cartoon:! 0 1 1 0 0 Start State Final State Transition labels 1

First Model: Finite Automata! Cartoon:! 0 1 1 1 0 0 Examples: Which of the following are accepted? 000 10 101 111 100 1011 What is the language?

First Model: Finite Automata! Cartoon:! 0 1 1 How many states? What is the input alphabet 0 1 0 0 2 1

Cartoon to Mathematical Structure! Cartoon:! 0 0 1 1 1 0 1 2 0 A (deterministic) finite automaton (DFA) M is a 5-tuple M = <Q, Σ, δ, q 0, F> where Q is a finite set (states) Σ is a finite set (alphabet) δ: Q Σ Q (transition) q 0 Q (initial state) F Q (final states)

Cartoon to Mathematical Structure! Cartoon:! 0 0 1 1 0 1 2 0 M 2 mod 3 = <Q, Σ, δ, q 0, F> where Q = {0,1,2} Σ = {0,1} δ(q,a) = 2*q+a mod 3 q 0 = 0 F = {2} 1

Acceptance! M accepts the string w = w 1 w 2 w n if there exists a sequence of states! r 0, r 1, r 2,, r n! such that! 1. r 0 = q 0! 2. r i+1 = (r i,w i+1 ) for all i, 0 <= i < n! 3. r n F!

Calculation:! r 0 = 0! M 2 mod 3 accepts 101! r 1 = 2*0 + 1 mod 3 = 1! r 2 = 2*1 + 0 mod 3 = 2! r 3 = 2*2 + 1 mod 3 = 2! Since r 3 F (i.e. 2 {2})! this satisfies the definition! of acceptance for M 2 mod 3! M 2 mod 3 = <Q,,, q 0, F>! where! Q = {0,1,2}! = {0,1}! (q,a) = 2*q+a mod 3! q 0 = 0! F = {2}!

Regular languages "! L(M) = { w M accepts w }! A language A is regular if A = L(M) for some finite automaton M! The language! binary numbers congruent to 2 mod 3 is a regular language because it is! L(M 2 mod 3 ), and M 2 mod 3 is a DFA!

Classifying Problems! Map of the world! Regular Languages! Examples of other regular languages?! 2 mod 3

Extending the model! What if we allow multiple possible transitions on the same symbol?! 0,1 1 0,1 0,1

Extending the model! How should this machine behave?! 0,1 1 0,1 0,1 Examples:! 100! 111000! 111! 0000!

Nondeterminism! If we can win we do win! 0,1 1 0,1 0,1

Changing the Model! A (deterministic) nondeterministic finite automaton (DFA NFA) M is a! 5-tuple! M = <Q,,, q 0, F>! where! Q is a finite set (states)! is a finite set (alphabet)! : Q -> P(Q) (transition)! q 0 is in Q (initial state)! F subset of Q (final states)!

Nondeterminism! 0,1 1 0,1 0,1 a b c d M = <Q,,, q 0, F>! where! "Q = {a,b,c,d}! " = {0,1}! " "q 0 = 0! " "F = {d}!! 0! 1! a! {a}! {a,b}! b! {c}! {c}! c! {d}! {d}! d! {}! {}!

NFA Acceptance! M accepts the string w = w 1 w 2 w n if there exists a sequence of states! r 0, r 1, r 2,, r n! such that! 1. r 0 = q 0! 2. r i+1 = (r i,w i+1 ) for all i, 0 <= i < n! 3. r n is in F!

NFA Acceptance! M accepts the string w = w 1 w 2 w n if there exists a sequence of states! r 0, r 1, r 2,, r n! such that! 1. r 0 = q 0! 2. r i+1 (r i,w i+1 ) for all i, 0 <= i < n! 3. r n is in F!

NFA vs. DFA?! Can NFAs describe more languages than DFAs?!

Comparing two models! To answer the question is X the same as Y we have two strategies! No: Show an X that isn t a Y (or v.v.)! produce a counter example! Yes: Show that:! every X is a Y! every Y is an X! Often we will give constructions (or algorithms) that build an X out of Y (or v.v.)!

NFA vs. DFA?! Can NFAs describe more languages than DFAs?! Clearly if A = L(M) for a DFA M, then A = L(M) for a similar NFA! Why?! What about the other direction? Can every language recognized by an NFA be recognized by a DFA?!

Simulating an NFA on 101! 0,1 1 0,1 0,1 a b c d 0,1 1 0,1 0,1 a b c d 0,1 1 0,1 0,1 a b c d 0,1 1 0,1 0,1 a b c d

Strategy! Track the set of states! {a}! {a,b}! {a,c}! {a,b,d}! a b c d a b c d a b c d a b c d

DFA state: set of NFA states! Since the powerset of a finite set is finite, we can use sets of states of the NFA as states of the DFA that will simulate it! Each transition will now be deterministic because there is always a well defined set of reachable states! Which states should be final?!

Formalizing! Claim: If A = L(M) for an NFA M, then A = L(M ) for a DFA M.! Proof: Given M = <Q,,, q 0, F>, construct M = <P(Q),,, {q 0 }, F > where! " (R,a) "= r R (r,a)! "F " "= {R R F }!

Are we there yet?! We have the construction of M from M! We haven t shown L(M) = L(M )! Need! w L(M) w L(M )! w L(M ) w L(M)! Why?!

Show w L(M) w L(M )! Proof resources?! Construction of M! Definition of acceptance for DFAs and NFAs! Need to show if M can accept w then M must accept w! Is it plausible?! Given M = <Q,,, q 0, F>, construct M = <P(Q),,, {q 0 }, F > where " (R,a) "= r R (r,a)! "F "= {R R F }! M accepts the string w = w 1 w 2 w n if there exists a sequence of states! r 0, r 1, r 2,, r n! such that! 1. r 0 = q 0! 2. r i+1 = (r i,w i+1 )! for all i, 0 <= i < n! 3. r n F!

Show w L(M) w L(M )! Basic idea:! If M can get from state p to state q reading w,! then M will move from {p} to a state R containing q on input w! Given M = <Q,,, q 0, F>, construct M = <P(Q),,, {q 0 }, F > where " (R,a) "= r R (r,a)! "F "= {R R F }! M accepts the string w = w 1 w 2 w n if there exists a sequence of states! r 0, r 1, r 2,, r n! such that! 1. r 0 = q 0! 2. r i+1 = (r i,w i+1 )! for all i, 0 <= i < n! 3. r n F!

Notational asside! from state p to state q reading w! ˆ(p, w) = q! For DFAs! ˆ(p, ) = p! ˆ(p, w 1 w) = ˆ( (p, w 1 ), w)! For NFAs! ˆ(p, ) = {p}! ˆ(p, w 1 w) = q (p, w1) ˆ(q, w)!

Show w L(M) w L(M )! Basic idea:! If q ˆ(p, w)! then q R, where! R = ˆ({p}, w)! Basic idea:! If M can get from state p to state q reading w,! then M will move from {p} to a state R containing q on input w!

Show w L(M) w L(M )! Claim:! If q ˆ(p, w)! then q R, where! R = ˆ({p}, w)! Proof: By induction on the length of w! Basis: w =! In this case q = p, R={p}, and the condition holds by definition!

Show w L(M) w L(M )! Claim:! If q ˆ(p, w)! then q R, where R = ˆ({p}, w)! Step: w = w 1 y! Assume the property holds for y to show for w.! q ˆ(p, w 1 y) = r (p, w1) ˆ(r, y)! Hence for some r (p, w1), q ˆ(r, y)! By induction, q R, where R = ˆ({r }, y)!

Show w L(M) w L(M )! Step: w = w 1 y! Assume the property holds for y to show for w.! q ˆ(p, w 1 y) = r (p, w1) ˆ(r, y)! Hence for some r (p, w1), q ˆ(r, y)! By induction, q R, where R = ˆ({r }, y)! Recall we are trying to show! "q R, where R = ˆ({p}, w 1 y)! which is equivalent to! "q R, where R = ˆ( ({p}, w 1 ),y)! "q R, where R = ˆ( (p, w 1 ),y)! Problem: mismatch between {r } and (p, w 1 )! Must generalize claim to apply induction!

Show w L(M) w L(M )! Claim (generalized):! If q ˆ(p, w)! then p S implies q R, where R = ˆ(S, w)! Proof: By induction on the length of w! Basis: w =! In this case q = p, R=S, and the condition holds by reflexivity, p S implies p S!

Show w L(M) w L(M )! Claim (generalized):! If q ˆ(p, w)! then p S implies q R, where R = ˆ(S, w)! Step: w = w 1 y! Assume the property holds for y to show for w.! q ˆ(p, w 1 y) = r (p, w1) ˆ(r, y)! Hence for some r (p, w1), q ˆ(r, y)! By induction, r S implies q R, where! R = ˆ(S, y)!

Show w L(M) w L(M )! Step: w = w 1 y! Assume the property holds for y to show for w.! q ˆ(p, w 1 y) = r (p, w1) ˆ(r, y)! Hence for some r (p, w 1 ), q ˆ(r, y)! By induction, r S implies q R, where R = ˆ(S, y)! Recall we are trying to show! "p S implies q R, where R = ˆ(S, w 1 y)! rewriting R! "R = ˆ( (S, w 1 ),y)! "R = ˆ( (p, w 1 ) X,y)! Since p S implies r (p, w 1 ) X, we can apply induction to conclude q R, as required!

Using the Claim! By definition of acceptance for M! w L(M) implies there are states r 0, r 1, r n satisfying acceptance conditions! by the claim! there are states of M R 0, R 1,, R n! where R 0 = {q 0 }, r i R i! since r n F and r n R n, R n F! Hence R n F, establishing the acceptance conditions for M!

Are we there yet?! We have the construction of M from M! We haven t shown L(M) = L(M )! Need! w L(M) w L(M )! w L(M ) w L(M)! Why?!

w L(M ) w L(M)! Must show that if the deterministic simulation includes a final state, then the nondeterministic machine could have made choices that reach it! Claim: q R, where R= ˆ(S,w) implies there exists p S. q ˆ(p,w)! Proof: By induction on w!

w L(M ) w L(M)! Claim: q R, where R= ˆ(S,w) implies there exists p S such that! q ˆ(p,w)! Proof: By induction on w! Basis: w =! In this case R = S. satisfy the claim! Pick p = q to

w L(M ) w L(M)! Claim: q R, where R= ˆ(S,w) implies there exists p S. q ˆ(p,w)! Step: w = w 1 y! R = ˆ(S,w)! R = ˆ(S, w 1 y)! R = ˆ( (S, w 1 ), y)! By induction, there is a p in (S, w 1 ) such that q ˆ(p,y)!

w L(M ) w L(M)! Claim: q R, where R= ˆ(S,w) implies there exists p S such that q ˆ(p,w)! Step: w = w 1 y! By induction, there is a p in (S, w 1 ) such that q ˆ(p,y)! By definition, (S, w 1 ) = r S (r,a)! Hence, for some particular r S, p must be in (r,a).! Take p to be this r.!

w L(M ) w L(M)! Claim: q R, where R= ˆ(S,w) implies there exists p S such that q ˆ(p,w)! Step: w = w 1 y! Take p to be this r.! Verify that p has the property desired as follows:! q ˆ(p,w)! q ˆ(p, w 1 y)! q s (p, w1) ˆ(s, y)! q ˆ(r, y) X (for some set X, r as previous slide)! But this last line is a consequence of the induction hypothesis, since we have demonstrated q ˆ(r, y)! This proves the claim.!

Applying the Claim! To show w L(M ) w L(M), consider w L(M ).! By definition of acceptance this means there is a sequence of states R 0, R 1,, R n satisfying the conditions.! By definition of M and condition 1, R 0 ={q 0 }.! Similarly R n F is not empty.! Consider r n R n F, which will satisfy acceptance condition 3! By repeated application of the claim, select a sequence of r i R i for each i.! By the claim these r i can be selected to satisfy acceptance condition 2 for M. Furthermore, r 0 = q 0, satisfying condition 1 for M.! This establishes w L(M), as required!

Are we there yet?! We have the construction of M from M! We haven t shown L(M) = L(M )! Need! w L(M) w L(M )! w L(M ) w L(M)! Done!!

What have we proved?! If a language is accepted by an NFA then it is regular (accepted by a DFA)!

Note! The development in the book introduces -transitions at the same time as nondeterminism! In this lecture we have omitted transitions! How does this impact the proofs?! We will use -transitions freely!