CSE 105 Theory of Computation

Similar documents
CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 Theory of Computation Professor Jeanne Ferrante

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

CSE 105 Theory of Computation

CSE 105 Theory of Computation

Sri vidya college of engineering and technology

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 105 THEORY OF COMPUTATION

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

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

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

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

CSE 105 THEORY OF COMPUTATION

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CMSC 330: Organization of Programming Languages

CS 154. Finite Automata, Nondeterminism, Regular Expressions

1 Two-Way Deterministic Finite Automata

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

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

CSE 105 THEORY OF COMPUTATION

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

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

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

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 455/555: Finite automata

Finite Automata and Regular languages

CPS 220 Theory of Computation REGULAR LANGUAGES

CS 154 Introduction to Automata and Complexity Theory

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CSE 105 THEORY OF COMPUTATION

Finite Automata and Languages

Deterministic Finite Automata (DFAs)

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

COM364 Automata Theory Lecture Note 2 - Nondeterminism

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Theory of Computation Lecture 1. Dr. Nahla Belal

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

Deterministic Finite Automata (DFAs)

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Nondeterministic finite automata

CSE 105 Theory of Computation

Finite Automata Part Two

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

CSE 105 THEORY OF COMPUTATION

Finite Automata. Warren McCulloch ( ) and Walter Pitts ( )

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

Chapter 6. Properties of Regular Languages

Closure under the Regular Operations

CS 208: Automata Theory and Logic

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

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

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,

Fooling Sets and. Lecture 5

False. They are the same language.

Deterministic Finite Automata (DFAs)

Constructions on Finite Automata

CSE 105 THEORY OF COMPUTATION

How do regular expressions work? CMSC 330: Organization of Programming Languages

3515ICT: Theory of Computation. Regular languages

CSCI 2670 Introduction to Theory of Computing

Assignment #2 COMP 3200 Spring 2012 Prof. Stucki

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

Nondeterministic Finite Automata

Theory of Computation

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

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Computational Models - Lecture 3 1

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSE 105 THEORY OF COMPUTATION

CSC173 Workshop: 13 Sept. Notes

Notes on Finite Automata

Equivalence of DFAs and NFAs

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

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

Decidability (What, stuff is unsolvable?)

CS243, Logic and Computation Nondeterministic finite automata

Chapter Five: Nondeterministic Finite Automata

Decidability of WS1S and S1S (An Exposition) Exposition by William Gasarch-U of MD

CS 154 Formal Languages and Computability Assignment #2 Solutions

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS20a: Turing Machines (Oct 29, 2002)

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

1 Alphabets and Languages

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

Automata Theory and Formal Grammars: Lecture 1

10. The GNFA method is used to show that

Nondeterminism and Epsilon Transitions

CSE 105 THEORY OF COMPUTATION

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS21 Decidability and Tractability

Languages, regular languages, finite automata

Computational Theory

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

Transcription:

CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1

Today s agenda Formal definition of DFA DFA design Regular languages Closure properties of the regular languages Lots More Office Hours! Check out calendar & Go! Reminder: HW 1 due Friday (April 1, no fooling) by 11:59 pm 2

Lec. 1 Review Question Which ONE of the following is FALSE? A. There is a DFA whose language is the empty set B. DFA s have only 1 start state C. DFA s can recognize languages with infinitely many strings D. DFA s have only 1 final state E. For any finite set of strings, there is a DFA that recognizes that finite set 3

A different way of specifying a DFA FORMAL DEFINITION OF DFA 4

Formal Definition of a DFA A DFA M 1 is a 5-tuple (Q, Σ, δ, q0, F), where: Q is a finite set of states Σ is a finite set of characters, the alphabet δ: Q x Σ -> Q, the transition function q0, a member of Q, the start state F, a subset of Q, the set of final state(s) Q = Σ = The start state = F = 5

Can 2 different DFA s recognize the same language? A. Yes, but the diagrams must be isomorphic as graphs B. Yes, but the 2 automata must have the same number of states C. Yes, and the automata can have a different number of states D. No, each DFA recognizes a distinct language 6

DFA s recognize Regular Languages A language L is regular if there is DFA that recognizes it. We ll use the formal definition of DFA in proofs instead of diagrams We won t have DFA diagrams to work with But we ll be able to refer to specific parts of the DFA (e.g. F, the set of final states) Let s take a closer look at δ 7

M = δ: Q x Σ -> Q Transition Table A. s a b q1 q1 q2 q2 q1 q2 L(M) = {w length(w) is odd} (Note: w = length of w) Which table best describes δ? B. C. a b q1 q2 q2 q2 q1 q1 a b q1 q1 q1 q2 q2 q2 8

Finite Automata: Historical Perspective Michael Rabin Dana Scott In 1976, Rabin and Scott won the Turing Award, the highest award in computer science, for their 1959 paper, "Finite Automata and Their Decision Problems" They wrote the paper while spending a summer at IBM Research! Origin of FA from 1943 McCulloch and Pitts paper, "A logical calculus of the ideas immanent in nervous activity, a mathematical model of neural activity and networks 9

Now that you see how DFA s work DESIGNING YOUR OWN DFA 10

Which states should be in F so that DFA M 2 recognizes the language L 2 = {w w contains less than 1 a or more than 1 a}? (Σ = {a,b}) M 2 : A. F = {q2} B. F = {q3} C. F = {q1, q2} D. F = {q1, q3} E. F = {q2, q3} 11

Designing DFA s States are the only mechanism for a DFA to remember what it has seen of input string so far When you design a DFA, it helps to associate a meaning to each state and name it accordingly It s comparable to writing comments in code It s also useful, and we will practice, describing DFA transitions in words To be correct, need to satisfy both: Include all strings you need to accept Exclude all strings you need to reject (not accept) 12

Designing DFA s L = {w w contains aa as substring} S = {a,b} Please note that this diagram is correct, but would not execute correctly in JFLAP! 13

Designing DFA s L = {w w contains aa as substring but not bb} 14

Designing DFA s L = {w w is positive and even when interpreted as binary number} S = {0,1} 15

Digging deeper into what it means to be a regular language CLOSURE PROPERTIES OF THE REGULAR LANGUAGES 16

Regular Languages The set of languages for which there exists a DFA that (exactly) recognizes the language Note that the Regular Languages is a How large is this set? set of sets of strings What are its boundaries? Thm 1.25. The class of regular languages is closed under the union operation. 17

Review: Closure Properties/ Closed Under Which of the following statements are FALSE? A. Integers are closed under addition B. Integers are closed under division C. Even numbers are closed under addition 18

Thm 1.25. The class of regular languages is closed under the union operation. { w in w, b's never appear after a s } r1 r2 {w length(w) is odd} DESIGN METHOD: Use Cartesian Product of State Sets 19

Thm. The class of regular languages is closed under the Our working example: a (r1,q1) (r2,q2) (r2,q1) (r1,q2) (r2,q2) (r2,q3) (r1,q3) (r2,q3) (r2,q3) (r2,q1) (r1,q2) (r1,q1) (r2,q2) (r1,q2) (r1,q3) b union operation. A generalized proof form: Given two regular languages L1, L2, with DFAs M1, M2 M1 = (Q1,Σ,δ1,q 0 1,F1) M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: Q = Q1 x Q2 δ = q 0 = F = M recognizes L1 U L2: A DFA recognizes L1 U L2, then L1 U L2 must be regular (r2,q3) (r1,q3) (r1,q3) 20

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L1, L2, with DFAs M1, M2 M1 = (Q1,Σ,δ1, s1,f1) M2 = (Q2,Σ,δ2, s2,f2) We construct a DFA M = (Q,Σ,δ, q 0,F) such that: Q = Q1 x Q2 δ = q 0 = F = Correctness: We show that M recognizes L1 U L2: Conclusion: A DFA recognizes L1 U L2, then L1 U L2 must be regular 21

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L1, L2, with DFAs M1, M2 M1 = (Q1,Σ,δ1,s1,F1) M2 = (Q2,Σ,δ2, s2,f2) We construct a DFA M = (Q,Σ,δ, q 0,F), such that: Q = Q1 x Q2 δ = q 0 = F = Which is true for q 0 in the proof? Correctness: We show that M recognizes L1 U L2: A. q 0 = s1 B. q 0 = s2 C. q 0 = (s1, s2) D. q 0 = {(s1,s2)} Conclusion: A DFA recognizes L1 U L2, then L1 U L2 must be regular 22

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L1, L2, with DFAs M1, M2 M1 = (Q1,Σ,δ1, s1,f1) M2 = (Q2,Σ,δ2, s2,f2) We construct a DFA M = (Q,Σ,δ, q 0,F) such that: Q = Q1 x Q2 δ = q 0 = F = Which is FALSE for δ? A. δ: Q1 x Q2 Q B. δ: Q1 x Q2 x Σ Q C. δ((x,y),c) = (δ1(x,c), δ2(y,c)), for c in Σ and (x,y) in Q D. None of the above Correctness: We show that M recognizes L1 U L2: Conclusion: A DFA recognizes L1 U L2, then L1 U L2 must be regular 23

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L1, L2, with DFAs M1, M2 M1 = (Q1,Σ,δ1, s1,f1) M2 = (Q2,Σ,δ2, s2,f2) We construct a DFA M = (Q,Σ,δ, q 0,F) such that: Q = Q1 x Q2 δ = q 0 = F = Which is true for F? A. F = F1 x F2 B. F = F1 U F2 C. F = {(x,y) in Q x in F1 or y in F2} D. None of the above Correctness: We show that M recognizes L1 U L2: Conclusion: A DFA recognizes L1 U L2, then L1 U L2 must be regular 24

Thm. The class of regular languag es is clos ed under the union operation. Proof: Given: Two regular lang uag es L1, L2. Want to sh ow: L1 U L2 is regular. Because L1 and L2 are regular, we know there exist D FAs M1 = (Q1,Σ,δ1,s1,F1) and M2 = (Q2,Σ,δ2,s2,F2) that recognize L1 and L2. We construct a D FA M = (Q,Σ,δ,q0,F), s.t.: Q = Q1 x Q2 δ((x,y),c) = (δ1(x,c), δ2 (y,c)), for c in Σ and (x,y) in Q q0 = (s1, s2) F = { (x,y) in Q x in F1 or y in F2} C o r r e c t n e s s : We s h o w M recog nizes L1 U L2. Let x be a string whose computation in M ends in state (q,r). If x is accepted by M, then q is in F1 or r is in F2. Therefore x is accepted by M1 or M2, so x is in L1 U L2. If x is not accepted by M, then q is not in F1 and r is not in F2, and x is not accepted by either M1 or M2. Therefore x is not in L1 U L2. Conclusion: Th e r e i s a D FA that recognizes L1 U L2, so L1 U L2 is regular, and the class of reg ular lang uag es is closed under union. 25

Thm. The class of regular languages is clos ed under Intersection Proof: G iven: Two re g ular lang uag e s L1, L2. Want to sh ow: L1 L2 is re g ular. Because L1 and L2 are re g ular, we know there exist D FAs M1 = (Q1,Σ,δ1,s1,F1) and M2 = (Q2,Σ,δ2,s2,F2) that reco g nize L1 a n d L2. W e construct a D FA M = (Q,Σ,δ,q0,F), s.t.: Q = Q1 x Q2 δ((x,y),c) = (δ1(x,c), δ2 (y,c)), for c in Σ and (x,y) in Q q0 = (s1, s2) F = { (x,y) in Q x in F1 and y in F2} C o r r e c t n e s s : W e s h o w t h a t M recog nizes L1 L2. Let x be a string whose computation in M ends in state (q,r). If x is accepted by M, then q is in F1 and r is in F2. Therefore x is accepted by M1 and M2, so x is in L1 L2. If x is a string not recognized by M, then either q is not in F1 or r is not in F2. Therefore, x is not accepted by one of M1 and M2, and so M is not in L1 L2. Conclusion: A D FA recognizes L1 L2, so L1 L2 is regular, and the class of reg ular lang uag es is closed under union. Q.E.D. 26

Highlights of DFA s so far Input: a string of symbols, of any length, over the alphabet A DFA M accepts a string w if using w as input to M from the start state leads to a final (accept) state Designed to recognize language L The set of strings that are accepted by DFA Remaining strings are rejected by DFA To specify a DFA M, either: As example: Draw its State Diagram, with exactly 1 outgoing edge for each member of M s alphabet, or In a proof: Define each component in 5-tuple (Q, Σ, δ, q0, F) A language L is regular if there is some DFA M that recognizes L. Regular languages are closed under U and operations 27